Browse Source

Add "Hide empty metadata tables in tree view" option

pull/1968/head
Siegfried Pammer 5 years ago
parent
commit
c55c1f9476
  1. 28
      ILSpy/Metadata/DebugMetadataTreeNode.cs
  2. 106
      ILSpy/Metadata/MetadataTreeNode.cs
  3. 13
      ILSpy/Options/DisplaySettings.cs
  4. 1
      ILSpy/Options/DisplaySettingsPanel.xaml
  5. 2
      ILSpy/Options/DisplaySettingsPanel.xaml.cs
  6. 9
      ILSpy/Properties/Resources.Designer.cs
  7. 3
      ILSpy/Properties/Resources.resx

28
ILSpy/Metadata/DebugMetadataTreeNode.cs

@ -18,8 +18,10 @@ @@ -18,8 +18,10 @@
using System.Linq;
using System.Reflection.Metadata;
using System.Reflection.Metadata.Ecma335;
using ICSharpCode.Decompiler;
using ICSharpCode.Decompiler.Metadata;
using ICSharpCode.ILSpy.Options;
using ICSharpCode.ILSpy.TreeNodes;
using ICSharpCode.ILSpy.ViewModels;
@ -61,14 +63,24 @@ namespace ICSharpCode.ILSpy.Metadata @@ -61,14 +63,24 @@ namespace ICSharpCode.ILSpy.Metadata
protected override void LoadChildren()
{
this.Children.Add(new DocumentTableTreeNode(this.module, this.provider, isEmbedded));
this.Children.Add(new MethodDebugInformationTableTreeNode(this.module, this.provider, isEmbedded));
this.Children.Add(new LocalScopeTableTreeNode(this.module, this.provider, isEmbedded));
this.Children.Add(new LocalVariableTableTreeNode(this.module, this.provider, isEmbedded));
this.Children.Add(new LocalConstantTableTreeNode(this.module, this.provider, isEmbedded));
this.Children.Add(new ImportScopeTableTreeNode(this.module, this.provider, isEmbedded));
this.Children.Add(new StateMachineMethodTableTreeNode(this.module, this.provider, isEmbedded));
this.Children.Add(new CustomDebugInformationTableTreeNode(this.module, this.provider, isEmbedded));
if (ShowTable(TableIndex.Document))
this.Children.Add(new DocumentTableTreeNode(this.module, this.provider, isEmbedded));
if (ShowTable(TableIndex.MethodDebugInformation))
this.Children.Add(new MethodDebugInformationTableTreeNode(this.module, this.provider, isEmbedded));
if (ShowTable(TableIndex.LocalScope))
this.Children.Add(new LocalScopeTableTreeNode(this.module, this.provider, isEmbedded));
if (ShowTable(TableIndex.LocalVariable))
this.Children.Add(new LocalVariableTableTreeNode(this.module, this.provider, isEmbedded));
if (ShowTable(TableIndex.LocalConstant))
this.Children.Add(new LocalConstantTableTreeNode(this.module, this.provider, isEmbedded));
if (ShowTable(TableIndex.ImportScope))
this.Children.Add(new ImportScopeTableTreeNode(this.module, this.provider, isEmbedded));
if (ShowTable(TableIndex.StateMachineMethod))
this.Children.Add(new StateMachineMethodTableTreeNode(this.module, this.provider, isEmbedded));
if (ShowTable(TableIndex.CustomDebugInformation))
this.Children.Add(new CustomDebugInformationTableTreeNode(this.module, this.provider, isEmbedded));
bool ShowTable(TableIndex table) => !DisplaySettingsPanel.CurrentDisplaySettings.HideEmptyMetadataTables || module.Metadata.GetTableRowCount(table) > 0;
}
public MetadataTableTreeNode FindNodeByHandleKind(HandleKind kind)

106
ILSpy/Metadata/MetadataTreeNode.cs

@ -21,6 +21,7 @@ using System.Collections.Generic; @@ -21,6 +21,7 @@ using System.Collections.Generic;
using System.Globalization;
using System.Linq;
using System.Reflection.Metadata;
using System.Reflection.Metadata.Ecma335;
using System.Reflection.PortableExecutable;
using System.Text;
using System.Threading.Tasks;
@ -28,6 +29,7 @@ using System.Windows; @@ -28,6 +29,7 @@ using System.Windows;
using System.Windows.Data;
using ICSharpCode.Decompiler;
using ICSharpCode.Decompiler.Metadata;
using ICSharpCode.ILSpy.Options;
using ICSharpCode.ILSpy.TreeNodes;
using ICSharpCode.ILSpy.ViewModels;
@ -68,40 +70,76 @@ namespace ICSharpCode.ILSpy.Metadata @@ -68,40 +70,76 @@ namespace ICSharpCode.ILSpy.Metadata
this.Children.Add(new CoffHeaderTreeNode(module));
this.Children.Add(new OptionalHeaderTreeNode(module));
this.Children.Add(new DataDirectoriesTreeNode(module));
this.Children.Add(new ModuleTableTreeNode(module));
this.Children.Add(new TypeRefTableTreeNode(module));
this.Children.Add(new TypeDefTableTreeNode(module));
this.Children.Add(new FieldTableTreeNode(module));
this.Children.Add(new MethodTableTreeNode(module));
this.Children.Add(new ParamTableTreeNode(module));
this.Children.Add(new InterfaceImplTableTreeNode(module));
this.Children.Add(new MemberRefTableTreeNode(module));
this.Children.Add(new ConstantTableTreeNode(module));
this.Children.Add(new CustomAttributeTableTreeNode(module));
this.Children.Add(new FieldMarshalTableTreeNode(module));
this.Children.Add(new DeclSecurityTableTreeNode(module));
this.Children.Add(new ClassLayoutTableTreeNode(module));
this.Children.Add(new FieldLayoutTableTreeNode(module));
this.Children.Add(new StandAloneSigTableTreeNode(module));
this.Children.Add(new EventMapTableTreeNode(module));
this.Children.Add(new EventTableTreeNode(module));
this.Children.Add(new PropertyMapTableTreeNode(module));
this.Children.Add(new PropertyTableTreeNode(module));
this.Children.Add(new MethodSemanticsTableTreeNode(module));
this.Children.Add(new MethodImplTableTreeNode(module));
this.Children.Add(new ModuleRefTableTreeNode(module));
this.Children.Add(new TypeSpecTableTreeNode(module));
this.Children.Add(new ImplMapTableTreeNode(module)); ;
this.Children.Add(new FieldRVATableTreeNode(module));
this.Children.Add(new AssemblyTableTreeNode(module));
this.Children.Add(new AssemblyRefTableTreeNode(module));
this.Children.Add(new FileTableTreeNode(module));
this.Children.Add(new ExportedTypeTableTreeNode(module));
this.Children.Add(new ManifestResourceTableTreeNode(module));
this.Children.Add(new NestedClassTableTreeNode(module));
this.Children.Add(new GenericParamTableTreeNode(module));
this.Children.Add(new MethodSpecTableTreeNode(module));
this.Children.Add(new GenericParamConstraintTableTreeNode(module));
if (ShowTable(TableIndex.Module))
this.Children.Add(new ModuleTableTreeNode(module));
if (ShowTable(TableIndex.TypeRef))
this.Children.Add(new TypeRefTableTreeNode(module));
if (ShowTable(TableIndex.TypeDef))
this.Children.Add(new TypeDefTableTreeNode(module));
if (ShowTable(TableIndex.Field))
this.Children.Add(new FieldTableTreeNode(module));
if (ShowTable(TableIndex.MethodDef))
this.Children.Add(new MethodTableTreeNode(module));
if (ShowTable(TableIndex.Param))
this.Children.Add(new ParamTableTreeNode(module));
if (ShowTable(TableIndex.InterfaceImpl))
this.Children.Add(new InterfaceImplTableTreeNode(module));
if (ShowTable(TableIndex.MemberRef))
this.Children.Add(new MemberRefTableTreeNode(module));
if (ShowTable(TableIndex.Constant))
this.Children.Add(new ConstantTableTreeNode(module));
if (ShowTable(TableIndex.CustomAttribute))
this.Children.Add(new CustomAttributeTableTreeNode(module));
if (ShowTable(TableIndex.FieldMarshal))
this.Children.Add(new FieldMarshalTableTreeNode(module));
if (ShowTable(TableIndex.DeclSecurity))
this.Children.Add(new DeclSecurityTableTreeNode(module));
if (ShowTable(TableIndex.ClassLayout))
this.Children.Add(new ClassLayoutTableTreeNode(module));
if (ShowTable(TableIndex.FieldLayout))
this.Children.Add(new FieldLayoutTableTreeNode(module));
if (ShowTable(TableIndex.StandAloneSig))
this.Children.Add(new StandAloneSigTableTreeNode(module));
if (ShowTable(TableIndex.EventMap))
this.Children.Add(new EventMapTableTreeNode(module));
if (ShowTable(TableIndex.Event))
this.Children.Add(new EventTableTreeNode(module));
if (ShowTable(TableIndex.PropertyMap))
this.Children.Add(new PropertyMapTableTreeNode(module));
if (ShowTable(TableIndex.Property))
this.Children.Add(new PropertyTableTreeNode(module));
if (ShowTable(TableIndex.MethodSemantics))
this.Children.Add(new MethodSemanticsTableTreeNode(module));
if (ShowTable(TableIndex.MethodImpl))
this.Children.Add(new MethodImplTableTreeNode(module));
if (ShowTable(TableIndex.ModuleRef))
this.Children.Add(new ModuleRefTableTreeNode(module));
if (ShowTable(TableIndex.TypeSpec))
this.Children.Add(new TypeSpecTableTreeNode(module));
if (ShowTable(TableIndex.ImplMap))
this.Children.Add(new ImplMapTableTreeNode(module));
if (ShowTable(TableIndex.FieldRva))
this.Children.Add(new FieldRVATableTreeNode(module));
if (ShowTable(TableIndex.Assembly))
this.Children.Add(new AssemblyTableTreeNode(module));
if (ShowTable(TableIndex.AssemblyRef))
this.Children.Add(new AssemblyRefTableTreeNode(module));
if (ShowTable(TableIndex.File))
this.Children.Add(new FileTableTreeNode(module));
if (ShowTable(TableIndex.ExportedType))
this.Children.Add(new ExportedTypeTableTreeNode(module));
if (ShowTable(TableIndex.ManifestResource))
this.Children.Add(new ManifestResourceTableTreeNode(module));
if (ShowTable(TableIndex.NestedClass))
this.Children.Add(new NestedClassTableTreeNode(module));
if (ShowTable(TableIndex.GenericParam))
this.Children.Add(new GenericParamTableTreeNode(module));
if (ShowTable(TableIndex.MethodSpec))
this.Children.Add(new MethodSpecTableTreeNode(module));
if (ShowTable(TableIndex.GenericParamConstraint))
this.Children.Add(new GenericParamConstraintTableTreeNode(module));
bool ShowTable(TableIndex table) => !DisplaySettingsPanel.CurrentDisplaySettings.HideEmptyMetadataTables || module.Metadata.GetTableRowCount(table) > 0;
}
public MetadataTableTreeNode FindNodeByHandleKind(HandleKind kind)

13
ILSpy/Options/DisplaySettings.cs

@ -234,6 +234,18 @@ namespace ICSharpCode.ILSpy.Options @@ -234,6 +234,18 @@ namespace ICSharpCode.ILSpy.Options
}
}
bool hideEmptyMetadataTables = true;
public bool HideEmptyMetadataTables {
get { return hideEmptyMetadataTables; }
set {
if (hideEmptyMetadataTables != value) {
hideEmptyMetadataTables = value;
OnPropertyChanged();
}
}
}
public void CopyValues(DisplaySettings s)
{
this.SelectedFont = s.selectedFont;
@ -251,6 +263,7 @@ namespace ICSharpCode.ILSpy.Options @@ -251,6 +263,7 @@ namespace ICSharpCode.ILSpy.Options
this.IndentationTabSize = s.indentationTabSize;
this.IndentationSize = s.indentationSize;
this.HighlightMatchingBraces = s.highlightMatchingBraces;
this.HideEmptyMetadataTables = s.HideEmptyMetadataTables;
}
}
}

1
ILSpy/Options/DisplaySettingsPanel.xaml

@ -77,6 +77,7 @@ @@ -77,6 +77,7 @@
<CheckBox IsChecked="{Binding ShowLineNumbers}" Content="{x:Static properties:Resources.ShowLineNumbers}"></CheckBox>
<CheckBox IsChecked="{Binding ShowMetadataTokens}" Content="{x:Static properties:Resources.ShowMetadataTokens}"></CheckBox>
<CheckBox IsChecked="{Binding ShowMetadataTokensInBase10}" Content="{x:Static properties:Resources.ShowMetadataTokensInBase10}"></CheckBox>
<CheckBox IsChecked="{Binding HideEmptyMetadataTables}" Content="{x:Static properties:Resources.HideEmptyMetadataTables}"></CheckBox>
<CheckBox IsChecked="{Binding ShowDebugInfo}" Content="{x:Static properties:Resources.ShowInfoFromDebugSymbolsAvailable}"></CheckBox>
<CheckBox IsChecked="{Binding EnableWordWrap}" Content="{x:Static properties:Resources.EnableWordWrap}"></CheckBox>
<CheckBox IsChecked="{Binding FoldBraces}" Content="{x:Static properties:Resources.EnableFoldingBlocksBraces}"></CheckBox>

2
ILSpy/Options/DisplaySettingsPanel.xaml.cs

@ -115,6 +115,7 @@ namespace ICSharpCode.ILSpy.Options @@ -115,6 +115,7 @@ namespace ICSharpCode.ILSpy.Options
s.IndentationSize = (int?)e.Attribute("IndentationSize") ?? 4;
s.IndentationTabSize = (int?)e.Attribute("IndentationTabSize") ?? 4;
s.HighlightMatchingBraces = (bool?)e.Attribute("HighlightMatchingBraces") ?? true;
s.HideEmptyMetadataTables = (bool?)e.Attribute("HideEmptyMetadataTables") ?? true;
return s;
}
@ -139,6 +140,7 @@ namespace ICSharpCode.ILSpy.Options @@ -139,6 +140,7 @@ namespace ICSharpCode.ILSpy.Options
section.SetAttributeValue("IndentationSize", s.IndentationSize);
section.SetAttributeValue("IndentationTabSize", s.IndentationTabSize);
section.SetAttributeValue("HighlightMatchingBraces", s.HighlightMatchingBraces);
section.SetAttributeValue("HideEmptyMetadataTables", s.HideEmptyMetadataTables);
XElement existingElement = root.Element("DisplaySettings");
if (existingElement != null)

9
ILSpy/Properties/Resources.Designer.cs generated

@ -1305,6 +1305,15 @@ namespace ICSharpCode.ILSpy.Properties { @@ -1305,6 +1305,15 @@ namespace ICSharpCode.ILSpy.Properties {
}
}
/// <summary>
/// Looks up a localized string similar to Hide empty metadata tables from tree view.
/// </summary>
public static string HideEmptyMetadataTables {
get {
return ResourceManager.GetString("HideEmptyMetadataTables", resourceCulture);
}
}
/// <summary>
/// Looks up a localized string similar to Highlight matching braces.
/// </summary>

3
ILSpy/Properties/Resources.resx

@ -829,4 +829,7 @@ Are you sure you want to continue?</value> @@ -829,4 +829,7 @@ Are you sure you want to continue?</value>
<data name="DecompilerSettings.IntroduceStaticLocalFunctions" xml:space="preserve">
<value>Introduce static local functions</value>
</data>
<data name="HideEmptyMetadataTables" xml:space="preserve">
<value>Hide empty metadata tables from tree view</value>
</data>
</root>
Loading…
Cancel
Save