Browse Source

MethodTreeNode hides extension-block impl methods

Pair to ea56a80cd. When DecompilerSettings.ExtensionMembers is on and the
active language is C#, methods that the decompiler identifies as implementation
methods for an extension block are filtered out of the outer static class —
they surface as ExtensionTreeNode children of the containing static class
instead. Without this gate the user would see each extension member twice:
once as a regular method on the static container, once under the extension
block. Mirrors WPF MethodTreeNode.Filter lines 95-104 verbatim.

Assisted-by: Claude:claude-opus-4-7:Claude Code
pull/3755/head
Siegfried Pammer 2 months ago
parent
commit
2b0016ae5a
  1. 29
      ILSpy/TreeNodes/MethodTreeNode.cs

29
ILSpy/TreeNodes/MethodTreeNode.cs

@ -69,15 +69,38 @@ namespace ILSpy.TreeNodes
{ {
if (settings.ShowApiLevel == ApiVisibility.PublicOnly && !IsPublicAPI) if (settings.ShowApiLevel == ApiVisibility.PublicOnly && !IsPublicAPI)
return FilterResult.Hidden; return FilterResult.Hidden;
// WPF additionally hides extension-block implementation methods when the // Hide implementation methods of C# 14 extension blocks when ExtensionMembers is on
// ExtensionMembers decompiler setting is on; tracked as `methodtreenode-extension-gate` // — those land as ExtensionTreeNode children of the static container instead, so
// in the parity TODO and reinstated when the DecompilerSettings UI lands. // surfacing them on the outer class would be duplicate UI. Pair to the
// `extension-methods-tree` work in ea56a80cd.
if (LanguageService.CurrentLanguage is Languages.CSharpLanguage
&& MethodDefinition.DeclaringTypeDefinition?.ExtensionInfo is { } extInfo)
{
var decompilerSettings = TryGetDecompilerSettings();
if (decompilerSettings?.ExtensionMembers == true
&& extInfo.InfoOfImplementationMember((IMethod)MethodDefinition.MemberDefinition).HasValue)
{
return FilterResult.Hidden;
}
}
if (settings.SearchTermMatches(MethodDefinition.Name) && (settings.ShowApiLevel == ApiVisibility.All || LanguageService.CurrentLanguage.ShowMember(MethodDefinition))) if (settings.SearchTermMatches(MethodDefinition.Name) && (settings.ShowApiLevel == ApiVisibility.All || LanguageService.CurrentLanguage.ShowMember(MethodDefinition)))
return FilterResult.Match; return FilterResult.Match;
else else
return FilterResult.Hidden; return FilterResult.Hidden;
} }
static ICSharpCode.Decompiler.DecompilerSettings? TryGetDecompilerSettings()
{
try
{
return AppEnv.AppComposition.Current.GetExport<SettingsService>().DecompilerSettings.Clone();
}
catch
{
return null;
}
}
// Stable identity for SessionSettings.ActiveTreeViewPath; format must round-trip // Stable identity for SessionSettings.ActiveTreeViewPath; format must round-trip
// across launches so the saved path can be restored. // across launches so the saved path can be restored.
public override string ToString() public override string ToString()

Loading…
Cancel
Save