Map protected-internal types to the plain protected overlay

The WPF frontend uses a type-only overlay mapper that shows protected
internal types with the plain protected badge, while members get the
combined protected-internal badge; the Avalonia frontend ran both through
the shared Images.GetOverlay and so badged types differently. Restore the
type-only mapping in TypeTreeNode.GetIcon, which now also covers search
results and every other caller of the helper.

Assisted-by: Claude:claude-fable-5:Claude Code
This commit is contained in:
Christoph Wille
2026-08-24 12:38:56 +02:00
parent c11eded3ea
commit 300c075ffe
2 changed files with 23 additions and 2 deletions
@@ -91,6 +91,20 @@ public class SearchResultFactoryIconTests
icon.BaseImage.Should().BeSameAs(Images.Enum);
}
[AvaloniaTest]
public void Protected_Internal_Nested_Type_Gets_Plain_Protected_Overlay()
{
var nested = fixtureType.NestedTypes
.Single(t => t.Name == "NestedProtectedInternal").GetDefinition()!;
var icon = (LayeredImage)factory.Create(nested).Image;
// Types map protected-internal to the plain protected badge; only members show
// the combined protected-internal badge. Matches the WPF frontend's type-only
// overlay mapping.
icon.Overlays.Should().Equal(Images.OverlayProtected);
}
[AvaloniaTest]
public void Location_Image_Reflects_Declaring_Type_Icon()
{
@@ -113,5 +127,7 @@ class SearchIconFixture
internal interface INested { }
enum NestedEnum { None }
protected internal class NestedProtectedInternal { }
}
#pragma warning restore CS0169
+7 -2
View File
@@ -75,8 +75,13 @@ namespace ICSharpCode.ILSpy.TreeNodes
TypeKind.Enum => Images.Enum,
_ => Images.Class,
};
return Images.GetIcon(baseImage,
Images.GetOverlay(type.Accessibility), type.IsStatic);
// Types map protected-internal to the plain protected badge; only members show
// the combined protected-internal badge. Matches the WPF frontend's type-only
// overlay mapping.
var overlay = type.Accessibility == Accessibility.ProtectedOrInternal
? AccessOverlayIcon.Protected
: Images.GetOverlay(type.Accessibility);
return Images.GetIcon(baseImage, overlay, type.IsStatic);
}
public override bool CanExpandRecursively => true;