Browse Source

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
pull/4044/head
Christoph Wille 3 weeks ago
parent
commit
300c075ffe
  1. 16
      ILSpy.Tests/Search/SearchResultFactoryIconTests.cs
  2. 9
      ILSpy/TreeNodes/TypeTreeNode.cs

16
ILSpy.Tests/Search/SearchResultFactoryIconTests.cs

@ -91,6 +91,20 @@ public class SearchResultFactoryIconTests
icon.BaseImage.Should().BeSameAs(Images.Enum); 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] [AvaloniaTest]
public void Location_Image_Reflects_Declaring_Type_Icon() public void Location_Image_Reflects_Declaring_Type_Icon()
{ {
@ -113,5 +127,7 @@ class SearchIconFixture
internal interface INested { } internal interface INested { }
enum NestedEnum { None } enum NestedEnum { None }
protected internal class NestedProtectedInternal { }
} }
#pragma warning restore CS0169 #pragma warning restore CS0169

9
ILSpy/TreeNodes/TypeTreeNode.cs

@ -75,8 +75,13 @@ namespace ICSharpCode.ILSpy.TreeNodes
TypeKind.Enum => Images.Enum, TypeKind.Enum => Images.Enum,
_ => Images.Class, _ => Images.Class,
}; };
return Images.GetIcon(baseImage, // Types map protected-internal to the plain protected badge; only members show
Images.GetOverlay(type.Accessibility), type.IsStatic); // 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; public override bool CanExpandRecursively => true;

Loading…
Cancel
Save