diff --git a/ILSpy/FilterSettings.cs b/ILSpy/FilterSettings.cs index 6adb3200db..1c7224fc5a 100644 --- a/ILSpy/FilterSettings.cs +++ b/ILSpy/FilterSettings.cs @@ -47,6 +47,7 @@ public class FilterSettings : INotifyPropertyChanged public FilterSettings(XElement element) { this.ShowApiLevel = (ApiVisibility?)(int?)element.Element("ShowAPILevel") ?? ApiVisibility.PublicAndInternal; + this.ShowApiInherited = (bool?)element.Element("ShowAPIInherited") ?? false; this.Language = Languages.GetLanguage((string)element.Element("Language")); this.LanguageVersion = Language.LanguageVersions.FirstOrDefault(v => v.Version == (string)element.Element("LanguageVersion")); if (this.LanguageVersion == default(LanguageVersion)) @@ -58,6 +59,7 @@ public XElement SaveAsXml() return new XElement( "FilterSettings", new XElement("ShowAPILevel", (int)this.ShowApiLevel), + new XElement("ShowAPIInherited", this.ShowApiInherited), new XElement("Language", this.Language.Name), new XElement("LanguageVersion", this.LanguageVersion?.Version) ); @@ -142,6 +144,19 @@ public bool ApiVisAll { } } + bool showApiInherited; + + public bool ShowApiInherited { + get { return showApiInherited; } + set { + if (showApiInherited != value) + { + showApiInherited = value; + OnPropertyChanged(nameof(ShowApiInherited)); + } + } + } + Language language; /// diff --git a/ILSpy/MainWindow.xaml b/ILSpy/MainWindow.xaml index 0d236371fb..449a6f83d2 100644 --- a/ILSpy/MainWindow.xaml +++ b/ILSpy/MainWindow.xaml @@ -138,6 +138,7 @@ + diff --git a/ILSpy/Properties/Resources.Designer.cs b/ILSpy/Properties/Resources.Designer.cs index 397e5da3a7..48ddf90ba5 100644 --- a/ILSpy/Properties/Resources.Designer.cs +++ b/ILSpy/Properties/Resources.Designer.cs @@ -2503,7 +2503,16 @@ public static string Show_allTypesAndMembers { } /// - /// Looks up a localized string similar to Show public, private and internal. + /// Looks up a localized string similar to Show in_herited members. + /// + public static string Show_inheritedMembers { + get { + return ResourceManager.GetString("Show_inheritedMembers", resourceCulture); + } + } + + /// + /// Looks up a localized string similar to Show public, private and _internal. /// public static string Show_internalTypesMembers { get { diff --git a/ILSpy/Properties/Resources.resx b/ILSpy/Properties/Resources.resx index 6623f03530..9fd24357cd 100644 --- a/ILSpy/Properties/Resources.resx +++ b/ILSpy/Properties/Resources.resx @@ -901,8 +901,11 @@ Do you want to continue? Show _all types and members + + Show in_herited members + - Show public, private and internal + Show public, private and _internal Show only _public types and members diff --git a/ILSpy/Properties/Resources.zh-Hans.resx b/ILSpy/Properties/Resources.zh-Hans.resx index 0304ce4468..ee78054e8b 100644 --- a/ILSpy/Properties/Resources.zh-Hans.resx +++ b/ILSpy/Properties/Resources.zh-Hans.resx @@ -872,6 +872,9 @@ 显示所有类型和成员(_A) + + 显示继承成员(_H) + 显示内部类型和成员(_I) diff --git a/ILSpy/TreeNodes/TypeTreeNode.cs b/ILSpy/TreeNodes/TypeTreeNode.cs index 83126d88c3..9623d9bc74 100644 --- a/ILSpy/TreeNodes/TypeTreeNode.cs +++ b/ILSpy/TreeNodes/TypeTreeNode.cs @@ -31,6 +31,8 @@ namespace ICSharpCode.ILSpy.TreeNodes public sealed class TypeTreeNode : ILSpyTreeNode, IMemberTreeNode { + private bool? loadedInheritedMembers; + public TypeTreeNode(ITypeDefinition typeDefinition, AssemblyTreeNode parentAssemblyNode) { this.ParentAssemblyNode = parentAssemblyNode ?? throw new ArgumentNullException(nameof(parentAssemblyNode)); @@ -84,8 +86,23 @@ public override FilterResult Filter(FilterSettings settings) } } + protected override void OnFilterSettingsChanged() + { + base.OnFilterSettingsChanged(); + if (loadedInheritedMembers != null && loadedInheritedMembers != FilterSettings.ShowApiInherited) + { + this.Children.Clear(); + if (IsVisible) + LoadChildren(); + else + LazyLoading = true; + } + } + protected override void LoadChildren() { + loadedInheritedMembers = FilterSettings.ShowApiInherited; + GetMemberOptions inheritanceOptions = FilterSettings.ShowApiInherited ? GetMemberOptions.None : GetMemberOptions.IgnoreInheritedMembers; if (TypeDefinition.DirectBaseTypes.Any()) this.Children.Add(new BaseTypesTreeNode(ParentAssemblyNode.LoadedAssembly.GetPEFileOrNull(), TypeDefinition)); if (!TypeDefinition.IsSealed) @@ -104,20 +121,20 @@ protected override void LoadChildren() } else { - foreach (var field in TypeDefinition.Fields.OrderBy(f => f.Name, NaturalStringComparer.Instance)) + foreach (var field in TypeDefinition.GetFields(null, inheritanceOptions).OrderBy(f => f.Name, NaturalStringComparer.Instance)) { this.Children.Add(new FieldTreeNode(field)); } } - foreach (var property in TypeDefinition.Properties.OrderBy(p => p.Name, NaturalStringComparer.Instance)) + foreach (var property in TypeDefinition.GetProperties(null, inheritanceOptions).OrderBy(p => p.Name, NaturalStringComparer.Instance)) { this.Children.Add(new PropertyTreeNode(property)); } - foreach (var ev in TypeDefinition.Events.OrderBy(e => e.Name, NaturalStringComparer.Instance)) + foreach (var ev in TypeDefinition.GetEvents(null, inheritanceOptions).OrderBy(e => e.Name, NaturalStringComparer.Instance)) { this.Children.Add(new EventTreeNode(ev)); } - foreach (var method in TypeDefinition.Methods.OrderBy(m => m.Name, NaturalStringComparer.Instance)) + foreach (var method in TypeDefinition.GetMethods(null, inheritanceOptions).OrderBy(m => m.Name, NaturalStringComparer.Instance)) { if (method.MetadataToken.IsNil) continue;