Browse Source

Link metadata tokens in decompilation output to metadata tables.

pull/1716/head
Siegfried Pammer 5 years ago
parent
commit
deaedd0914
  1. 12
      ICSharpCode.Decompiler/Disassembler/MethodBodyDisassembler.cs
  2. 24
      ICSharpCode.Decompiler/Disassembler/ReflectionDisassembler.cs
  3. 2
      ICSharpCode.Decompiler/Output/ITextOutput.cs
  4. 6
      ICSharpCode.Decompiler/Output/PlainTextOutput.cs
  5. 5
      ILSpy/Commands/DecompileInNewViewCommand.cs
  6. 17
      ILSpy/Commands/IProtocolHandler.cs
  7. 3
      ILSpy/ILSpy.csproj
  8. 47
      ILSpy/MainWindow.xaml.cs
  9. 10
      ILSpy/Metadata/CorTables/AssemblyRefTableTreeNode.cs
  10. 16
      ILSpy/Metadata/CorTables/AssemblyTableTreeNode.cs
  11. 15
      ILSpy/Metadata/CorTables/ClassLayoutTableTreeNode.cs
  12. 10
      ILSpy/Metadata/CorTables/ConstantTableTreeNode.cs
  13. 14
      ILSpy/Metadata/CorTables/CustomAttributeTableTreeNode.cs
  14. 14
      ILSpy/Metadata/CorTables/DeclSecurityTableTreeNode.cs
  15. 15
      ILSpy/Metadata/CorTables/EventMapTableTreeNode.cs
  16. 17
      ILSpy/Metadata/CorTables/EventTableTreeNode.cs
  17. 17
      ILSpy/Metadata/CorTables/ExportedTypeTableTreeNode.cs
  18. 15
      ILSpy/Metadata/CorTables/FieldLayoutTableTreeNode.cs
  19. 15
      ILSpy/Metadata/CorTables/FieldMarshalTableTreeNode.cs
  20. 15
      ILSpy/Metadata/CorTables/FieldRVATableTreeNode.cs
  21. 13
      ILSpy/Metadata/CorTables/FieldTableTreeNode.cs
  22. 16
      ILSpy/Metadata/CorTables/FileTableTreeNode.cs
  23. 20
      ILSpy/Metadata/CorTables/GenericParamConstraintTableTreeNode.cs
  24. 17
      ILSpy/Metadata/CorTables/GenericParamTableTreeNode.cs
  25. 16
      ILSpy/Metadata/CorTables/ImplMapTableTreeNode.cs
  26. 15
      ILSpy/Metadata/CorTables/InterfaceImplTableTreeNode.cs
  27. 14
      ILSpy/Metadata/CorTables/ManifestResourceTableTreeNode.cs
  28. 17
      ILSpy/Metadata/CorTables/MemberRefTableTreeNode.cs
  29. 18
      ILSpy/Metadata/CorTables/MethodImplTableTreeNode.cs
  30. 19
      ILSpy/Metadata/CorTables/MethodSemanticsTableTreeNode.cs
  31. 18
      ILSpy/Metadata/CorTables/MethodSpecTableTreeNode.cs
  32. 18
      ILSpy/Metadata/CorTables/MethodTableTreeNode.cs
  33. 18
      ILSpy/Metadata/CorTables/ModuleRefTableTreeNode.cs
  34. 18
      ILSpy/Metadata/CorTables/ModuleTableTreeNode.cs
  35. 16
      ILSpy/Metadata/CorTables/NestedClassTableTreeNode.cs
  36. 19
      ILSpy/Metadata/CorTables/ParamTableTreeNode.cs
  37. 15
      ILSpy/Metadata/CorTables/PropertyMapTableTreeNode.cs
  38. 17
      ILSpy/Metadata/CorTables/PropertyTableTreeNode.cs
  39. 16
      ILSpy/Metadata/CorTables/StandAloneSigTableTreeNode.cs
  40. 16
      ILSpy/Metadata/CorTables/TypeDefTableTreeNode.cs
  41. 18
      ILSpy/Metadata/CorTables/TypeRefTableTreeNode.cs
  42. 19
      ILSpy/Metadata/CorTables/TypeSpecTableTreeNode.cs
  43. 32
      ILSpy/Metadata/MetadataProtocolHandler.cs
  44. 38
      ILSpy/Metadata/MetadataTableTreeNode.cs
  45. 6
      ILSpy/Metadata/MetadataTreeNode.cs
  46. 4
      ILSpy/TextView/AvalonEditTextOutput.cs

12
ICSharpCode.Decompiler/Disassembler/MethodBodyDisassembler.cs

@ -489,16 +489,8 @@ namespace ICSharpCode.Decompiler.Disassembler @@ -489,16 +489,8 @@ namespace ICSharpCode.Decompiler.Disassembler
private void WriteMetadataToken(Handle? handle, int metadataToken, bool spaceBefore)
{
if (ShowMetadataTokens || handle == null) {
if (spaceBefore) {
output.Write(' ');
}
if (ShowMetadataTokensInBase10) {
output.Write("/* {0} */", metadataToken);
} else {
output.Write("/* {0:X8} */", metadataToken);
}
}
ReflectionDisassembler.WriteMetadataToken(output, module, handle, metadataToken,
spaceAfter: false, spaceBefore, ShowMetadataTokens, ShowMetadataTokensInBase10);
}
}
}

24
ICSharpCode.Decompiler/Disassembler/ReflectionDisassembler.cs

@ -159,7 +159,8 @@ namespace ICSharpCode.Decompiler.Disassembler @@ -159,7 +159,8 @@ namespace ICSharpCode.Decompiler.Disassembler
{
var metadata = module.Metadata;
WriteMetadataToken(handle, spaceAfter:true);
WriteMetadataToken(output, module, handle, MetadataTokens.GetToken(handle),
spaceAfter: true, spaceBefore: false, ShowMetadataTokens, ShowMetadataTokensInBase10);
var methodDefinition = metadata.GetMethodDefinition(handle);
// .method public hidebysig specialname
// instance default class [mscorlib]System.IO.TextWriter get_BaseWriter () cil managed
@ -285,10 +286,19 @@ namespace ICSharpCode.Decompiler.Disassembler @@ -285,10 +286,19 @@ namespace ICSharpCode.Decompiler.Disassembler
output.Unindent();
}
void WriteMetadataToken(Handle handle, bool spaceAfter)
internal static void WriteMetadataToken(ITextOutput output, PEFile module, Handle? handle, int metadataToken, bool spaceAfter, bool spaceBefore, bool showMetadataTokens, bool base10)
{
if (ShowMetadataTokens) {
output.Write("/* {0:X8} */", MetadataTokens.GetToken(handle));
if (showMetadataTokens || handle == null) {
if (spaceBefore) {
output.Write(' ');
}
output.Write("/* ");
if (base10) {
output.WriteReference(module, handle.GetValueOrDefault(), metadataToken.ToString(), "metadata");
} else {
output.WriteReference(module, handle.GetValueOrDefault(), metadataToken.ToString("X8"), "metadata");
}
output.Write(" */");
if (spaceAfter) {
output.Write(' ');
}
@ -1205,7 +1215,7 @@ namespace ICSharpCode.Decompiler.Disassembler @@ -1205,7 +1215,7 @@ namespace ICSharpCode.Decompiler.Disassembler
{
var metadata = module.Metadata;
var propertyDefinition = metadata.GetPropertyDefinition(property);
output.WriteReference(module, property, ".property", true);
output.WriteReference(module, property, ".property", isDefinition: true);
output.Write(" ");
WriteFlags(propertyDefinition.Attributes, propertyAttributes);
var accessors = propertyDefinition.GetAccessors();
@ -1270,7 +1280,7 @@ namespace ICSharpCode.Decompiler.Disassembler @@ -1270,7 +1280,7 @@ namespace ICSharpCode.Decompiler.Disassembler
} else {
declaringType = module.Metadata.GetMethodDefinition(accessors.Raiser).GetDeclaringType();
}
output.WriteReference(module, handle, ".event", true);
output.WriteReference(module, handle, ".event", isDefinition: true);
output.Write(" ");
WriteFlags(eventDefinition.Attributes, eventAttributes);
var provider = new DisassemblerSignatureTypeProvider(module, output);
@ -1342,7 +1352,7 @@ namespace ICSharpCode.Decompiler.Disassembler @@ -1342,7 +1352,7 @@ namespace ICSharpCode.Decompiler.Disassembler
public void DisassembleType(PEFile module, TypeDefinitionHandle type)
{
var typeDefinition = module.Metadata.GetTypeDefinition(type);
output.WriteReference(module, type, ".class", true);
output.WriteReference(module, type, ".class", isDefinition: true);
output.Write(" ");
if ((typeDefinition.Attributes & TypeAttributes.ClassSemanticsMask) == TypeAttributes.Interface)
output.Write("interface ");

2
ICSharpCode.Decompiler/Output/ITextOutput.cs

@ -33,7 +33,7 @@ namespace ICSharpCode.Decompiler @@ -33,7 +33,7 @@ namespace ICSharpCode.Decompiler
void Write(string text);
void WriteLine();
void WriteReference(OpCodeInfo opCode, bool omitSuffix = false);
void WriteReference(PEFile module, EntityHandle handle, string text, bool isDefinition = false);
void WriteReference(PEFile module, Handle handle, string text, string protocol = "decompile", bool isDefinition = false);
void WriteReference(IType type, string text, bool isDefinition = false);
void WriteReference(IMember member, string text, bool isDefinition = false);
void WriteLocalReference(string text, object reference, bool isDefinition = false);

6
ICSharpCode.Decompiler/Output/PlainTextOutput.cs

@ -116,7 +116,7 @@ namespace ICSharpCode.Decompiler @@ -116,7 +116,7 @@ namespace ICSharpCode.Decompiler
}
}
public void WriteReference(PEFile module, EntityHandle handle, string text, bool isDefinition = false)
public void WriteReference(PEFile module, Handle handle, string text, string protocol = "decompile", bool isDefinition = false)
{
Write(text);
}
@ -217,9 +217,9 @@ namespace ICSharpCode.Decompiler @@ -217,9 +217,9 @@ namespace ICSharpCode.Decompiler
actions.Add(target => target.WriteReference(opCode));
}
public void WriteReference(PEFile module, EntityHandle handle, string text, bool isDefinition = false)
public void WriteReference(PEFile module, Handle handle, string text, string protocol = "decompile", bool isDefinition = false)
{
actions.Add(target => target.WriteReference(module, handle, text, isDefinition));
actions.Add(target => target.WriteReference(module, handle, text, protocol, isDefinition));
}
public void WriteReference(IType type, string text, bool isDefinition = false)

5
ILSpy/Commands/DecompileInNewViewCommand.cs

@ -69,10 +69,7 @@ namespace ICSharpCode.ILSpy.Commands @@ -69,10 +69,7 @@ namespace ICSharpCode.ILSpy.Commands
if (nodes.Length == 0)
return;
var title = string.Join(", ", nodes.Select(x => x.Text.ToString()));
DockWorkspace.Instance.TabPages.Add(new ViewModels.TabPageModel() { Language = MainWindow.Instance.CurrentLanguage, LanguageVersion = MainWindow.Instance.CurrentLanguageVersion });
DockWorkspace.Instance.ActiveTabPage = DockWorkspace.Instance.TabPages.Last();
MainWindow.Instance.SelectNodes(nodes);
MainWindow.Instance.SelectNodes(nodes, inNewTabPage: true);
MainWindow.Instance.Dispatcher.BeginInvoke(DispatcherPriority.Background, (Action)MainWindow.Instance.RefreshDecompiledView);
}
}

17
ILSpy/Commands/IProtocolHandler.cs

@ -0,0 +1,17 @@ @@ -0,0 +1,17 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Reflection.Metadata;
using System.Text;
using System.Threading.Tasks;
using ICSharpCode.Decompiler.Metadata;
using ICSharpCode.ILSpy.TreeNodes;
using ICSharpCode.TreeView;
namespace ICSharpCode.ILSpy
{
public interface IProtocolHandler
{
ILSpyTreeNode Resolve(string protocol, PEFile module, Handle handle, out bool newTabPage);
}
}

3
ILSpy/ILSpy.csproj

@ -114,6 +114,7 @@ @@ -114,6 +114,7 @@
<Compile Include="Commands\ExitCommand.cs" />
<Compile Include="Commands\CommandWrapper.cs" />
<Compile Include="Commands\ILSpyCommands.cs" />
<Compile Include="Commands\IProtocolHandler.cs" />
<Compile Include="Commands\ManageAssemblyListsCommand.cs" />
<Compile Include="Commands\Pdb2XmlCommand.cs" />
<Compile Include="Commands\RemoveAssembliesWithLoadErrors.cs" />
@ -171,6 +172,8 @@ @@ -171,6 +172,8 @@
<Compile Include="Metadata\FlagsFilterControl.xaml.cs" />
<Compile Include="Metadata\FlagsTooltip.xaml.cs" />
<Compile Include="Metadata\HexFilterControl.xaml.cs" />
<Compile Include="Metadata\MetadataProtocolHandler.cs" />
<Compile Include="Metadata\MetadataTableTreeNode.cs" />
<Compile Include="ViewModels\ManageAssemblyListsViewModel.cs" />
<Compile Include="ViewModels\ViewModelBase.cs" />
<Compile Include="Views\CreateListDialog.xaml.cs">

47
ILSpy/MainWindow.xaml.cs

@ -24,6 +24,7 @@ using System.Diagnostics; @@ -24,6 +24,7 @@ using System.Diagnostics;
using System.IO;
using System.Linq;
using System.Reflection.Metadata;
using System.Reflection.Metadata.Ecma335;
using System.Runtime.CompilerServices;
using System.Text;
using System.Threading.Tasks;
@ -611,7 +612,7 @@ namespace ICSharpCode.ILSpy @@ -611,7 +612,7 @@ namespace ICSharpCode.ILSpy
assemblyListTreeNode = new AssemblyListTreeNode(assemblyList);
assemblyListTreeNode.FilterSettings = sessionSettings.FilterSettings.Clone();
assemblyListTreeNode.Select = SelectNode;
assemblyListTreeNode.Select = x => SelectNode(x, inNewTabPage: false);
treeView.Root = assemblyListTreeNode;
if (assemblyList.ListName == AssemblyListManager.DefaultListName)
@ -684,10 +685,19 @@ namespace ICSharpCode.ILSpy @@ -684,10 +685,19 @@ namespace ICSharpCode.ILSpy
#region Node Selection
public void SelectNode(SharpTreeNode obj)
public void SelectNode(SharpTreeNode obj, bool inNewTabPage = false)
{
if (obj != null) {
if (!obj.AncestorsAndSelf().Any(node => node.IsHidden)) {
if (inNewTabPage) {
DockWorkspace.Instance.TabPages.Add(
new TabPageModel() {
Language = CurrentLanguage,
LanguageVersion = CurrentLanguageVersion
});
DockWorkspace.Instance.ActiveTabPage = DockWorkspace.Instance.TabPages.Last();
}
// Set both the selection and focus to ensure that keyboard navigation works as expected.
treeView.FocusNode(obj);
treeView.SelectedItem = obj;
@ -700,9 +710,18 @@ namespace ICSharpCode.ILSpy @@ -700,9 +710,18 @@ namespace ICSharpCode.ILSpy
}
}
public void SelectNodes(IEnumerable<SharpTreeNode> nodes)
public void SelectNodes(IEnumerable<SharpTreeNode> nodes, bool inNewTabPage = false)
{
if (nodes.Any() && nodes.All(n => !n.AncestorsAndSelf().Any(a => a.IsHidden))) {
if (inNewTabPage) {
DockWorkspace.Instance.TabPages.Add(
new TabPageModel() {
Language = CurrentLanguage,
LanguageVersion = CurrentLanguageVersion
});
DockWorkspace.Instance.ActiveTabPage = DockWorkspace.Instance.TabPages.Last();
}
treeView.FocusNode(nodes.First());
treeView.SetSelectedNodes(nodes);
}
@ -796,11 +815,25 @@ namespace ICSharpCode.ILSpy @@ -796,11 +815,25 @@ namespace ICSharpCode.ILSpy
case Decompiler.Disassembler.OpCodeInfo opCode:
OpenLink(opCode.Link);
break;
case ValueTuple<PEFile, System.Reflection.Metadata.EntityHandle> unresolvedEntity:
var typeSystem = new DecompilerTypeSystem(unresolvedEntity.Item1, unresolvedEntity.Item1.GetAssemblyResolver(),
case ValueTuple<string, PEFile, Handle> unresolvedEntity:
string protocol = unresolvedEntity.Item1 ?? "decompile";
if (protocol != "decompile") {
var protocolHandlers = App.ExportProvider.GetExports<IProtocolHandler>();
foreach (var handler in protocolHandlers) {
var node = handler.Value.Resolve(protocol, unresolvedEntity.Item2, unresolvedEntity.Item3, out bool newTabPage);
if (node != null) {
SelectNode(node, newTabPage);
return decompilationTask;
}
}
}
if (MetadataTokenHelpers.TryAsEntityHandle(MetadataTokens.GetToken(unresolvedEntity.Item3)) != null) {
var typeSystem = new DecompilerTypeSystem(unresolvedEntity.Item2, unresolvedEntity.Item2.GetAssemblyResolver(),
TypeSystemOptions.Default | TypeSystemOptions.Uncached);
reference = typeSystem.MainModule.ResolveEntity(unresolvedEntity.Item2);
goto default;
reference = typeSystem.MainModule.ResolveEntity((EntityHandle)unresolvedEntity.Item3);
goto default;
}
break;
default:
ILSpyTreeNode treeNode = FindTreeNode(reference);
if (treeNode != null)

10
ILSpy/Metadata/CorTables/AssemblyRefTableTreeNode.cs

@ -21,21 +21,17 @@ using System.Collections.Generic; @@ -21,21 +21,17 @@ using System.Collections.Generic;
using System.Reflection;
using System.Reflection.Metadata;
using System.Reflection.Metadata.Ecma335;
using System.Windows.Controls;
using ICSharpCode.Decompiler;
using ICSharpCode.Decompiler.Metadata;
using ICSharpCode.ILSpy.TextView;
using ICSharpCode.ILSpy.TreeNodes;
namespace ICSharpCode.ILSpy.Metadata
{
internal class AssemblyRefTableTreeNode : ILSpyTreeNode
internal class AssemblyRefTableTreeNode : MetadataTableTreeNode
{
private PEFile module;
public AssemblyRefTableTreeNode(PEFile module)
: base(HandleKind.AssemblyReference, module)
{
this.module = module;
}
public override object Text => $"23 AssemblyRef ({module.Metadata.GetTableRowCount(TableIndex.AssemblyRef)})";

16
ILSpy/Metadata/CorTables/AssemblyTableTreeNode.cs

@ -18,30 +18,20 @@ @@ -18,30 +18,20 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Reflection;
using System.Reflection.Metadata;
using System.Reflection.Metadata.Ecma335;
using System.Text;
using System.Windows.Controls;
using System.Windows.Data;
using ICSharpCode.Decompiler;
using ICSharpCode.Decompiler.CSharp.Syntax;
using ICSharpCode.Decompiler.Metadata;
using ICSharpCode.ILSpy.Controls;
using ICSharpCode.ILSpy.TextView;
using ICSharpCode.ILSpy.TreeNodes;
using ICSharpCode.TreeView;
namespace ICSharpCode.ILSpy.Metadata
{
internal class AssemblyTableTreeNode : ILSpyTreeNode
internal class AssemblyTableTreeNode : MetadataTableTreeNode
{
private PEFile module;
public AssemblyTableTreeNode(PEFile module)
: base(HandleKind.AssemblyDefinition, module)
{
this.module = module;
}
public override object Text => $"20 Assembly ({module.Metadata.GetTableRowCount(TableIndex.Assembly)})";

15
ILSpy/Metadata/CorTables/ClassLayoutTableTreeNode.cs

@ -16,31 +16,22 @@ @@ -16,31 +16,22 @@
// OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
// DEALINGS IN THE SOFTWARE.
using System;
using System.Collections.Generic;
using System.Linq;
using System.Reflection.Metadata;
using System.Reflection.Metadata.Ecma335;
using System.Runtime.InteropServices;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Controls;
using ICSharpCode.Decompiler;
using ICSharpCode.Decompiler.Disassembler;
using ICSharpCode.Decompiler.IL;
using ICSharpCode.Decompiler.Metadata;
using ICSharpCode.ILSpy.TextView;
using ICSharpCode.ILSpy.TreeNodes;
namespace ICSharpCode.ILSpy.Metadata
{
class ClassLayoutTableTreeNode : ILSpyTreeNode
class ClassLayoutTableTreeNode : MetadataTableTreeNode
{
private PEFile module;
public ClassLayoutTableTreeNode(PEFile module)
: base((HandleKind)0x0F, module)
{
this.module = module;
}
public override object Text => $"0F ClassLayout ({module.Metadata.GetTableRowCount(TableIndex.ClassLayout)})";

10
ILSpy/Metadata/CorTables/ConstantTableTreeNode.cs

@ -19,24 +19,20 @@ @@ -19,24 +19,20 @@
using System.Collections.Generic;
using System.Reflection.Metadata;
using System.Reflection.Metadata.Ecma335;
using System.Windows.Controls;
using ICSharpCode.Decompiler;
using ICSharpCode.Decompiler.Disassembler;
using ICSharpCode.Decompiler.IL;
using ICSharpCode.Decompiler.Metadata;
using ICSharpCode.ILSpy.TextView;
using ICSharpCode.ILSpy.TreeNodes;
using ICSharpCode.ILSpy.ViewModels;
namespace ICSharpCode.ILSpy.Metadata
{
internal class ConstantTableTreeNode : ILSpyTreeNode
internal class ConstantTableTreeNode : MetadataTableTreeNode
{
private PEFile module;
public ConstantTableTreeNode(PEFile module)
: base((HandleKind)0x0B, module)
{
this.module = module;
}
public override object Text => $"0B Constant ({module.Metadata.GetTableRowCount(TableIndex.Constant)})";

14
ILSpy/Metadata/CorTables/CustomAttributeTableTreeNode.cs

@ -16,30 +16,22 @@ @@ -16,30 +16,22 @@
// OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
// DEALINGS IN THE SOFTWARE.
using System;
using System.Collections.Generic;
using System.Linq;
using System.Reflection.Metadata;
using System.Reflection.Metadata.Ecma335;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Controls;
using ICSharpCode.Decompiler;
using ICSharpCode.Decompiler.Disassembler;
using ICSharpCode.Decompiler.IL;
using ICSharpCode.Decompiler.Metadata;
using ICSharpCode.ILSpy.TextView;
using ICSharpCode.ILSpy.TreeNodes;
namespace ICSharpCode.ILSpy.Metadata
{
class CustomAttributeTableTreeNode : ILSpyTreeNode
class CustomAttributeTableTreeNode : MetadataTableTreeNode
{
private PEFile module;
public CustomAttributeTableTreeNode(PEFile module)
: base(HandleKind.CustomAttribute, module)
{
this.module = module;
}
public override object Text => $"0C CustomAttribute ({module.Metadata.GetTableRowCount(TableIndex.CustomAttribute)})";

14
ILSpy/Metadata/CorTables/DeclSecurityTableTreeNode.cs

@ -16,30 +16,22 @@ @@ -16,30 +16,22 @@
// OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
// DEALINGS IN THE SOFTWARE.
using System;
using System.Collections.Generic;
using System.Linq;
using System.Reflection.Metadata;
using System.Reflection.Metadata.Ecma335;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Controls;
using ICSharpCode.Decompiler;
using ICSharpCode.Decompiler.Disassembler;
using ICSharpCode.Decompiler.IL;
using ICSharpCode.Decompiler.Metadata;
using ICSharpCode.ILSpy.TextView;
using ICSharpCode.ILSpy.TreeNodes;
namespace ICSharpCode.ILSpy.Metadata
{
class DeclSecurityTableTreeNode : ILSpyTreeNode
class DeclSecurityTableTreeNode : MetadataTableTreeNode
{
private PEFile module;
public DeclSecurityTableTreeNode(PEFile module)
: base(HandleKind.DeclarativeSecurityAttribute, module)
{
this.module = module;
}
public override object Text => $"0E DeclSecurity ({module.Metadata.GetTableRowCount(TableIndex.DeclSecurity)})";

15
ILSpy/Metadata/CorTables/EventMapTableTreeNode.cs

@ -16,31 +16,22 @@ @@ -16,31 +16,22 @@
// OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
// DEALINGS IN THE SOFTWARE.
using System;
using System.Collections.Generic;
using System.Linq;
using System.Reflection.Metadata;
using System.Reflection.Metadata.Ecma335;
using System.Runtime.InteropServices;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Controls;
using ICSharpCode.Decompiler;
using ICSharpCode.Decompiler.Disassembler;
using ICSharpCode.Decompiler.IL;
using ICSharpCode.Decompiler.Metadata;
using ICSharpCode.ILSpy.TextView;
using ICSharpCode.ILSpy.TreeNodes;
namespace ICSharpCode.ILSpy.Metadata
{
class EventMapTableTreeNode : ILSpyTreeNode
class EventMapTableTreeNode : MetadataTableTreeNode
{
private PEFile module;
public EventMapTableTreeNode(PEFile module)
: base((HandleKind)0x12, module)
{
this.module = module;
}
public override object Text => $"12 EventMap ({module.Metadata.GetTableRowCount(TableIndex.EventMap)})";

17
ILSpy/Metadata/CorTables/EventTableTreeNode.cs

@ -16,32 +16,25 @@ @@ -16,32 +16,25 @@
// OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
// DEALINGS IN THE SOFTWARE.
using System;
using System.Collections.Generic;
using System.Linq;
using System.Reflection;
using System.Reflection.Metadata;
using System.Reflection.Metadata.Ecma335;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Controls;
using ICSharpCode.Decompiler;
using ICSharpCode.Decompiler.IL;
using ICSharpCode.Decompiler.Disassembler;
using ICSharpCode.Decompiler.IL;
using ICSharpCode.Decompiler.Metadata;
using ICSharpCode.Decompiler.TypeSystem;
using ICSharpCode.ILSpy.TextView;
using ICSharpCode.ILSpy.TreeNodes;
using System.Reflection;
namespace ICSharpCode.ILSpy.Metadata
{
internal class EventTableTreeNode : ILSpyTreeNode
internal class EventTableTreeNode : MetadataTableTreeNode
{
private PEFile module;
public EventTableTreeNode(PEFile module)
: base(HandleKind.EventDefinition, module)
{
this.module = module;
}
public override object Text => $"14 Event ({module.Metadata.GetTableRowCount(TableIndex.Event)})";

17
ILSpy/Metadata/CorTables/ExportedTypeTableTreeNode.cs

@ -16,32 +16,21 @@ @@ -16,32 +16,21 @@
// OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
// DEALINGS IN THE SOFTWARE.
using System;
using System.Collections.Generic;
using System.Linq;
using System.Reflection;
using System.Reflection.Metadata;
using System.Reflection.Metadata.Ecma335;
using System.Text;
using System.Windows.Controls;
using System.Windows.Data;
using ICSharpCode.Decompiler;
using ICSharpCode.Decompiler.CSharp.Syntax;
using ICSharpCode.Decompiler.Metadata;
using ICSharpCode.ILSpy.Controls;
using ICSharpCode.ILSpy.TextView;
using ICSharpCode.ILSpy.TreeNodes;
using ICSharpCode.TreeView;
namespace ICSharpCode.ILSpy.Metadata
{
internal class ExportedTypeTableTreeNode : ILSpyTreeNode
internal class ExportedTypeTableTreeNode : MetadataTableTreeNode
{
private PEFile module;
public ExportedTypeTableTreeNode(PEFile module)
: base(HandleKind.ExportedType, module)
{
this.module = module;
}
public override object Text => $"27 ExportedType ({module.Metadata.GetTableRowCount(TableIndex.ExportedType)})";

15
ILSpy/Metadata/CorTables/FieldLayoutTableTreeNode.cs

@ -16,31 +16,22 @@ @@ -16,31 +16,22 @@
// OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
// DEALINGS IN THE SOFTWARE.
using System;
using System.Collections.Generic;
using System.Linq;
using System.Reflection.Metadata;
using System.Reflection.Metadata.Ecma335;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Controls;
using ICSharpCode.Decompiler;
using ICSharpCode.Decompiler.Disassembler;
using ICSharpCode.Decompiler.IL;
using ICSharpCode.Decompiler.Metadata;
using ICSharpCode.Decompiler.TypeSystem;
using ICSharpCode.ILSpy.TextView;
using ICSharpCode.ILSpy.TreeNodes;
namespace ICSharpCode.ILSpy.Metadata
{
internal class FieldLayoutTableTreeNode : ILSpyTreeNode
internal class FieldLayoutTableTreeNode : MetadataTableTreeNode
{
private PEFile module;
public FieldLayoutTableTreeNode(PEFile module)
: base((HandleKind)0x10, module)
{
this.module = module;
}
public override object Text => $"10 FieldLayout ({module.Metadata.GetTableRowCount(TableIndex.FieldLayout)})";

15
ILSpy/Metadata/CorTables/FieldMarshalTableTreeNode.cs

@ -16,31 +16,22 @@ @@ -16,31 +16,22 @@
// OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
// DEALINGS IN THE SOFTWARE.
using System;
using System.Collections.Generic;
using System.Linq;
using System.Reflection.Metadata;
using System.Reflection.Metadata.Ecma335;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Controls;
using ICSharpCode.Decompiler;
using ICSharpCode.Decompiler.Disassembler;
using ICSharpCode.Decompiler.IL;
using ICSharpCode.Decompiler.Metadata;
using ICSharpCode.Decompiler.TypeSystem;
using ICSharpCode.ILSpy.TextView;
using ICSharpCode.ILSpy.TreeNodes;
namespace ICSharpCode.ILSpy.Metadata
{
internal class FieldMarshalTableTreeNode : ILSpyTreeNode
internal class FieldMarshalTableTreeNode : MetadataTableTreeNode
{
private PEFile module;
public FieldMarshalTableTreeNode(PEFile module)
: base((HandleKind)0x0D, module)
{
this.module = module;
}
public override object Text => $"0D FieldMarshal ({module.Metadata.GetTableRowCount(TableIndex.FieldMarshal)})";

15
ILSpy/Metadata/CorTables/FieldRVATableTreeNode.cs

@ -16,31 +16,22 @@ @@ -16,31 +16,22 @@
// OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
// DEALINGS IN THE SOFTWARE.
using System;
using System.Collections.Generic;
using System.Linq;
using System.Reflection.Metadata;
using System.Reflection.Metadata.Ecma335;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Controls;
using ICSharpCode.Decompiler;
using ICSharpCode.Decompiler.Disassembler;
using ICSharpCode.Decompiler.IL;
using ICSharpCode.Decompiler.Metadata;
using ICSharpCode.Decompiler.TypeSystem;
using ICSharpCode.ILSpy.TextView;
using ICSharpCode.ILSpy.TreeNodes;
namespace ICSharpCode.ILSpy.Metadata
{
internal class FieldRVATableTreeNode : ILSpyTreeNode
internal class FieldRVATableTreeNode : MetadataTableTreeNode
{
private PEFile module;
public FieldRVATableTreeNode(PEFile module)
: base((HandleKind)0x1D, module)
{
this.module = module;
}
public override object Text => $"1D FieldRVA ({module.Metadata.GetTableRowCount(TableIndex.FieldRva)})";

13
ILSpy/Metadata/CorTables/FieldTableTreeNode.cs

@ -16,32 +16,25 @@ @@ -16,32 +16,25 @@
// OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
// DEALINGS IN THE SOFTWARE.
using System;
using System.Collections.Generic;
using System.Linq;
using System.Reflection;
using System.Reflection.Metadata;
using System.Reflection.Metadata.Ecma335;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Controls;
using ICSharpCode.Decompiler;
using ICSharpCode.Decompiler.Disassembler;
using ICSharpCode.Decompiler.IL;
using ICSharpCode.Decompiler.Metadata;
using ICSharpCode.Decompiler.TypeSystem;
using ICSharpCode.ILSpy.TextView;
using ICSharpCode.ILSpy.TreeNodes;
namespace ICSharpCode.ILSpy.Metadata
{
internal class FieldTableTreeNode : ILSpyTreeNode
internal class FieldTableTreeNode : MetadataTableTreeNode
{
private PEFile module;
public FieldTableTreeNode(PEFile module)
: base(HandleKind.FieldDefinition, module)
{
this.module = module;
}
public override object Text => $"04 Field ({module.Metadata.GetTableRowCount(TableIndex.Field)})";

16
ILSpy/Metadata/CorTables/FileTableTreeNode.cs

@ -16,30 +16,20 @@ @@ -16,30 +16,20 @@
// OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
// DEALINGS IN THE SOFTWARE.
using System;
using System.Collections.Generic;
using System.Linq;
using System.Reflection.Metadata;
using System.Reflection.Metadata.Ecma335;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Controls;
using ICSharpCode.Decompiler;
using ICSharpCode.Decompiler.Disassembler;
using ICSharpCode.Decompiler.IL;
using ICSharpCode.Decompiler.Metadata;
using ICSharpCode.ILSpy.TextView;
using ICSharpCode.ILSpy.TreeNodes;
namespace ICSharpCode.ILSpy.Metadata
{
class FileTableTreeNode : ILSpyTreeNode
class FileTableTreeNode : MetadataTableTreeNode
{
private PEFile module;
public FileTableTreeNode(PEFile module)
: base(HandleKind.AssemblyFile, module)
{
this.module = module;
}
public override object Text => $"26 File ({module.Metadata.GetTableRowCount(TableIndex.File)})";

20
ILSpy/Metadata/CorTables/GenericParamConstraintTableTreeNode.cs

@ -16,34 +16,22 @@ @@ -16,34 +16,22 @@
// OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
// DEALINGS IN THE SOFTWARE.
using System;
using System.Collections.Generic;
using System.Linq;
using System.Reflection;
using System.Reflection.Metadata;
using System.Reflection.Metadata.Ecma335;
using System.Text;
using System.Windows.Controls;
using System.Windows.Data;
using ICSharpCode.Decompiler;
using ICSharpCode.Decompiler.CSharp.Syntax;
using ICSharpCode.Decompiler.Disassembler;
using ICSharpCode.Decompiler.IL;
using ICSharpCode.Decompiler.Metadata;
using ICSharpCode.ILSpy.Controls;
using ICSharpCode.ILSpy.TextView;
using ICSharpCode.ILSpy.TreeNodes;
using ICSharpCode.TreeView;
namespace ICSharpCode.ILSpy.Metadata
{
internal class GenericParamConstraintTableTreeNode : ILSpyTreeNode
internal class GenericParamConstraintTableTreeNode : MetadataTableTreeNode
{
private PEFile module;
public GenericParamConstraintTableTreeNode(PEFile module)
: base(HandleKind.GenericParameterConstraint, module)
{
this.module = module;
}
public override object Text => $"2C GenericParamConstraint ({module.Metadata.GetTableRowCount(TableIndex.GenericParamConstraint)})";
@ -60,7 +48,7 @@ namespace ICSharpCode.ILSpy.Metadata @@ -60,7 +48,7 @@ namespace ICSharpCode.ILSpy.Metadata
var list = new List<GenericParamConstraintEntry>();
for (int row = 1; row <= module.Metadata.GetTableRowCount(TableIndex.GenericParamConstraint); row++) {
for (int row = 1; row <= metadata.GetTableRowCount(TableIndex.GenericParamConstraint); row++) {
list.Add(new GenericParamConstraintEntry(module, MetadataTokens.GenericParameterConstraintHandle(row)));
}
view.ItemsSource = list;

17
ILSpy/Metadata/CorTables/GenericParamTableTreeNode.cs

@ -16,34 +16,23 @@ @@ -16,34 +16,23 @@
// OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
// DEALINGS IN THE SOFTWARE.
using System;
using System.Collections.Generic;
using System.Linq;
using System.Reflection;
using System.Reflection.Metadata;
using System.Reflection.Metadata.Ecma335;
using System.Text;
using System.Windows.Controls;
using System.Windows.Data;
using ICSharpCode.Decompiler;
using ICSharpCode.Decompiler.CSharp.Syntax;
using ICSharpCode.Decompiler.Disassembler;
using ICSharpCode.Decompiler.IL;
using ICSharpCode.Decompiler.Metadata;
using ICSharpCode.ILSpy.Controls;
using ICSharpCode.ILSpy.TextView;
using ICSharpCode.ILSpy.TreeNodes;
using ICSharpCode.TreeView;
namespace ICSharpCode.ILSpy.Metadata
{
internal class GenericParamTableTreeNode : ILSpyTreeNode
internal class GenericParamTableTreeNode : MetadataTableTreeNode
{
private PEFile module;
public GenericParamTableTreeNode(PEFile module)
: base(HandleKind.GenericParameter, module)
{
this.module = module;
}
public override object Text => $"2A GenericParam ({module.Metadata.GetTableRowCount(TableIndex.GenericParam)})";

16
ILSpy/Metadata/CorTables/ImplMapTableTreeNode.cs

@ -16,32 +16,24 @@ @@ -16,32 +16,24 @@
// OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
// DEALINGS IN THE SOFTWARE.
using System;
using System.Collections.Generic;
using System.Linq;
using System.Reflection.Metadata;
using System.Reflection.Metadata.Ecma335;
using System.Runtime.InteropServices;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Controls;
using ICSharpCode.Decompiler;
using ICSharpCode.Decompiler.Disassembler;
using ICSharpCode.Decompiler.IL;
using ICSharpCode.Decompiler.Metadata;
using ICSharpCode.ILSpy.TextView;
using ICSharpCode.ILSpy.TreeNodes;
using Mono.Cecil;
namespace ICSharpCode.ILSpy.Metadata
{
class ImplMapTableTreeNode : ILSpyTreeNode
class ImplMapTableTreeNode : MetadataTableTreeNode
{
private PEFile module;
public ImplMapTableTreeNode(PEFile module)
: base((HandleKind)0x1C, module)
{
this.module = module;
}
public override object Text => $"1C ImplMap ({module.Metadata.GetTableRowCount(TableIndex.ImplMap)})";

15
ILSpy/Metadata/CorTables/InterfaceImplTableTreeNode.cs

@ -16,31 +16,22 @@ @@ -16,31 +16,22 @@
// OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
// DEALINGS IN THE SOFTWARE.
using System;
using System.Collections.Generic;
using System.Linq;
using System.Reflection.Metadata;
using System.Reflection.Metadata.Ecma335;
using System.Runtime.InteropServices;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Controls;
using ICSharpCode.Decompiler;
using ICSharpCode.Decompiler.Disassembler;
using ICSharpCode.Decompiler.IL;
using ICSharpCode.Decompiler.Metadata;
using ICSharpCode.ILSpy.TextView;
using ICSharpCode.ILSpy.TreeNodes;
namespace ICSharpCode.ILSpy.Metadata
{
class InterfaceImplTableTreeNode : ILSpyTreeNode
class InterfaceImplTableTreeNode : MetadataTableTreeNode
{
private PEFile module;
public InterfaceImplTableTreeNode(PEFile module)
: base((HandleKind)0x09, module)
{
this.module = module;
}
public override object Text => $"09 InterfaceImpl ({module.Metadata.GetTableRowCount(TableIndex.InterfaceImpl)})";

14
ILSpy/Metadata/CorTables/ManifestResourceTableTreeNode.cs

@ -16,31 +16,23 @@ @@ -16,31 +16,23 @@
// OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
// DEALINGS IN THE SOFTWARE.
using System;
using System.Collections.Generic;
using System.Linq;
using System.Reflection;
using System.Reflection.Metadata;
using System.Reflection.Metadata.Ecma335;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Controls;
using ICSharpCode.Decompiler;
using ICSharpCode.Decompiler.Disassembler;
using ICSharpCode.Decompiler.IL;
using ICSharpCode.Decompiler.Metadata;
using ICSharpCode.ILSpy.TextView;
using ICSharpCode.ILSpy.TreeNodes;
namespace ICSharpCode.ILSpy.Metadata
{
class ManifestResourceTableTreeNode : ILSpyTreeNode
class ManifestResourceTableTreeNode : MetadataTableTreeNode
{
private PEFile module;
public ManifestResourceTableTreeNode(PEFile module)
: base(HandleKind.ManifestResource, module)
{
this.module = module;
}
public override object Text => $"28 ManifestResource ({module.Metadata.GetTableRowCount(TableIndex.ManifestResource)})";

17
ILSpy/Metadata/CorTables/MemberRefTableTreeNode.cs

@ -16,31 +16,22 @@ @@ -16,31 +16,22 @@
// OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
// DEALINGS IN THE SOFTWARE.
using System;
using System.Collections.Generic;
using System.Linq;
using System.Reflection.Metadata;
using System.Reflection.Metadata.Ecma335;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Controls;
using ICSharpCode.Decompiler;
using ICSharpCode.Decompiler.IL;
using ICSharpCode.Decompiler.Disassembler;
using ICSharpCode.Decompiler.IL;
using ICSharpCode.Decompiler.Metadata;
using ICSharpCode.Decompiler.TypeSystem;
using ICSharpCode.ILSpy.TextView;
using ICSharpCode.ILSpy.TreeNodes;
namespace ICSharpCode.ILSpy.Metadata
{
internal class MemberRefTableTreeNode : ILSpyTreeNode
internal class MemberRefTableTreeNode : MetadataTableTreeNode
{
private PEFile module;
public MemberRefTableTreeNode(PEFile module)
: base(HandleKind.MemberReference, module)
{
this.module = module;
}
public override object Text => $"0A MemberRef ({module.Metadata.GetTableRowCount(TableIndex.MemberRef)})";

18
ILSpy/Metadata/CorTables/MethodImplTableTreeNode.cs

@ -16,32 +16,22 @@ @@ -16,32 +16,22 @@
// OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
// DEALINGS IN THE SOFTWARE.
using System;
using System.Collections.Generic;
using System.Linq;
using System.Reflection.Metadata;
using System.Reflection.Metadata.Ecma335;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Controls;
using ICSharpCode.Decompiler;
using ICSharpCode.Decompiler.IL;
using ICSharpCode.Decompiler.Disassembler;
using ICSharpCode.Decompiler.IL;
using ICSharpCode.Decompiler.Metadata;
using ICSharpCode.Decompiler.TypeSystem;
using ICSharpCode.ILSpy.TextView;
using ICSharpCode.ILSpy.TreeNodes;
using System.Reflection;
namespace ICSharpCode.ILSpy.Metadata
{
internal class MethodImplTableTreeNode : ILSpyTreeNode
internal class MethodImplTableTreeNode : MetadataTableTreeNode
{
private PEFile module;
public MethodImplTableTreeNode(PEFile module)
: base((HandleKind)0x19, module)
{
this.module = module;
}
public override object Text => $"19 MethodImpl ({module.Metadata.GetTableRowCount(TableIndex.MethodImpl)})";

19
ILSpy/Metadata/CorTables/MethodSemanticsTableTreeNode.cs

@ -16,32 +16,23 @@ @@ -16,32 +16,23 @@
// OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
// DEALINGS IN THE SOFTWARE.
using System;
using System.Collections.Generic;
using System.Linq;
using System.Reflection;
using System.Reflection.Metadata;
using System.Reflection.Metadata.Ecma335;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Controls;
using ICSharpCode.Decompiler;
using ICSharpCode.Decompiler.IL;
using ICSharpCode.Decompiler.Disassembler;
using ICSharpCode.Decompiler.IL;
using ICSharpCode.Decompiler.Metadata;
using ICSharpCode.Decompiler.TypeSystem;
using ICSharpCode.ILSpy.TextView;
using ICSharpCode.ILSpy.TreeNodes;
using System.Reflection;
namespace ICSharpCode.ILSpy.Metadata
{
internal class MethodSemanticsTableTreeNode : ILSpyTreeNode
internal class MethodSemanticsTableTreeNode : MetadataTableTreeNode
{
private PEFile module;
public MethodSemanticsTableTreeNode(PEFile module)
: base((HandleKind)0x18, module)
{
this.module = module;
}
public override object Text => $"18 MethodSemantics ({module.Metadata.GetTableRowCount(TableIndex.MethodSemantics)})";

18
ILSpy/Metadata/CorTables/MethodSpecTableTreeNode.cs

@ -16,34 +16,22 @@ @@ -16,34 +16,22 @@
// OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
// DEALINGS IN THE SOFTWARE.
using System;
using System.Collections.Generic;
using System.Linq;
using System.Reflection;
using System.Reflection.Metadata;
using System.Reflection.Metadata.Ecma335;
using System.Text;
using System.Windows.Controls;
using System.Windows.Data;
using ICSharpCode.Decompiler;
using ICSharpCode.Decompiler.CSharp.Syntax;
using ICSharpCode.Decompiler.Disassembler;
using ICSharpCode.Decompiler.IL;
using ICSharpCode.Decompiler.Metadata;
using ICSharpCode.ILSpy.Controls;
using ICSharpCode.ILSpy.TextView;
using ICSharpCode.ILSpy.TreeNodes;
using ICSharpCode.TreeView;
namespace ICSharpCode.ILSpy.Metadata
{
internal class MethodSpecTableTreeNode : ILSpyTreeNode
internal class MethodSpecTableTreeNode : MetadataTableTreeNode
{
private PEFile module;
public MethodSpecTableTreeNode(PEFile module)
: base(HandleKind.MethodSpecification, module)
{
this.module = module;
}
public override object Text => $"2B MethodSpec ({module.Metadata.GetTableRowCount(TableIndex.MethodSpec)})";

18
ILSpy/Metadata/CorTables/MethodTableTreeNode.cs

@ -16,33 +16,25 @@ @@ -16,33 +16,25 @@
// OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
// DEALINGS IN THE SOFTWARE.
using System;
using System.Collections.Generic;
using System.Linq;
using System.Reflection;
using System.Reflection.Metadata;
using System.Reflection.Metadata.Ecma335;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Controls;
using ICSharpCode.Decompiler;
using ICSharpCode.Decompiler.IL;
using ICSharpCode.Decompiler.Disassembler;
using ICSharpCode.Decompiler.IL;
using ICSharpCode.Decompiler.Metadata;
using ICSharpCode.Decompiler.TypeSystem;
using ICSharpCode.ILSpy.TextView;
using ICSharpCode.ILSpy.TreeNodes;
using System.Diagnostics;
using System.Reflection;
namespace ICSharpCode.ILSpy.Metadata
{
internal class MethodTableTreeNode : ILSpyTreeNode
internal class MethodTableTreeNode : MetadataTableTreeNode
{
private PEFile module;
public MethodTableTreeNode(PEFile module)
: base(HandleKind.MethodDefinition, module)
{
this.module = module;
}
public override object Text => $"06 Method ({module.Metadata.GetTableRowCount(TableIndex.MethodDef)})";

18
ILSpy/Metadata/CorTables/ModuleRefTableTreeNode.cs

@ -16,32 +16,20 @@ @@ -16,32 +16,20 @@
// OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
// DEALINGS IN THE SOFTWARE.
using System;
using System.Collections.Generic;
using System.Linq;
using System.Reflection;
using System.Reflection.Metadata;
using System.Reflection.Metadata.Ecma335;
using System.Text;
using System.Windows.Controls;
using System.Windows.Data;
using ICSharpCode.Decompiler;
using ICSharpCode.Decompiler.CSharp.Syntax;
using ICSharpCode.Decompiler.Metadata;
using ICSharpCode.ILSpy.Controls;
using ICSharpCode.ILSpy.TextView;
using ICSharpCode.ILSpy.TreeNodes;
using ICSharpCode.TreeView;
namespace ICSharpCode.ILSpy.Metadata
{
internal class ModuleRefTableTreeNode : ILSpyTreeNode
internal class ModuleRefTableTreeNode : MetadataTableTreeNode
{
private PEFile module;
public ModuleRefTableTreeNode(PEFile module)
: base(HandleKind.ModuleReference, module)
{
this.module = module;
}
public override object Text => $"1A ModuleRef ({module.Metadata.GetTableRowCount(TableIndex.ModuleRef)})";

18
ILSpy/Metadata/CorTables/ModuleTableTreeNode.cs

@ -16,32 +16,20 @@ @@ -16,32 +16,20 @@
// OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
// DEALINGS IN THE SOFTWARE.
using System;
using System.Collections.Generic;
using System.Linq;
using System.Reflection;
using System.Reflection.Metadata;
using System.Reflection.Metadata.Ecma335;
using System.Text;
using System.Windows.Controls;
using System.Windows.Data;
using ICSharpCode.Decompiler;
using ICSharpCode.Decompiler.CSharp.Syntax;
using ICSharpCode.Decompiler.Metadata;
using ICSharpCode.ILSpy.Controls;
using ICSharpCode.ILSpy.TextView;
using ICSharpCode.ILSpy.TreeNodes;
using ICSharpCode.TreeView;
namespace ICSharpCode.ILSpy.Metadata
{
internal class ModuleTableTreeNode : ILSpyTreeNode
internal class ModuleTableTreeNode : MetadataTableTreeNode
{
private PEFile module;
public ModuleTableTreeNode(PEFile module)
: base(HandleKind.ModuleDefinition, module)
{
this.module = module;
}
public override object Text => $"00 Module ({module.Metadata.GetTableRowCount(TableIndex.Module)})";

16
ILSpy/Metadata/CorTables/NestedClassTableTreeNode.cs

@ -16,32 +16,22 @@ @@ -16,32 +16,22 @@
// OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
// DEALINGS IN THE SOFTWARE.
using System;
using System.Collections.Generic;
using System.Linq;
using System.Reflection.Metadata;
using System.Reflection.Metadata.Ecma335;
using System.Runtime.InteropServices;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Controls;
using ICSharpCode.Decompiler;
using ICSharpCode.Decompiler.Disassembler;
using ICSharpCode.Decompiler.IL;
using ICSharpCode.Decompiler.Metadata;
using ICSharpCode.ILSpy.TextView;
using ICSharpCode.ILSpy.TreeNodes;
using Mono.Cecil;
namespace ICSharpCode.ILSpy.Metadata
{
class NestedClassTableTreeNode : ILSpyTreeNode
class NestedClassTableTreeNode : MetadataTableTreeNode
{
private PEFile module;
public NestedClassTableTreeNode(PEFile module)
: base((HandleKind)0x29, module)
{
this.module = module;
}
public override object Text => $"29 NestedClass ({module.Metadata.GetTableRowCount(TableIndex.NestedClass)})";

19
ILSpy/Metadata/CorTables/ParamTableTreeNode.cs

@ -16,34 +16,21 @@ @@ -16,34 +16,21 @@
// OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
// DEALINGS IN THE SOFTWARE.
using System;
using System.Collections.Generic;
using System.Linq;
using System.Reflection;
using System.Reflection.Metadata;
using System.Reflection.Metadata.Ecma335;
using System.Text;
using System.Windows.Controls;
using System.Windows.Data;
using ICSharpCode.Decompiler;
using ICSharpCode.Decompiler.CSharp.Syntax;
using ICSharpCode.Decompiler.Disassembler;
using ICSharpCode.Decompiler.IL;
using ICSharpCode.Decompiler.Metadata;
using ICSharpCode.ILSpy.Controls;
using ICSharpCode.ILSpy.TextView;
using ICSharpCode.ILSpy.TreeNodes;
using ICSharpCode.TreeView;
namespace ICSharpCode.ILSpy.Metadata
{
internal class ParamTableTreeNode : ILSpyTreeNode
internal class ParamTableTreeNode : MetadataTableTreeNode
{
private PEFile module;
public ParamTableTreeNode(PEFile module)
: base(HandleKind.Parameter, module)
{
this.module = module;
}
public override object Text => $"08 Param ({module.Metadata.GetTableRowCount(TableIndex.Param)})";

15
ILSpy/Metadata/CorTables/PropertyMapTableTreeNode.cs

@ -16,31 +16,22 @@ @@ -16,31 +16,22 @@
// OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
// DEALINGS IN THE SOFTWARE.
using System;
using System.Collections.Generic;
using System.Linq;
using System.Reflection.Metadata;
using System.Reflection.Metadata.Ecma335;
using System.Runtime.InteropServices;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Controls;
using ICSharpCode.Decompiler;
using ICSharpCode.Decompiler.Disassembler;
using ICSharpCode.Decompiler.IL;
using ICSharpCode.Decompiler.Metadata;
using ICSharpCode.ILSpy.TextView;
using ICSharpCode.ILSpy.TreeNodes;
namespace ICSharpCode.ILSpy.Metadata
{
class PropertyMapTableTreeNode : ILSpyTreeNode
class PropertyMapTableTreeNode : MetadataTableTreeNode
{
private PEFile module;
public PropertyMapTableTreeNode(PEFile module)
: base((HandleKind)0x15, module)
{
this.module = module;
}
public override object Text => $"15 PropertyMap ({module.Metadata.GetTableRowCount(TableIndex.PropertyMap)})";

17
ILSpy/Metadata/CorTables/PropertyTableTreeNode.cs

@ -16,32 +16,25 @@ @@ -16,32 +16,25 @@
// OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
// DEALINGS IN THE SOFTWARE.
using System;
using System.Collections.Generic;
using System.Linq;
using System.Reflection;
using System.Reflection.Metadata;
using System.Reflection.Metadata.Ecma335;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Controls;
using ICSharpCode.Decompiler;
using ICSharpCode.Decompiler.IL;
using ICSharpCode.Decompiler.Disassembler;
using ICSharpCode.Decompiler.IL;
using ICSharpCode.Decompiler.Metadata;
using ICSharpCode.Decompiler.TypeSystem;
using ICSharpCode.ILSpy.TextView;
using ICSharpCode.ILSpy.TreeNodes;
using System.Reflection;
namespace ICSharpCode.ILSpy.Metadata
{
internal class PropertyTableTreeNode : ILSpyTreeNode
internal class PropertyTableTreeNode : MetadataTableTreeNode
{
private PEFile module;
public PropertyTableTreeNode(PEFile module)
: base(HandleKind.PropertyDefinition, module)
{
this.module = module;
}
public override object Text => $"17 Property ({module.Metadata.GetTableRowCount(TableIndex.Property)})";

16
ILSpy/Metadata/CorTables/StandAloneSigTableTreeNode.cs

@ -16,30 +16,20 @@ @@ -16,30 +16,20 @@
// OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
// DEALINGS IN THE SOFTWARE.
using System;
using System.Collections.Generic;
using System.Linq;
using System.Reflection.Metadata;
using System.Reflection.Metadata.Ecma335;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Controls;
using ICSharpCode.Decompiler;
using ICSharpCode.Decompiler.Disassembler;
using ICSharpCode.Decompiler.IL;
using ICSharpCode.Decompiler.Metadata;
using ICSharpCode.ILSpy.TextView;
using ICSharpCode.ILSpy.TreeNodes;
namespace ICSharpCode.ILSpy.Metadata
{
class StandAloneSigTableTreeNode : ILSpyTreeNode
class StandAloneSigTableTreeNode : MetadataTableTreeNode
{
private PEFile module;
public StandAloneSigTableTreeNode(PEFile module)
: base(HandleKind.StandaloneSignature, module)
{
this.module = module;
}
public override object Text => $"11 StandAloneSig ({module.Metadata.GetTableRowCount(TableIndex.StandAloneSig)})";

16
ILSpy/Metadata/CorTables/TypeDefTableTreeNode.cs

@ -16,35 +16,25 @@ @@ -16,35 +16,25 @@
// OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
// DEALINGS IN THE SOFTWARE.
using System;
using System.Collections.Generic;
using System.Linq;
using System.Reflection;
using System.Reflection.Metadata;
using System.Reflection.Metadata.Ecma335;
using System.Text;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using ICSharpCode.Decompiler;
using ICSharpCode.Decompiler.CSharp.Syntax;
using ICSharpCode.Decompiler.Disassembler;
using ICSharpCode.Decompiler.Metadata;
using ICSharpCode.Decompiler.TypeSystem;
using ICSharpCode.ILSpy.Controls;
using ICSharpCode.ILSpy.TextView;
using ICSharpCode.ILSpy.TreeNodes;
using ICSharpCode.TreeView;
namespace ICSharpCode.ILSpy.Metadata
{
internal class TypeDefTableTreeNode : ILSpyTreeNode
internal class TypeDefTableTreeNode : MetadataTableTreeNode
{
private PEFile module;
public TypeDefTableTreeNode(PEFile module)
: base(HandleKind.TypeDefinition, module)
{
this.module = module;
}
public override object Text => $"02 TypeDef ({module.Metadata.GetTableRowCount(TableIndex.TypeDef)})";

18
ILSpy/Metadata/CorTables/TypeRefTableTreeNode.cs

@ -16,33 +16,21 @@ @@ -16,33 +16,21 @@
// OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
// DEALINGS IN THE SOFTWARE.
using System;
using System.Collections.Generic;
using System.Linq;
using System.Reflection;
using System.Reflection.Metadata;
using System.Reflection.Metadata.Ecma335;
using System.Text;
using System.Windows.Controls;
using System.Windows.Data;
using ICSharpCode.Decompiler;
using ICSharpCode.Decompiler.CSharp.Syntax;
using ICSharpCode.Decompiler.IL;
using ICSharpCode.Decompiler.Metadata;
using ICSharpCode.ILSpy.Controls;
using ICSharpCode.ILSpy.TextView;
using ICSharpCode.ILSpy.TreeNodes;
using ICSharpCode.TreeView;
namespace ICSharpCode.ILSpy.Metadata
{
internal class TypeRefTableTreeNode : ILSpyTreeNode
internal class TypeRefTableTreeNode : MetadataTableTreeNode
{
private PEFile module;
public TypeRefTableTreeNode(PEFile module)
: base(HandleKind.TypeReference, module)
{
this.module = module;
}
public override object Text => $"01 TypeRef ({module.Metadata.GetTableRowCount(TableIndex.TypeRef)})";

19
ILSpy/Metadata/CorTables/TypeSpecTableTreeNode.cs

@ -16,34 +16,21 @@ @@ -16,34 +16,21 @@
// OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
// DEALINGS IN THE SOFTWARE.
using System;
using System.Collections.Generic;
using System.Linq;
using System.Reflection;
using System.Reflection.Metadata;
using System.Reflection.Metadata.Ecma335;
using System.Text;
using System.Windows.Controls;
using System.Windows.Data;
using ICSharpCode.Decompiler;
using ICSharpCode.Decompiler.CSharp.Syntax;
using ICSharpCode.Decompiler.Disassembler;
using ICSharpCode.Decompiler.IL;
using ICSharpCode.Decompiler.Metadata;
using ICSharpCode.ILSpy.Controls;
using ICSharpCode.ILSpy.TextView;
using ICSharpCode.ILSpy.TreeNodes;
using ICSharpCode.TreeView;
namespace ICSharpCode.ILSpy.Metadata
{
internal class TypeSpecTableTreeNode : ILSpyTreeNode
internal class TypeSpecTableTreeNode : MetadataTableTreeNode
{
private PEFile module;
public TypeSpecTableTreeNode(PEFile module)
: base(HandleKind.TypeSpecification, module)
{
this.module = module;
}
public override object Text => $"1B TypeSpec ({module.Metadata.GetTableRowCount(TableIndex.TypeSpec)})";

32
ILSpy/Metadata/MetadataProtocolHandler.cs

@ -0,0 +1,32 @@ @@ -0,0 +1,32 @@
using System;
using System.Collections.Generic;
using System.ComponentModel.Composition;
using System.Linq;
using System.Reflection.Metadata;
using System.Text;
using System.Threading.Tasks;
using ICSharpCode.Decompiler.Metadata;
using ICSharpCode.ILSpy.TreeNodes;
namespace ICSharpCode.ILSpy.Metadata
{
[Export(typeof(IProtocolHandler))]
class MetadataProtocolHandler : IProtocolHandler
{
public ILSpyTreeNode Resolve(string protocol, PEFile module, Handle handle, out bool newTabPage)
{
newTabPage = true;
if (protocol != "metadata")
return null;
var assemblyTreeNode = MainWindow.Instance.FindTreeNode(module) as AssemblyTreeNode;
if (assemblyTreeNode == null)
return null;
var mxNode = assemblyTreeNode.Children.OfType<MetadataTreeNode>().FirstOrDefault();
if (mxNode != null) {
mxNode.EnsureLazyChildren();
return mxNode.FindNodeByHandleKind(handle.Kind);
}
return null;
}
}
}

38
ILSpy/Metadata/MetadataTableTreeNode.cs

@ -0,0 +1,38 @@ @@ -0,0 +1,38 @@
// Copyright (c) 2011 AlphaSierraPapa for the SharpDevelop Team
//
// Permission is hereby granted, free of charge, to any person obtaining a copy of this
// software and associated documentation files (the "Software"), to deal in the Software
// without restriction, including without limitation the rights to use, copy, modify, merge,
// publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons
// to whom the Software is furnished to do so, subject to the following conditions:
//
// The above copyright notice and this permission notice shall be included in all copies or
// substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED,
// INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR
// PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE
// FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
// OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
// DEALINGS IN THE SOFTWARE.
using System.Reflection.Metadata;
using ICSharpCode.Decompiler.Metadata;
using ICSharpCode.ILSpy.TreeNodes;
using ICSharpCode.TreeView;
namespace ICSharpCode.ILSpy.Metadata
{
internal abstract class MetadataTableTreeNode : ILSpyTreeNode
{
protected PEFile module;
public HandleKind Kind { get; }
public MetadataTableTreeNode(HandleKind kind, PEFile module)
{
this.module = module;
this.Kind = kind;
}
}
}

6
ILSpy/Metadata/MetadataTreeNode.cs

@ -20,6 +20,7 @@ using System; @@ -20,6 +20,7 @@ using System;
using System.Collections.Generic;
using System.Globalization;
using System.Linq;
using System.Reflection.Metadata;
using System.Reflection.PortableExecutable;
using System.Text;
using System.Threading.Tasks;
@ -102,6 +103,11 @@ namespace ICSharpCode.ILSpy.Metadata @@ -102,6 +103,11 @@ namespace ICSharpCode.ILSpy.Metadata
this.Children.Add(new MethodSpecTableTreeNode(module));
this.Children.Add(new GenericParamConstraintTableTreeNode(module));
}
public ILSpyTreeNode FindNodeByHandleKind(HandleKind kind)
{
return this.Children.OfType<MetadataTableTreeNode>().SingleOrDefault(x => x.Kind == kind);
}
}
class Entry

4
ILSpy/TextView/AvalonEditTextOutput.cs

@ -230,7 +230,7 @@ namespace ICSharpCode.ILSpy.TextView @@ -230,7 +230,7 @@ namespace ICSharpCode.ILSpy.TextView
references.Add(new ReferenceSegment { StartOffset = start, EndOffset = end, Reference = opCode });
}
public void WriteReference(PEFile module, EntityHandle handle, string text, bool isDefinition = false)
public void WriteReference(PEFile module, Handle handle, string text, string protocol = "decompile", bool isDefinition = false)
{
WriteIndent();
int start = this.TextLength;
@ -239,7 +239,7 @@ namespace ICSharpCode.ILSpy.TextView @@ -239,7 +239,7 @@ namespace ICSharpCode.ILSpy.TextView
if (isDefinition) {
this.DefinitionLookup.AddDefinition((module, handle), this.TextLength);
}
references.Add(new ReferenceSegment { StartOffset = start, EndOffset = end, Reference = (module, handle), IsDefinition = isDefinition });
references.Add(new ReferenceSegment { StartOffset = start, EndOffset = end, Reference = (protocol, module, handle), IsDefinition = isDefinition });
}
public void WriteReference(IType type, string text, bool isDefinition = false)

Loading…
Cancel
Save