From 300c075ffe7f910f2c658b1eddb8ff70e45eec79 Mon Sep 17 00:00:00 2001 From: Christoph Wille Date: Mon, 24 Aug 2026 12:38:56 +0200 Subject: [PATCH] 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 --- .../Search/SearchResultFactoryIconTests.cs | 16 ++++++++++++++++ ILSpy/TreeNodes/TypeTreeNode.cs | 9 +++++++-- 2 files changed, 23 insertions(+), 2 deletions(-) diff --git a/ILSpy.Tests/Search/SearchResultFactoryIconTests.cs b/ILSpy.Tests/Search/SearchResultFactoryIconTests.cs index 1bd44a96d..449771deb 100644 --- a/ILSpy.Tests/Search/SearchResultFactoryIconTests.cs +++ b/ILSpy.Tests/Search/SearchResultFactoryIconTests.cs @@ -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 diff --git a/ILSpy/TreeNodes/TypeTreeNode.cs b/ILSpy/TreeNodes/TypeTreeNode.cs index c96eda29d..6e0f8c299 100644 --- a/ILSpy/TreeNodes/TypeTreeNode.cs +++ b/ILSpy/TreeNodes/TypeTreeNode.cs @@ -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;