Browse Source

Support for most metadata tables.

pull/1716/head
Siegfried Pammer 6 years ago
parent
commit
8bf7d3f41c
  1. 22
      ICSharpCode.Decompiler/Metadata/Dom.cs
  2. 71
      ICSharpCode.Decompiler/Metadata/MetadataExtensions.cs
  3. 106
      ILSpy/ILSpy.csproj
  4. 20
      ILSpy/Metadata/CoffHeaderTreeNode.cs
  5. 118
      ILSpy/Metadata/CorTables/AssemblyRefTableTreeNode.cs
  6. 114
      ILSpy/Metadata/CorTables/AssemblyTableTreeNode.cs
  7. 116
      ILSpy/Metadata/CorTables/ConstantTableTreeNode.cs
  8. 127
      ILSpy/Metadata/CorTables/CustomAttributeTableTreeNode.cs
  9. 124
      ILSpy/Metadata/CorTables/DeclSecurityTableTreeNode.cs
  10. 117
      ILSpy/Metadata/CorTables/EventTableTreeNode.cs
  11. 28
      ILSpy/Metadata/CorTables/ExportedTypeTableTreeNode.cs
  12. 119
      ILSpy/Metadata/CorTables/FieldLayoutTableTreeNode.cs
  13. 20
      ILSpy/Metadata/CorTables/FieldTableTreeNode.cs
  14. 116
      ILSpy/Metadata/CorTables/FileTableTreeNode.cs
  15. 120
      ILSpy/Metadata/CorTables/GenericParamConstraintTableTreeNode.cs
  16. 120
      ILSpy/Metadata/CorTables/GenericParamTableTreeNode.cs
  17. 118
      ILSpy/Metadata/CorTables/ManifestResourceTableTreeNode.cs
  18. 122
      ILSpy/Metadata/CorTables/MemberRefTableTreeNode.cs
  19. 126
      ILSpy/Metadata/CorTables/MethodSemanticsTableTreeNode.cs
  20. 128
      ILSpy/Metadata/CorTables/MethodSpecTableTreeNode.cs
  21. 20
      ILSpy/Metadata/CorTables/MethodTableTreeNode.cs
  22. 102
      ILSpy/Metadata/CorTables/ModuleRefTableTreeNode.cs
  23. 115
      ILSpy/Metadata/CorTables/ModuleTableTreeNode.cs
  24. 111
      ILSpy/Metadata/CorTables/ParamTableTreeNode.cs
  25. 117
      ILSpy/Metadata/CorTables/PropertyTableTreeNode.cs
  26. 105
      ILSpy/Metadata/CorTables/StandAloneSigTableTreeNode.cs
  27. 20
      ILSpy/Metadata/CorTables/TypeDefTableTreeNode.cs
  28. 135
      ILSpy/Metadata/CorTables/TypeRefTableTreeNode.cs
  29. 110
      ILSpy/Metadata/CorTables/TypeSpecTableTreeNode.cs
  30. 20
      ILSpy/Metadata/DataDirectoriesTreeNode.cs
  31. 20
      ILSpy/Metadata/DosHeaderTreeNode.cs
  32. 73
      ILSpy/Metadata/EntityHandleTemplate.cs
  33. 20
      ILSpy/Metadata/Helpers.cs
  34. 384
      ILSpy/Metadata/MetadataTableViews.xaml
  35. 39
      ILSpy/Metadata/MetadataTreeNode.cs
  36. 95
      ILSpy/Metadata/ModuleTableTreeNode.cs
  37. 20
      ILSpy/Metadata/OptionalHeaderTreeNode.cs
  38. 20
      ILSpy/Metadata/StringHandleTemplate.cs
  39. 89
      ILSpy/Metadata/TypeRefTableTreeNode.cs

22
ICSharpCode.Decompiler/Metadata/Dom.cs

@ -110,7 +110,7 @@ namespace ICSharpCode.Decompiler.Metadata @@ -110,7 +110,7 @@ namespace ICSharpCode.Decompiler.Metadata
}
}
public sealed class FullTypeNameSignatureDecoder : ISignatureTypeProvider<FullTypeName, Unit>
public sealed class FullTypeNameSignatureDecoder : ISignatureTypeProvider<FullTypeName, Unit>, ICustomAttributeTypeProvider<FullTypeName>
{
readonly MetadataReader metadata;
@ -170,6 +170,11 @@ namespace ICSharpCode.Decompiler.Metadata @@ -170,6 +170,11 @@ namespace ICSharpCode.Decompiler.Metadata
return new TopLevelTypeName(ktr.Namespace, ktr.Name, ktr.TypeParameterCount);
}
public FullTypeName GetSystemType()
{
return new TopLevelTypeName("System", "Type");
}
public FullTypeName GetSZArrayType(FullTypeName elementType)
{
return elementType;
@ -185,10 +190,25 @@ namespace ICSharpCode.Decompiler.Metadata @@ -185,10 +190,25 @@ namespace ICSharpCode.Decompiler.Metadata
return handle.GetFullTypeName(reader);
}
public FullTypeName GetTypeFromSerializedName(string name)
{
return new FullTypeName(name);
}
public FullTypeName GetTypeFromSpecification(MetadataReader reader, Unit genericContext, TypeSpecificationHandle handle, byte rawTypeKind)
{
return reader.GetTypeSpecification(handle).DecodeSignature(new FullTypeNameSignatureDecoder(metadata), default);
}
public PrimitiveTypeCode GetUnderlyingEnumType(FullTypeName type)
{
throw new NotImplementedException();
}
public bool IsSystemType(FullTypeName type)
{
return type.IsKnownType(KnownTypeCode.Type);
}
}
public class GenericContext

71
ICSharpCode.Decompiler/Metadata/MetadataExtensions.cs

@ -251,5 +251,76 @@ namespace ICSharpCode.Decompiler.Metadata @@ -251,5 +251,76 @@ namespace ICSharpCode.Decompiler.Metadata
yield return MetadataTokens.ModuleReferenceHandle(row);
}
}
public static IEnumerable<TypeSpecificationHandle> GetTypeSpecifications(this MetadataReader metadata)
{
var rowCount = metadata.GetTableRowCount(TableIndex.TypeSpec);
for (int row = 1; row <= rowCount; row++) {
yield return MetadataTokens.TypeSpecificationHandle(row);
}
}
public static IEnumerable<MethodSpecificationHandle> GetMethodSpecifications(this MetadataReader metadata)
{
var rowCount = metadata.GetTableRowCount(TableIndex.MethodSpec);
for (int row = 1; row <= rowCount; row++) {
yield return MetadataTokens.MethodSpecificationHandle(row);
}
}
public static IEnumerable<(Handle Handle, MethodSemanticsAttributes Semantics, MethodDefinitionHandle Method, EntityHandle Association)> GetMethodSemantics(this MetadataReader metadata)
{
int offset = metadata.GetTableMetadataOffset(TableIndex.MethodSemantics);
int rowSize = metadata.GetTableRowSize(TableIndex.MethodSemantics);
int rowCount = metadata.GetTableRowCount(TableIndex.MethodSemantics);
bool methodSmall = metadata.GetTableRowCount(TableIndex.MethodDef) <= ushort.MaxValue;
bool assocSmall = metadata.GetTableRowCount(TableIndex.Property) <= ushort.MaxValue && metadata.GetTableRowCount(TableIndex.Event) <= ushort.MaxValue;
int assocOffset = (methodSmall ? 2 : 4) + 2;
for (int row = 0; row < rowCount; row++) {
yield return Read(row);
}
unsafe (Handle Handle, MethodSemanticsAttributes Semantics, MethodDefinitionHandle Method, EntityHandle Association) Read(int row)
{
byte* ptr = metadata.MetadataPointer + offset + rowSize * row;
int methodDef = methodSmall ? *(ushort*)(ptr + 2) : (int)*(uint*)(ptr + 2);
int assocDef = assocSmall ? *(ushort*)(ptr + assocOffset) : (int)*(uint*)(ptr + assocOffset);
EntityHandle propOrEvent;
if ((assocDef & 0x1) == 1) {
propOrEvent = MetadataTokens.PropertyDefinitionHandle(assocDef >> 1);
} else {
propOrEvent = MetadataTokens.EventDefinitionHandle(assocDef >> 1);
}
return (MetadataTokens.Handle(0x18000000 | (row + 1)), (MethodSemanticsAttributes)(*(ushort*)ptr), MetadataTokens.MethodDefinitionHandle(methodDef), propOrEvent);
}
}
public static IEnumerable<EntityHandle> GetFieldLayouts(this MetadataReader metadata)
{
var rowCount = metadata.GetTableRowCount(TableIndex.FieldLayout);
for (int row = 1; row <= rowCount; row++) {
yield return MetadataTokens.EntityHandle(TableIndex.FieldLayout, row);
}
}
public unsafe static (int Offset, FieldDefinitionHandle FieldDef) GetFieldLayout(this MetadataReader metadata, EntityHandle fieldLayoutHandle)
{
byte* startPointer = metadata.MetadataPointer;
int offset = metadata.GetTableMetadataOffset(TableIndex.FieldLayout);
int rowSize = metadata.GetTableRowSize(TableIndex.FieldLayout);
int rowCount = metadata.GetTableRowCount(TableIndex.FieldLayout);
int fieldRowNo = metadata.GetRowNumber(fieldLayoutHandle);
bool small = metadata.GetTableRowCount(TableIndex.Field) <= ushort.MaxValue;
for (int row = rowCount - 1; row >= 0; row--) {
byte* ptr = startPointer + offset + rowSize * row;
uint rowNo = small ? *(ushort*)(ptr + 4) : *(uint*)(ptr + 4);
if (fieldRowNo == rowNo) {
return (*(int*)ptr, MetadataTokens.FieldDefinitionHandle(fieldRowNo));
}
}
return (0, default);
}
}
}

106
ILSpy/ILSpy.csproj

@ -160,18 +160,112 @@ @@ -160,18 +160,112 @@
<Compile Include="Languages\IResourceFileHandler.cs" />
<Compile Include="Languages\Language.cs" />
<Compile Include="Languages\Languages.cs" />
<Compile Include="Metadata\CorTables\AssemblyRefTableTreeNode.cs">
<SubType>Code</SubType>
<Generator>MSBuild:Compile</Generator>
</Compile>
<Compile Include="Metadata\CorTables\AssemblyTableTreeNode.cs">
<SubType>Code</SubType>
<Generator>MSBuild:Compile</Generator>
</Compile>
<Compile Include="Metadata\CorTables\ConstantTableTreeNode.cs">
<SubType>Code</SubType>
<Generator>MSBuild:Compile</Generator>
</Compile>
<Compile Include="Metadata\CorTables\CustomAttributeTableTreeNode.cs">
<SubType>Code</SubType>
<Generator>MSBuild:Compile</Generator>
</Compile>
<Compile Include="Metadata\CorTables\DeclSecurityTableTreeNode.cs">
<SubType>Code</SubType>
<Generator>MSBuild:Compile</Generator>
</Compile>
<Compile Include="Metadata\CorTables\EventTableTreeNode.cs">
<SubType>Code</SubType>
<Generator>MSBuild:Compile</Generator>
</Compile>
<Compile Include="Metadata\CorTables\ExportedTypeTableTreeNode.cs">
<SubType>Code</SubType>
<Generator>MSBuild:Compile</Generator>
</Compile>
<Compile Include="Metadata\CorTables\FieldLayoutTableTreeNode.cs">
<SubType>Code</SubType>
<Generator>MSBuild:Compile</Generator>
</Compile>
<Compile Include="Metadata\CorTables\FieldTableTreeNode.cs">
<SubType>Code</SubType>
<Generator>MSBuild:Compile</Generator>
</Compile>
<Compile Include="Metadata\CorTables\FileTableTreeNode.cs">
<SubType>Code</SubType>
<Generator>MSBuild:Compile</Generator>
</Compile>
<Compile Include="Metadata\CorTables\GenericParamConstraintTableTreeNode.cs">
<SubType>Code</SubType>
<Generator>MSBuild:Compile</Generator>
</Compile>
<Compile Include="Metadata\CorTables\GenericParamTableTreeNode.cs">
<SubType>Code</SubType>
<Generator>MSBuild:Compile</Generator>
</Compile>
<Compile Include="Metadata\CorTables\ManifestResourceTableTreeNode.cs">
<SubType>Code</SubType>
<Generator>MSBuild:Compile</Generator>
</Compile>
<Compile Include="Metadata\CorTables\MemberRefTableTreeNode.cs">
<SubType>Code</SubType>
<Generator>MSBuild:Compile</Generator>
</Compile>
<Compile Include="Metadata\CorTables\MethodSemanticsTableTreeNode.cs">
<SubType>Code</SubType>
<Generator>MSBuild:Compile</Generator>
</Compile>
<Compile Include="Metadata\CorTables\MethodSpecTableTreeNode.cs">
<SubType>Code</SubType>
<Generator>MSBuild:Compile</Generator>
</Compile>
<Compile Include="Metadata\CorTables\MethodTableTreeNode.cs">
<SubType>Code</SubType>
<Generator>MSBuild:Compile</Generator>
</Compile>
<Compile Include="Metadata\CorTables\ModuleRefTableTreeNode.cs">
<SubType>Code</SubType>
<Generator>MSBuild:Compile</Generator>
</Compile>
<Compile Include="Metadata\CorTables\ModuleTableTreeNode.cs">
<SubType>Code</SubType>
<Generator>MSBuild:Compile</Generator>
</Compile>
<Compile Include="Metadata\CorTables\ParamTableTreeNode.cs">
<SubType>Code</SubType>
<Generator>MSBuild:Compile</Generator>
</Compile>
<Compile Include="Metadata\CorTables\PropertyTableTreeNode.cs">
<SubType>Code</SubType>
<Generator>MSBuild:Compile</Generator>
</Compile>
<Compile Include="Metadata\CorTables\StandAloneSigTableTreeNode.cs">
<SubType>Code</SubType>
<Generator>MSBuild:Compile</Generator>
</Compile>
<Compile Include="Metadata\CorTables\TypeDefTableTreeNode.cs">
<SubType>Code</SubType>
<Generator>MSBuild:Compile</Generator>
</Compile>
<Compile Include="Metadata\CorTables\TypeRefTableTreeNode.cs">
<SubType>Code</SubType>
<Generator>MSBuild:Compile</Generator>
</Compile>
<Compile Include="Metadata\CorTables\TypeSpecTableTreeNode.cs">
<SubType>Code</SubType>
<Generator>MSBuild:Compile</Generator>
</Compile>
<Compile Include="Metadata\DataDirectoriesTreeNode.cs" />
<Compile Include="Metadata\DosHeaderTreeNode.cs" />
<Compile Include="Metadata\CoffHeaderTreeNode.cs" />
<Compile Include="Metadata\EntityHandleTemplate.cs" />
<Compile Include="Metadata\MethodTableTreeNode.cs" />
<Compile Include="Metadata\FieldTableTreeNode.cs" />
<Compile Include="Metadata\Helpers.cs" />
<Compile Include="Metadata\StringHandleTemplate.cs" />
<Compile Include="Metadata\TypeDefTableTreeNode.cs" />
<Compile Include="Metadata\TypeRefTableTreeNode.cs" />
<Compile Include="Metadata\ModuleTableTreeNode.cs" />
<Compile Include="Metadata\ExportedTypeTableTreeNode.cs" />
<Compile Include="Metadata\MetadataTableViews.xaml.cs" />
<Compile Include="Metadata\MetadataTreeNode.cs" />
<Compile Include="Metadata\OptionalHeaderTreeNode.cs" />

20
ILSpy/Metadata/CoffHeaderTreeNode.cs

@ -1,4 +1,22 @@ @@ -1,4 +1,22 @@
using System;
// 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;
using System.Collections.Generic;
using System.Windows;
using System.Windows.Controls;

118
ILSpy/Metadata/CorTables/AssemblyRefTableTreeNode.cs

@ -0,0 +1,118 @@ @@ -0,0 +1,118 @@
// 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;
using System.Collections.Generic;
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
{
private PEFile module;
public AssemblyRefTableTreeNode(PEFile module)
{
this.module = module;
}
public override object Text => $"23 AssemblyRef ({module.Metadata.GetTableRowCount(TableIndex.AssemblyRef)})";
public override object Icon => Images.Literal;
public override bool View(DecompilerTextView textView)
{
ListView view = Helpers.CreateListView("AssemblyRefView");
var metadata = module.Metadata;
var list = new List<AssemblyRefEntry>();
foreach (var row in metadata.AssemblyReferences) {
list.Add(new AssemblyRefEntry(module, row));
}
view.ItemsSource = list;
textView.ShowContent(new[] { this }, view);
return true;
}
struct AssemblyRefEntry
{
readonly int metadataOffset;
readonly PEFile module;
readonly MetadataReader metadata;
readonly AssemblyReferenceHandle handle;
readonly System.Reflection.Metadata.AssemblyReference assemblyRef;
public int RID => MetadataTokens.GetRowNumber(handle);
public int Token => MetadataTokens.GetToken(handle);
public int Offset => metadataOffset
+ metadata.GetTableMetadataOffset(TableIndex.AssemblyRef)
+ metadata.GetTableRowSize(TableIndex.AssemblyRef) * (RID - 1);
public Version Version => assemblyRef.Version;
public int Flags => (int)assemblyRef.Flags;
public string FlagsTooltip => null;// Helpers.AttributesToString(assemblyRef.Flags);
public int PublicKeyOrToken => MetadataTokens.GetHeapOffset(assemblyRef.PublicKeyOrToken);
public string PublicKeyOrTokenTooltip {
get {
if (assemblyRef.PublicKeyOrToken.IsNil)
return null;
System.Collections.Immutable.ImmutableArray<byte> token = metadata.GetBlobContent(assemblyRef.PublicKeyOrToken);
return token.ToHexString(token.Length);
}
}
public int NameStringHandle => MetadataTokens.GetHeapOffset(assemblyRef.Name);
public string Name => metadata.GetString(assemblyRef.Name);
public int CultureStringHandle => MetadataTokens.GetHeapOffset(assemblyRef.Culture);
public string Culture => metadata.GetString(assemblyRef.Culture);
public AssemblyRefEntry(PEFile module, AssemblyReferenceHandle handle)
{
this.metadataOffset = module.Reader.PEHeaders.MetadataStartOffset;
this.module = module;
this.metadata = module.Metadata;
this.handle = handle;
this.assemblyRef = metadata.GetAssemblyReference(handle);
}
}
public override void Decompile(Language language, ITextOutput output, DecompilationOptions options)
{
language.WriteCommentLine(output, "AssemblyRef");
}
}
}

114
ILSpy/Metadata/CorTables/AssemblyTableTreeNode.cs

@ -0,0 +1,114 @@ @@ -0,0 +1,114 @@
// 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;
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
{
private PEFile module;
public AssemblyTableTreeNode(PEFile module)
{
this.module = module;
}
public override object Text => $"20 Assembly ({module.Metadata.GetTableRowCount(TableIndex.Assembly)})";
public override object Icon => Images.Literal;
public override bool View(DecompilerTextView textView)
{
ListView view = Helpers.CreateListView("AssemblyView");
var metadata = module.Metadata;
var list = new List<AssemblyEntry>();
list.Add(new AssemblyEntry(module));
view.ItemsSource = list;
textView.ShowContent(new[] { this }, view);
return true;
}
struct AssemblyEntry
{
readonly int metadataOffset;
readonly PEFile module;
readonly MetadataReader metadata;
readonly AssemblyDefinition assembly;
public int RID => MetadataTokens.GetRowNumber(EntityHandle.AssemblyDefinition);
public int Token => MetadataTokens.GetToken(EntityHandle.AssemblyDefinition);
public int Offset => metadataOffset
+ metadata.GetTableMetadataOffset(TableIndex.Assembly)
+ metadata.GetTableRowSize(TableIndex.Assembly) * (RID - 1);
public int HashAlgorithm => (int)assembly.HashAlgorithm;
public string HashAlgorithmTooltip => assembly.HashAlgorithm.ToString();
public int Flags => (int)assembly.Flags;
public string FlagsTooltip => null;// Helpers.AttributesToString(assembly.Flags);
public Version Version => assembly.Version;
public int NameStringHandle => MetadataTokens.GetHeapOffset(assembly.Name);
public string Name => metadata.GetString(assembly.Name);
public int CultureStringHandle => MetadataTokens.GetHeapOffset(assembly.Culture);
public string Culture => metadata.GetString(assembly.Culture);
public AssemblyEntry(PEFile module)
{
this.metadataOffset = module.Reader.PEHeaders.MetadataStartOffset;
this.module = module;
this.metadata = module.Metadata;
this.assembly = metadata.GetAssemblyDefinition();
}
}
public override void Decompile(Language language, ITextOutput output, DecompilationOptions options)
{
language.WriteCommentLine(output, "Assembly");
}
}
}

116
ILSpy/Metadata/CorTables/ConstantTableTreeNode.cs

@ -0,0 +1,116 @@ @@ -0,0 +1,116 @@
// 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.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;
namespace ICSharpCode.ILSpy.Metadata
{
internal class ConstantTableTreeNode : ILSpyTreeNode
{
private PEFile module;
public ConstantTableTreeNode(PEFile module)
{
this.module = module;
}
public override object Text => $"0B Constant ({module.Metadata.GetTableRowCount(TableIndex.Constant)})";
public override object Icon => Images.Literal;
public override bool View(DecompilerTextView textView)
{
ListView view = Helpers.CreateListView("ConstantsView");
var metadata = module.Metadata;
var list = new List<ConstantEntry>();
for (int row = 1; row <= module.Metadata.GetTableRowCount(TableIndex.Constant); row++) {
list.Add(new ConstantEntry(module, MetadataTokens.ConstantHandle(row)));
}
view.ItemsSource = list;
textView.ShowContent(new[] { this }, view);
return true;
}
struct ConstantEntry
{
readonly int metadataOffset;
readonly PEFile module;
readonly MetadataReader metadata;
readonly EntityHandle handle;
readonly Constant constant;
public int RID => MetadataTokens.GetRowNumber(handle);
public int Token => MetadataTokens.GetToken(handle);
public int Offset => metadataOffset
+ metadata.GetTableMetadataOffset(TableIndex.Constant)
+ metadata.GetTableRowSize(TableIndex.Constant) * (RID - 1);
public int Type => (int)constant.TypeCode;
public string TypeTooltip => constant.TypeCode.ToString();
public int ParentHandle => MetadataTokens.GetToken(constant.Parent);
public string ParentTooltip {
get {
ITextOutput output = new PlainTextOutput();
var context = new Decompiler.Metadata.GenericContext(default(TypeDefinitionHandle), module);
constant.Parent.WriteTo(module, output, context);
return output.ToString();
}
}
public int Value => MetadataTokens.GetHeapOffset(constant.Value);
public string ValueTooltip {
get {
return null;
}
}
public ConstantEntry(PEFile module, ConstantHandle handle)
{
this.metadataOffset = module.Reader.PEHeaders.MetadataStartOffset;
this.module = module;
this.metadata = module.Metadata;
this.handle = handle;
this.constant = metadata.GetConstant(handle);
}
}
public override void Decompile(Language language, ITextOutput output, DecompilationOptions options)
{
language.WriteCommentLine(output, "Constants");
}
}
}

127
ILSpy/Metadata/CorTables/CustomAttributeTableTreeNode.cs

@ -0,0 +1,127 @@ @@ -0,0 +1,127 @@
// 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;
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
{
private PEFile module;
public CustomAttributeTableTreeNode(PEFile module)
{
this.module = module;
}
public override object Text => $"0C CustomAttribute ({module.Metadata.GetTableRowCount(TableIndex.CustomAttribute)})";
public override object Icon => Images.Literal;
public override bool View(DecompilerTextView textView)
{
ListView view = Helpers.CreateListView("CustomAttributesView");
var metadata = module.Metadata;
var list = new List<CustomAttributeEntry>();
foreach (var row in metadata.CustomAttributes) {
list.Add(new CustomAttributeEntry(module, row));
}
view.ItemsSource = list;
textView.ShowContent(new[] { this }, view);
return true;
}
struct CustomAttributeEntry
{
readonly int metadataOffset;
readonly PEFile module;
readonly MetadataReader metadata;
readonly CustomAttributeHandle handle;
readonly CustomAttribute customAttr;
public int RID => MetadataTokens.GetRowNumber(handle);
public int Token => MetadataTokens.GetToken(handle);
public int Offset => metadataOffset
+ metadata.GetTableMetadataOffset(TableIndex.CustomAttribute)
+ metadata.GetTableRowSize(TableIndex.CustomAttribute) * (RID - 1);
public int ParentHandle => MetadataTokens.GetToken(customAttr.Parent);
public string ParentTooltip {
get {
ITextOutput output = new PlainTextOutput();
var context = new GenericContext(default(TypeDefinitionHandle), module);
customAttr.Parent.WriteTo(module, output, context);
return output.ToString();
}
}
public int ConstructorHandle => MetadataTokens.GetToken(customAttr.Constructor);
public string ConstructorTooltip {
get {
ITextOutput output = new PlainTextOutput();
var context = new GenericContext(default(TypeDefinitionHandle), module);
customAttr.Constructor.WriteTo(module, output, context);
return output.ToString();
}
}
public int ValueHandle => MetadataTokens.GetHeapOffset(customAttr.Value);
public string ValueTooltip {
get {
return null;
}
}
public CustomAttributeEntry(PEFile module, CustomAttributeHandle handle)
{
this.metadataOffset = module.Reader.PEHeaders.MetadataStartOffset;
this.module = module;
this.metadata = module.Metadata;
this.handle = handle;
this.customAttr = metadata.GetCustomAttribute(handle);
}
}
public override void Decompile(Language language, ITextOutput output, DecompilationOptions options)
{
language.WriteCommentLine(output, "CustomAttributes");
}
}
}

124
ILSpy/Metadata/CorTables/DeclSecurityTableTreeNode.cs

@ -0,0 +1,124 @@ @@ -0,0 +1,124 @@
// 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;
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
{
private PEFile module;
public DeclSecurityTableTreeNode(PEFile module)
{
this.module = module;
}
public override object Text => $"0E DeclSecurity ({module.Metadata.GetTableRowCount(TableIndex.DeclSecurity)})";
public override object Icon => Images.Literal;
public override bool View(DecompilerTextView textView)
{
ListView view = Helpers.CreateListView("DeclSecurityAttrsView");
var metadata = module.Metadata;
var list = new List<DeclSecurityEntry>();
foreach (var row in metadata.DeclarativeSecurityAttributes) {
list.Add(new DeclSecurityEntry(module, row));
}
view.ItemsSource = list;
textView.ShowContent(new[] { this }, view);
return true;
}
struct DeclSecurityEntry
{
readonly int metadataOffset;
readonly PEFile module;
readonly MetadataReader metadata;
readonly DeclarativeSecurityAttributeHandle handle;
readonly DeclarativeSecurityAttribute declSecAttr;
public int RID => MetadataTokens.GetRowNumber(handle);
public int Token => MetadataTokens.GetToken(handle);
public int Offset => metadataOffset
+ metadata.GetTableMetadataOffset(TableIndex.DeclSecurity)
+ metadata.GetTableRowSize(TableIndex.DeclSecurity) * (RID - 1);
public int ParentHandle => MetadataTokens.GetToken(declSecAttr.Parent);
public string ParentTooltip {
get {
ITextOutput output = new PlainTextOutput();
var context = new GenericContext(default(TypeDefinitionHandle), module);
declSecAttr.Parent.WriteTo(module, output, context);
return output.ToString();
}
}
public int Action => (int)declSecAttr.Action;
public string ActionTooltip {
get {
return null;
}
}
public int PermissionSetHandle => MetadataTokens.GetHeapOffset(declSecAttr.PermissionSet);
public string PermissionSetTooltip {
get {
return null;
}
}
public DeclSecurityEntry(PEFile module, DeclarativeSecurityAttributeHandle handle)
{
this.metadataOffset = module.Reader.PEHeaders.MetadataStartOffset;
this.module = module;
this.metadata = module.Metadata;
this.handle = handle;
this.declSecAttr = metadata.GetDeclarativeSecurityAttribute(handle);
}
}
public override void Decompile(Language language, ITextOutput output, DecompilationOptions options)
{
language.WriteCommentLine(output, "DeclSecurityAttrs");
}
}
}

117
ILSpy/Metadata/CorTables/EventTableTreeNode.cs

@ -0,0 +1,117 @@ @@ -0,0 +1,117 @@
// 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;
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.Metadata;
using ICSharpCode.Decompiler.TypeSystem;
using ICSharpCode.ILSpy.TextView;
using ICSharpCode.ILSpy.TreeNodes;
namespace ICSharpCode.ILSpy.Metadata
{
internal class EventTableTreeNode : ILSpyTreeNode
{
private PEFile module;
public EventTableTreeNode(PEFile module)
{
this.module = module;
}
public override object Text => $"14 Event ({module.Metadata.GetTableRowCount(TableIndex.Event)})";
public override object Icon => Images.Literal;
public override bool View(DecompilerTextView textView)
{
ListView view = Helpers.CreateListView("EventDefsView");
var metadata = module.Metadata;
var list = new List<EventDefEntry>();
foreach (var row in metadata.EventDefinitions)
list.Add(new EventDefEntry(module, row));
view.ItemsSource = list;
textView.ShowContent(new[] { this }, view);
return true;
}
struct EventDefEntry : IMemberTreeNode
{
readonly int metadataOffset;
readonly PEFile module;
readonly MetadataReader metadata;
readonly EventDefinitionHandle handle;
readonly EventDefinition eventDef;
public int RID => MetadataTokens.GetRowNumber(handle);
public int Token => MetadataTokens.GetToken(handle);
public int Offset => metadataOffset
+ metadata.GetTableMetadataOffset(TableIndex.Event)
+ metadata.GetTableRowSize(TableIndex.Event) * (RID - 1);
public int Attributes => (int)eventDef.Attributes;
public string AttributesTooltip => null; //Helpers.AttributesToString(EventDef.Attributes);
public int NameStringHandle => MetadataTokens.GetHeapOffset(eventDef.Name);
public string Name => metadata.GetString(eventDef.Name);
IEntity IMemberTreeNode.Member => ((MetadataModule)module.GetTypeSystemOrNull()?.MainModule).GetDefinition(handle);
public int Type => MetadataTokens.GetToken(eventDef.Type);
public string TypeTooltip {
get {
ITextOutput output = new PlainTextOutput();
eventDef.Type.WriteTo(module, output, Decompiler.Metadata.GenericContext.Empty);
return output.ToString();
}
}
public EventDefEntry(PEFile module, EventDefinitionHandle handle)
{
this.metadataOffset = module.Reader.PEHeaders.MetadataStartOffset;
this.module = module;
this.metadata = module.Metadata;
this.handle = handle;
this.eventDef = metadata.GetEventDefinition(handle);
}
}
public override void Decompile(Language language, ITextOutput output, DecompilationOptions options)
{
language.WriteCommentLine(output, "EventDefs");
}
}
}

28
ILSpy/Metadata/ExportedTypeTableTreeNode.cs → ILSpy/Metadata/CorTables/ExportedTypeTableTreeNode.cs

@ -1,4 +1,22 @@ @@ -1,4 +1,22 @@
using System;
// 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;
using System.Collections.Generic;
using System.Linq;
using System.Reflection;
@ -69,13 +87,13 @@ namespace ICSharpCode.ILSpy.Metadata @@ -69,13 +87,13 @@ namespace ICSharpCode.ILSpy.Metadata
public int TypeDefId => type.GetTypeDefinitionId();
public int TypeName => MetadataTokens.GetHeapOffset(type.Name);
public int TypeNameStringHandle => MetadataTokens.GetHeapOffset(type.Name);
public string TypeNameTooltip => metadata.GetString(type.Name);
public string TypeName => metadata.GetString(type.Name);
public int TypeNamespace => MetadataTokens.GetHeapOffset(type.Namespace);
public int TypeNamespaceStringHandle => MetadataTokens.GetHeapOffset(type.Namespace);
public string TypeNamespaceTooltip => metadata.GetString(type.Namespace);
public string TypeNamespace => metadata.GetString(type.Namespace);
public int Implementation => MetadataTokens.GetToken(type.Implementation);

119
ILSpy/Metadata/CorTables/FieldLayoutTableTreeNode.cs

@ -0,0 +1,119 @@ @@ -0,0 +1,119 @@
// 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;
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
{
private PEFile module;
public FieldLayoutTableTreeNode(PEFile module)
{
this.module = module;
}
public override object Text => $"10 FieldLayout ({module.Metadata.GetTableRowCount(TableIndex.FieldLayout)})";
public override object Icon => Images.Literal;
public override bool View(DecompilerTextView textView)
{
ListView view = Helpers.CreateListView("FieldLayoutsView");
var metadata = module.Metadata;
var list = new List<FieldLayoutEntry>();
foreach (var row in metadata.GetFieldLayouts()) {
FieldDefinition d = default;
d.GetOffset();
list.Add(new FieldLayoutEntry(module, row));
}
view.ItemsSource = list;
textView.ShowContent(new[] { this }, view);
return true;
}
struct FieldLayoutEntry
{
readonly int metadataOffset;
readonly PEFile module;
readonly MetadataReader metadata;
readonly EntityHandle handle;
//readonly fieldDef;
public int RID => MetadataTokens.GetRowNumber(handle);
public int Token => MetadataTokens.GetToken(handle);
public int Offset => metadataOffset
+ metadata.GetTableMetadataOffset(TableIndex.FieldLayout)
+ metadata.GetTableRowSize(TableIndex.FieldLayout) * (RID - 1);
//public int Attributes => (int)fieldDef.Attributes;
//public string AttributesTooltip => null; //Helpers.AttributesToString(fieldDef.Attributes);
//public int NameStringHandle => MetadataTokens.GetHeapOffset(fieldDef.Name);
//public string Name => metadata.GetString(fieldDef.Name);
//public int Signature => MetadataTokens.GetHeapOffset(fieldDef.Signature);
public string SignatureTooltip {
get {
ITextOutput output = new PlainTextOutput();
var context = new Decompiler.Metadata.GenericContext(default(TypeDefinitionHandle), module);
((EntityHandle)handle).WriteTo(module, output, context);
return output.ToString();
}
}
public FieldLayoutEntry(PEFile module, EntityHandle handle)
{
this.metadataOffset = module.Reader.PEHeaders.MetadataStartOffset;
this.module = module;
this.metadata = module.Metadata;
this.handle = handle;
//this.fieldDef = metadata.GetFieldLayoutinition(handle);
}
}
public override void Decompile(Language language, ITextOutput output, DecompilationOptions options)
{
language.WriteCommentLine(output, "FieldLayouts");
}
}
}

20
ILSpy/Metadata/FieldTableTreeNode.cs → ILSpy/Metadata/CorTables/FieldTableTreeNode.cs

@ -1,4 +1,22 @@ @@ -1,4 +1,22 @@
using System;
// 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;
using System.Collections.Generic;
using System.Linq;
using System.Reflection.Metadata;

116
ILSpy/Metadata/CorTables/FileTableTreeNode.cs

@ -0,0 +1,116 @@ @@ -0,0 +1,116 @@
// 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;
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
{
private PEFile module;
public FileTableTreeNode(PEFile module)
{
this.module = module;
}
public override object Text => $"26 File ({module.Metadata.GetTableRowCount(TableIndex.File)})";
public override object Icon => Images.Literal;
public override bool View(DecompilerTextView textView)
{
ListView view = Helpers.CreateListView("FilesView");
var metadata = module.Metadata;
var list = new List<FileEntry>();
foreach (var row in metadata.AssemblyFiles) {
list.Add(new FileEntry(module, row));
}
view.ItemsSource = list;
textView.ShowContent(new[] { this }, view);
return true;
}
struct FileEntry
{
readonly int metadataOffset;
readonly PEFile module;
readonly MetadataReader metadata;
readonly AssemblyFileHandle handle;
readonly AssemblyFile assemblyFile;
public int RID => MetadataTokens.GetRowNumber(handle);
public int Token => MetadataTokens.GetToken(handle);
public int Offset => metadataOffset
+ metadata.GetTableMetadataOffset(TableIndex.File)
+ metadata.GetTableRowSize(TableIndex.File) * (RID - 1);
public int Attributes => assemblyFile.ContainsMetadata ? 1 : 0;
public string AttributesTooltip => assemblyFile.ContainsMetadata ? "ContainsMetaData" : "ContainsNoMetaData";
public int NameStringHandle => MetadataTokens.GetHeapOffset(assemblyFile.Name);
public string Name => metadata.GetString(assemblyFile.Name);
public int HashValue => MetadataTokens.GetHeapOffset(assemblyFile.HashValue);
public string HashValueTooltip {
get {
if (assemblyFile.HashValue.IsNil)
return null;
System.Collections.Immutable.ImmutableArray<byte> token = metadata.GetBlobContent(assemblyFile.HashValue);
return token.ToHexString(token.Length);
}
}
public FileEntry(PEFile module, AssemblyFileHandle handle)
{
this.metadataOffset = module.Reader.PEHeaders.MetadataStartOffset;
this.module = module;
this.metadata = module.Metadata;
this.handle = handle;
this.assemblyFile = metadata.GetAssemblyFile(handle);
}
}
public override void Decompile(Language language, ITextOutput output, DecompilationOptions options)
{
language.WriteCommentLine(output, "Files");
}
}
}

120
ILSpy/Metadata/CorTables/GenericParamConstraintTableTreeNode.cs

@ -0,0 +1,120 @@ @@ -0,0 +1,120 @@
// 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;
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
{
private PEFile module;
public GenericParamConstraintTableTreeNode(PEFile module)
{
this.module = module;
}
public override object Text => $"2C GenericParamConstraint ({module.Metadata.GetTableRowCount(TableIndex.GenericParamConstraint)})";
public override object Icon => Images.Literal;
public override bool View(DecompilerTextView textView)
{
ListView view = Helpers.CreateListView("GenericParamConstraintsView");
var metadata = module.Metadata;
var list = new List<GenericParamConstraintEntry>();
for (int row = 1; row <= module.Metadata.GetTableRowCount(TableIndex.GenericParamConstraint); row++) {
list.Add(new GenericParamConstraintEntry(module, MetadataTokens.GenericParameterConstraintHandle(row)));
}
view.ItemsSource = list;
textView.ShowContent(new[] { this }, view);
return true;
}
struct GenericParamConstraintEntry
{
readonly int metadataOffset;
readonly PEFile module;
readonly MetadataReader metadata;
readonly GenericParameterConstraintHandle handle;
readonly GenericParameterConstraint genericParamConstraint;
public int RID => MetadataTokens.GetRowNumber(handle);
public int Token => MetadataTokens.GetToken(handle);
public int Offset => metadataOffset
+ metadata.GetTableMetadataOffset(TableIndex.GenericParamConstraint)
+ metadata.GetTableRowSize(TableIndex.GenericParamConstraint) * (RID-1);
public int OwnerHandle => MetadataTokens.GetToken(genericParamConstraint.Parameter);
public string Owner {
get {
ITextOutput output = new PlainTextOutput();
((EntityHandle)genericParamConstraint.Parameter).WriteTo(module, output, GenericContext.Empty);
return output.ToString();
}
}
public int Type => MetadataTokens.GetToken(genericParamConstraint.Type);
public string TypeTooltip {
get {
ITextOutput output = new PlainTextOutput();
genericParamConstraint.Type.WriteTo(module, output, GenericContext.Empty);
return output.ToString();
}
}
public GenericParamConstraintEntry(PEFile module, GenericParameterConstraintHandle handle)
{
this.metadataOffset = module.Reader.PEHeaders.MetadataStartOffset;
this.module = module;
this.metadata = module.Metadata;
this.handle = handle;
this.genericParamConstraint = metadata.GetGenericParameterConstraint(handle);
}
}
public override void Decompile(Language language, ITextOutput output, DecompilationOptions options)
{
language.WriteCommentLine(output, "GenericParamConstraints");
}
}
}

120
ILSpy/Metadata/CorTables/GenericParamTableTreeNode.cs

@ -0,0 +1,120 @@ @@ -0,0 +1,120 @@
// 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;
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
{
private PEFile module;
public GenericParamTableTreeNode(PEFile module)
{
this.module = module;
}
public override object Text => $"2A GenericParam ({module.Metadata.GetTableRowCount(TableIndex.GenericParam)})";
public override object Icon => Images.Literal;
public override bool View(DecompilerTextView textView)
{
ListView view = Helpers.CreateListView("GenericParamsView");
var metadata = module.Metadata;
var list = new List<GenericParamEntry>();
for (int row = 1; row <= module.Metadata.GetTableRowCount(TableIndex.GenericParam); row++) {
list.Add(new GenericParamEntry(module, MetadataTokens.GenericParameterHandle(row)));
}
view.ItemsSource = list;
textView.ShowContent(new[] { this }, view);
return true;
}
struct GenericParamEntry
{
readonly int metadataOffset;
readonly PEFile module;
readonly MetadataReader metadata;
readonly GenericParameterHandle handle;
readonly GenericParameter genericParam;
public int RID => MetadataTokens.GetRowNumber(handle);
public int Token => MetadataTokens.GetToken(handle);
public int Offset => metadataOffset
+ metadata.GetTableMetadataOffset(TableIndex.GenericParam)
+ metadata.GetTableRowSize(TableIndex.GenericParam) * (RID-1);
public int Number => genericParam.Index;
public int Attributes => (int)genericParam.Attributes;
public string AttributesTooltip => null; // TODO
public int OwnerHandle => MetadataTokens.GetToken(genericParam.Parent);
public string Owner {
get {
ITextOutput output = new PlainTextOutput();
genericParam.Parent.WriteTo(module, output, GenericContext.Empty);
return output.ToString();
}
}
public int NameStringHandle => MetadataTokens.GetHeapOffset(genericParam.Name);
public string Name => metadata.GetString(genericParam.Name);
public GenericParamEntry(PEFile module, GenericParameterHandle handle)
{
this.metadataOffset = module.Reader.PEHeaders.MetadataStartOffset;
this.module = module;
this.metadata = module.Metadata;
this.handle = handle;
this.genericParam = metadata.GetGenericParameter(handle);
}
}
public override void Decompile(Language language, ITextOutput output, DecompilationOptions options)
{
language.WriteCommentLine(output, "GenericParams");
}
}
}

118
ILSpy/Metadata/CorTables/ManifestResourceTableTreeNode.cs

@ -0,0 +1,118 @@ @@ -0,0 +1,118 @@
// 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;
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 ManifestResourceTableTreeNode : ILSpyTreeNode
{
private PEFile module;
public ManifestResourceTableTreeNode(PEFile module)
{
this.module = module;
}
public override object Text => $"28 ManifestResource ({module.Metadata.GetTableRowCount(TableIndex.ManifestResource)})";
public override object Icon => Images.Literal;
public override bool View(DecompilerTextView textView)
{
ListView view = Helpers.CreateListView("ManifestResourcesView");
var metadata = module.Metadata;
var list = new List<ManifestResourceEntry>();
foreach (var row in metadata.ManifestResources) {
list.Add(new ManifestResourceEntry(module, row));
}
view.ItemsSource = list;
textView.ShowContent(new[] { this }, view);
return true;
}
struct ManifestResourceEntry
{
readonly int metadataOffset;
readonly PEFile module;
readonly MetadataReader metadata;
readonly ManifestResourceHandle handle;
readonly ManifestResource manifestResource;
public int RID => MetadataTokens.GetRowNumber(handle);
public int Token => MetadataTokens.GetToken(handle);
public int Offset => metadataOffset
+ metadata.GetTableMetadataOffset(TableIndex.ManifestResource)
+ metadata.GetTableRowSize(TableIndex.ManifestResource) * (RID - 1);
public int Attributes => (int)manifestResource.Attributes;
public string AttributesTooltip => null; // TODO : Helpers.AttributesToString(manifestResource.Attributes);
public int NameStringHandle => MetadataTokens.GetHeapOffset(manifestResource.Name);
public string Name => metadata.GetString(manifestResource.Name);
public int ImplementationHandle => MetadataTokens.GetToken(manifestResource.Implementation);
public string ImplementationTooltip {
get {
if (manifestResource.Implementation.IsNil)
return null;
ITextOutput output = new PlainTextOutput();
var context = new GenericContext(default(TypeDefinitionHandle), module);
manifestResource.Implementation.WriteTo(module, output, context);
return output.ToString();
}
}
public ManifestResourceEntry(PEFile module, ManifestResourceHandle handle)
{
this.metadataOffset = module.Reader.PEHeaders.MetadataStartOffset;
this.module = module;
this.metadata = module.Metadata;
this.handle = handle;
this.manifestResource = metadata.GetManifestResource(handle);
}
}
public override void Decompile(Language language, ITextOutput output, DecompilationOptions options)
{
language.WriteCommentLine(output, "ManifestResources");
}
}
}

122
ILSpy/Metadata/CorTables/MemberRefTableTreeNode.cs

@ -0,0 +1,122 @@ @@ -0,0 +1,122 @@
// 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;
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.Metadata;
using ICSharpCode.Decompiler.TypeSystem;
using ICSharpCode.ILSpy.TextView;
using ICSharpCode.ILSpy.TreeNodes;
namespace ICSharpCode.ILSpy.Metadata
{
internal class MemberRefTableTreeNode : ILSpyTreeNode
{
private PEFile module;
public MemberRefTableTreeNode(PEFile module)
{
this.module = module;
}
public override object Text => $"0A MemberRef ({module.Metadata.GetTableRowCount(TableIndex.MemberRef)})";
public override object Icon => Images.Literal;
public override bool View(DecompilerTextView textView)
{
ListView view = Helpers.CreateListView("MemberRefsView");
var metadata = module.Metadata;
var list = new List<MemberRefEntry>();
foreach (var row in metadata.MemberReferences)
list.Add(new MemberRefEntry(module, row));
view.ItemsSource = list;
textView.ShowContent(new[] { this }, view);
return true;
}
struct MemberRefEntry
{
readonly int metadataOffset;
readonly PEFile module;
readonly MetadataReader metadata;
readonly MemberReferenceHandle handle;
readonly MemberReference memberRef;
public int RID => MetadataTokens.GetRowNumber(handle);
public int Token => MetadataTokens.GetToken(handle);
public int Offset => metadataOffset
+ metadata.GetTableMetadataOffset(TableIndex.MemberRef)
+ metadata.GetTableRowSize(TableIndex.MemberRef) * (RID - 1);
public int ParentHandle => MetadataTokens.GetToken(memberRef.Parent);
public string ParentTooltip {
get {
ITextOutput output = new PlainTextOutput();
memberRef.Parent.WriteTo(module, output, Decompiler.Metadata.GenericContext.Empty);
return output.ToString();
}
}
public int NameStringHandle => MetadataTokens.GetHeapOffset(memberRef.Name);
public string Name => metadata.GetString(memberRef.Name);
public int Signature => MetadataTokens.GetHeapOffset(memberRef.Signature);
public string SignatureTooltip {
get {
ITextOutput output = new PlainTextOutput();
var context = new Decompiler.Metadata.GenericContext(default(TypeDefinitionHandle), module);
((EntityHandle)handle).WriteTo(module, output, context);
return output.ToString();
}
}
public MemberRefEntry(PEFile module, MemberReferenceHandle handle)
{
this.metadataOffset = module.Reader.PEHeaders.MetadataStartOffset;
this.module = module;
this.metadata = module.Metadata;
this.handle = handle;
this.memberRef = metadata.GetMemberReference(handle);
}
}
public override void Decompile(Language language, ITextOutput output, DecompilationOptions options)
{
language.WriteCommentLine(output, "MemberRefs");
}
}
}

126
ILSpy/Metadata/CorTables/MethodSemanticsTableTreeNode.cs

@ -0,0 +1,126 @@ @@ -0,0 +1,126 @@
// 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;
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.Metadata;
using ICSharpCode.Decompiler.TypeSystem;
using ICSharpCode.ILSpy.TextView;
using ICSharpCode.ILSpy.TreeNodes;
using System.Reflection;
namespace ICSharpCode.ILSpy.Metadata
{
internal class MethodSemanticsTableTreeNode : ILSpyTreeNode
{
private PEFile module;
public MethodSemanticsTableTreeNode(PEFile module)
{
this.module = module;
}
public override object Text => $"18 MethodSemantics ({module.Metadata.GetTableRowCount(TableIndex.MethodSemantics)})";
public override object Icon => Images.Literal;
public override bool View(DecompilerTextView textView)
{
ListView view = Helpers.CreateListView("MethodSemanticsView");
var metadata = module.Metadata;
var list = new List<MethodSemanticsEntry>();
foreach (var row in metadata.GetMethodSemantics())
list.Add(new MethodSemanticsEntry(module, row.Handle, row.Semantics, row.Method, row.Association));
view.ItemsSource = list;
textView.ShowContent(new[] { this }, view);
return true;
}
struct MethodSemanticsEntry
{
readonly int metadataOffset;
readonly PEFile module;
readonly MetadataReader metadata;
readonly Handle handle;
readonly MethodSemanticsAttributes semantics;
readonly MethodDefinitionHandle method;
readonly EntityHandle association;
public int RID => MetadataTokens.GetToken(handle) & 0xFFFFFF;
public int Token => MetadataTokens.GetToken(handle);
public int Offset => metadataOffset
+ metadata.GetTableMetadataOffset(TableIndex.MethodDef)
+ metadata.GetTableRowSize(TableIndex.MethodDef) * (RID - 1);
public int Semantics => (int)semantics;
public string SemanticsTooltip => semantics.ToString();
public int MethodHandle => MetadataTokens.GetToken(method);
public string Method {
get {
ITextOutput output = new PlainTextOutput();
((EntityHandle)method).WriteTo(module, output, Decompiler.Metadata.GenericContext.Empty);
return output.ToString();
}
}
public int AssociationHandle => MetadataTokens.GetToken(association);
public string Association {
get {
ITextOutput output = new PlainTextOutput();
association.WriteTo(module, output, Decompiler.Metadata.GenericContext.Empty);
return output.ToString();
}
}
public MethodSemanticsEntry(PEFile module, Handle handle, MethodSemanticsAttributes semantics, MethodDefinitionHandle method, EntityHandle association)
{
this.metadataOffset = module.Reader.PEHeaders.MetadataStartOffset;
this.module = module;
this.metadata = module.Metadata;
this.handle = handle;
this.semantics = semantics;
this.method = method;
this.association = association;
}
}
public override void Decompile(Language language, ITextOutput output, DecompilationOptions options)
{
language.WriteCommentLine(output, "MethodDefs");
}
}
}

128
ILSpy/Metadata/CorTables/MethodSpecTableTreeNode.cs

@ -0,0 +1,128 @@ @@ -0,0 +1,128 @@
// 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;
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
{
private PEFile module;
public MethodSpecTableTreeNode(PEFile module)
{
this.module = module;
}
public override object Text => $"2B MethodSpec ({module.Metadata.GetTableRowCount(TableIndex.MethodSpec)})";
public override object Icon => Images.Literal;
public override bool View(DecompilerTextView textView)
{
ListView view = Helpers.CreateListView("MethodSpecsView");
var metadata = module.Metadata;
var list = new List<MethodSpecEntry>();
foreach (var row in metadata.GetMethodSpecifications())
list.Add(new MethodSpecEntry(module, row));
view.ItemsSource = list;
textView.ShowContent(new[] { this }, view);
return true;
}
struct MethodSpecEntry
{
readonly int metadataOffset;
readonly PEFile module;
readonly MetadataReader metadata;
readonly MethodSpecificationHandle handle;
readonly MethodSpecification methodSpec;
public int RID => MetadataTokens.GetRowNumber(handle);
public int Token => MetadataTokens.GetToken(handle);
public int Offset => metadataOffset
+ metadata.GetTableMetadataOffset(TableIndex.MethodSpec)
+ metadata.GetTableRowSize(TableIndex.MethodSpec) * (RID-1);
public int MethodHandle => MetadataTokens.GetToken(methodSpec.Method);
public string Method {
get {
ITextOutput output = new PlainTextOutput();
methodSpec.Method.WriteTo(module, output, GenericContext.Empty);
return output.ToString();
}
}
public int Signature => MetadataTokens.GetHeapOffset(methodSpec.Signature);
public string SignatureTooltip {
get {
ITextOutput output = new PlainTextOutput();
var signature = methodSpec.DecodeSignature(new DisassemblerSignatureProvider(module, output), GenericContext.Empty);
bool first = true;
foreach (var type in signature) {
if (first)
first = false;
else
output.Write(", ");
type(ILNameSyntax.TypeName);
}
return output.ToString();
}
}
public MethodSpecEntry(PEFile module, MethodSpecificationHandle handle)
{
this.metadataOffset = module.Reader.PEHeaders.MetadataStartOffset;
this.module = module;
this.metadata = module.Metadata;
this.handle = handle;
this.methodSpec = metadata.GetMethodSpecification(handle);
}
}
public override void Decompile(Language language, ITextOutput output, DecompilationOptions options)
{
language.WriteCommentLine(output, "MethodSpecs");
}
}
}

20
ILSpy/Metadata/MethodTableTreeNode.cs → ILSpy/Metadata/CorTables/MethodTableTreeNode.cs

@ -1,4 +1,22 @@ @@ -1,4 +1,22 @@
using System;
// 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;
using System.Collections.Generic;
using System.Linq;
using System.Reflection.Metadata;

102
ILSpy/Metadata/CorTables/ModuleRefTableTreeNode.cs

@ -0,0 +1,102 @@ @@ -0,0 +1,102 @@
// 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;
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
{
private PEFile module;
public ModuleRefTableTreeNode(PEFile module)
{
this.module = module;
}
public override object Text => $"1A ModuleRef ({module.Metadata.GetTableRowCount(TableIndex.ModuleRef)})";
public override object Icon => Images.Literal;
public override bool View(DecompilerTextView textView)
{
ListView view = Helpers.CreateListView("ModuleRefsView");
var metadata = module.Metadata;
var list = new List<ModuleRefEntry>();
foreach (var row in metadata.GetModuleReferences())
list.Add(new ModuleRefEntry(module, row));
view.ItemsSource = list;
textView.ShowContent(new[] { this }, view);
return true;
}
struct ModuleRefEntry
{
readonly int metadataOffset;
readonly PEFile module;
readonly MetadataReader metadata;
readonly ModuleReferenceHandle handle;
readonly ModuleReference moduleRef;
public int RID => MetadataTokens.GetRowNumber(handle);
public int Token => MetadataTokens.GetToken(handle);
public int Offset => metadataOffset
+ metadata.GetTableMetadataOffset(TableIndex.ModuleRef)
+ metadata.GetTableRowSize(TableIndex.ModuleRef) * (RID-1);
public int NameStringHandle => MetadataTokens.GetHeapOffset(moduleRef.Name);
public string Name => metadata.GetString(moduleRef.Name);
public ModuleRefEntry(PEFile module, ModuleReferenceHandle handle)
{
this.metadataOffset = module.Reader.PEHeaders.MetadataStartOffset;
this.module = module;
this.metadata = module.Metadata;
this.handle = handle;
this.moduleRef = metadata.GetModuleReference(handle);
}
}
public override void Decompile(Language language, ITextOutput output, DecompilationOptions options)
{
language.WriteCommentLine(output, "ModuleRefs");
}
}
}

115
ILSpy/Metadata/CorTables/ModuleTableTreeNode.cs

@ -0,0 +1,115 @@ @@ -0,0 +1,115 @@
// 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;
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
{
private PEFile module;
public ModuleTableTreeNode(PEFile module)
{
this.module = module;
}
public override object Text => $"00 Module ({module.Metadata.GetTableRowCount(TableIndex.Module)})";
public override object Icon => Images.Literal;
public override bool View(DecompilerTextView textView)
{
ListView view = Helpers.CreateListView("ModulesView");
var metadata = module.Metadata;
var list = new List<ModuleEntry>();
list.Add(new ModuleEntry(module, EntityHandle.ModuleDefinition));
view.ItemsSource = list;
textView.ShowContent(new[] { this }, view);
return true;
}
struct ModuleEntry
{
readonly int metadataOffset;
readonly PEFile module;
readonly MetadataReader metadata;
readonly ModuleDefinitionHandle handle;
readonly ModuleDefinition moduleDef;
public int RID => MetadataTokens.GetRowNumber(handle);
public int Token => MetadataTokens.GetToken(handle);
public int Offset => metadataOffset
+ metadata.GetTableMetadataOffset(TableIndex.Module)
+ metadata.GetTableRowSize(TableIndex.Module) * (RID-1);
public int Generation => moduleDef.Generation;
public int NameStringHandle => MetadataTokens.GetHeapOffset(moduleDef.Name);
public string Name => metadata.GetString(moduleDef.Name);
public int Mvid => MetadataTokens.GetHeapOffset(moduleDef.Mvid);
public string MvidTooltip => metadata.GetGuid(moduleDef.Mvid).ToString();
public int GenerationId => MetadataTokens.GetHeapOffset(moduleDef.GenerationId);
public string GenerationIdTooltip => moduleDef.GenerationId.IsNil ? null : metadata.GetGuid(moduleDef.GenerationId).ToString();
public int BaseGenerationId => MetadataTokens.GetHeapOffset(moduleDef.BaseGenerationId);
public string BaseGenerationIdTooltip => moduleDef.BaseGenerationId.IsNil ? null : metadata.GetGuid(moduleDef.BaseGenerationId).ToString();
public ModuleEntry(PEFile module, ModuleDefinitionHandle handle)
{
this.metadataOffset = module.Reader.PEHeaders.MetadataStartOffset;
this.module = module;
this.metadata = module.Metadata;
this.handle = handle;
this.moduleDef = metadata.GetModuleDefinition();
}
}
public override void Decompile(Language language, ITextOutput output, DecompilationOptions options)
{
language.WriteCommentLine(output, "Modules");
}
}
}

111
ILSpy/Metadata/CorTables/ParamTableTreeNode.cs

@ -0,0 +1,111 @@ @@ -0,0 +1,111 @@
// 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;
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
{
private PEFile module;
public ParamTableTreeNode(PEFile module)
{
this.module = module;
}
public override object Text => $"08 Param ({module.Metadata.GetTableRowCount(TableIndex.Param)})";
public override object Icon => Images.Literal;
public override bool View(DecompilerTextView textView)
{
ListView view = Helpers.CreateListView("ParamsView");
var metadata = module.Metadata;
var list = new List<ParamEntry>();
for (int row = 1; row <= module.Metadata.GetTableRowCount(TableIndex.Param); row++) {
list.Add(new ParamEntry(module, MetadataTokens.ParameterHandle(row)));
}
view.ItemsSource = list;
textView.ShowContent(new[] { this }, view);
return true;
}
struct ParamEntry
{
readonly int metadataOffset;
readonly PEFile module;
readonly MetadataReader metadata;
readonly ParameterHandle handle;
readonly Parameter param;
public int RID => MetadataTokens.GetRowNumber(handle);
public int Token => MetadataTokens.GetToken(handle);
public int Offset => metadataOffset
+ metadata.GetTableMetadataOffset(TableIndex.Param)
+ metadata.GetTableRowSize(TableIndex.Param) * (RID-1);
public int Attributes => (int)param.Attributes;
public string AttributesTooltip => null; //Helpers.AttributesToString(param.Attributes);
public int NameStringHandle => MetadataTokens.GetHeapOffset(param.Name);
public string Name => metadata.GetString(param.Name);
public int Sequence => param.SequenceNumber;
public ParamEntry(PEFile module, ParameterHandle handle)
{
this.metadataOffset = module.Reader.PEHeaders.MetadataStartOffset;
this.module = module;
this.metadata = module.Metadata;
this.handle = handle;
this.param = metadata.GetParameter(handle);
}
}
public override void Decompile(Language language, ITextOutput output, DecompilationOptions options)
{
language.WriteCommentLine(output, "Params");
}
}
}

117
ILSpy/Metadata/CorTables/PropertyTableTreeNode.cs

@ -0,0 +1,117 @@ @@ -0,0 +1,117 @@
// 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;
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.Metadata;
using ICSharpCode.Decompiler.TypeSystem;
using ICSharpCode.ILSpy.TextView;
using ICSharpCode.ILSpy.TreeNodes;
namespace ICSharpCode.ILSpy.Metadata
{
internal class PropertyTableTreeNode : ILSpyTreeNode
{
private PEFile module;
public PropertyTableTreeNode(PEFile module)
{
this.module = module;
}
public override object Text => $"17 Property ({module.Metadata.GetTableRowCount(TableIndex.Property)})";
public override object Icon => Images.Literal;
public override bool View(DecompilerTextView textView)
{
ListView view = Helpers.CreateListView("PropertyDefsView");
var metadata = module.Metadata;
var list = new List<PropertyDefEntry>();
foreach (var row in metadata.PropertyDefinitions)
list.Add(new PropertyDefEntry(module, row));
view.ItemsSource = list;
textView.ShowContent(new[] { this }, view);
return true;
}
struct PropertyDefEntry : IMemberTreeNode
{
readonly int metadataOffset;
readonly PEFile module;
readonly MetadataReader metadata;
readonly PropertyDefinitionHandle handle;
readonly PropertyDefinition propertyDef;
public int RID => MetadataTokens.GetRowNumber(handle);
public int Token => MetadataTokens.GetToken(handle);
public int Offset => metadataOffset
+ metadata.GetTableMetadataOffset(TableIndex.Property)
+ metadata.GetTableRowSize(TableIndex.Property) * (RID - 1);
public int Attributes => (int)propertyDef.Attributes;
public string AttributesTooltip => null; //Helpers.AttributesToString(PropertyDef.Attributes);
public int NameStringHandle => MetadataTokens.GetHeapOffset(propertyDef.Name);
public string Name => metadata.GetString(propertyDef.Name);
IEntity IMemberTreeNode.Member => ((MetadataModule)module.GetTypeSystemOrNull()?.MainModule).GetDefinition(handle);
public int Signature => MetadataTokens.GetHeapOffset(propertyDef.Signature);
public string SignatureTooltip {
get {
ITextOutput output = new PlainTextOutput();
((EntityHandle)handle).WriteTo(module, output, Decompiler.Metadata.GenericContext.Empty);
return output.ToString();
}
}
public PropertyDefEntry(PEFile module, PropertyDefinitionHandle handle)
{
this.metadataOffset = module.Reader.PEHeaders.MetadataStartOffset;
this.module = module;
this.metadata = module.Metadata;
this.handle = handle;
this.propertyDef = metadata.GetPropertyDefinition(handle);
}
}
public override void Decompile(Language language, ITextOutput output, DecompilationOptions options)
{
language.WriteCommentLine(output, "PropertyDefs");
}
}
}

105
ILSpy/Metadata/CorTables/StandAloneSigTableTreeNode.cs

@ -0,0 +1,105 @@ @@ -0,0 +1,105 @@
// 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;
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
{
private PEFile module;
public StandAloneSigTableTreeNode(PEFile module)
{
this.module = module;
}
public override object Text => $"11 StandAloneSig ({module.Metadata.GetTableRowCount(TableIndex.StandAloneSig)})";
public override object Icon => Images.Literal;
public override bool View(DecompilerTextView textView)
{
ListView view = Helpers.CreateListView("StandAloneSigsView");
var metadata = module.Metadata;
var list = new List<StandAloneSigEntry>();
for (int row = 1; row <= module.Metadata.GetTableRowCount(TableIndex.StandAloneSig); row++) {
list.Add(new StandAloneSigEntry(module, MetadataTokens.StandaloneSignatureHandle(row)));
}
view.ItemsSource = list;
textView.ShowContent(new[] { this }, view);
return true;
}
struct StandAloneSigEntry
{
readonly int metadataOffset;
readonly PEFile module;
readonly MetadataReader metadata;
readonly StandaloneSignatureHandle handle;
readonly StandaloneSignature standaloneSig;
public int RID => MetadataTokens.GetRowNumber(handle);
public int Token => MetadataTokens.GetToken(handle);
public int Offset => metadataOffset
+ metadata.GetTableMetadataOffset(TableIndex.StandAloneSig)
+ metadata.GetTableRowSize(TableIndex.StandAloneSig) * (RID - 1);
public int Signature => MetadataTokens.GetHeapOffset(standaloneSig.Signature);
public string SignatureTooltip {
get {
return null;
}
}
public StandAloneSigEntry(PEFile module, StandaloneSignatureHandle handle)
{
this.metadataOffset = module.Reader.PEHeaders.MetadataStartOffset;
this.module = module;
this.metadata = module.Metadata;
this.handle = handle;
this.standaloneSig = metadata.GetStandaloneSignature(handle);
}
}
public override void Decompile(Language language, ITextOutput output, DecompilationOptions options)
{
language.WriteCommentLine(output, "StandAloneSigs");
}
}
}

20
ILSpy/Metadata/TypeDefTableTreeNode.cs → ILSpy/Metadata/CorTables/TypeDefTableTreeNode.cs

@ -1,4 +1,22 @@ @@ -1,4 +1,22 @@
using System;
// 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;
using System.Collections.Generic;
using System.Linq;
using System.Reflection;

135
ILSpy/Metadata/CorTables/TypeRefTableTreeNode.cs

@ -0,0 +1,135 @@ @@ -0,0 +1,135 @@
// 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;
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
{
private PEFile module;
public TypeRefTableTreeNode(PEFile module)
{
this.module = module;
}
public override object Text => $"01 TypeRef ({module.Metadata.GetTableRowCount(TableIndex.TypeRef)})";
public override object Icon => Images.Literal;
public override bool View(DecompilerTextView textView)
{
ListView view = Helpers.CreateListView("TypeRefsView");
var metadata = module.Metadata;
var list = new List<TypeRefEntry>();
foreach (var row in metadata.TypeReferences)
list.Add(new TypeRefEntry(module, row));
view.ItemsSource = list;
textView.ShowContent(new[] { this }, view);
return true;
}
struct TypeRefEntry
{
readonly int metadataOffset;
readonly PEFile module;
readonly MetadataReader metadata;
readonly TypeReferenceHandle handle;
readonly TypeReference typeRef;
public int RID => MetadataTokens.GetRowNumber(handle);
public int Token => MetadataTokens.GetToken(handle);
public int Offset => metadataOffset
+ metadata.GetTableMetadataOffset(TableIndex.TypeRef)
+ metadata.GetTableRowSize(TableIndex.TypeRef) * (RID-1);
public int ResolutionScope => MetadataTokens.GetToken(typeRef.ResolutionScope);
public string ResolutionScopeSignature {
get {
if (typeRef.ResolutionScope.IsNil)
return null;
var output = new PlainTextOutput();
switch (typeRef.ResolutionScope.Kind) {
case HandleKind.ModuleDefinition:
output.Write(metadata.GetString(metadata.GetModuleDefinition().Name));
break;
case HandleKind.ModuleReference:
ModuleReference moduleReference = metadata.GetModuleReference((ModuleReferenceHandle)typeRef.ResolutionScope);
output.Write(metadata.GetString(moduleReference.Name));
break;
case HandleKind.AssemblyReference:
var asmRef = new Decompiler.Metadata.AssemblyReference(module, (AssemblyReferenceHandle)typeRef.ResolutionScope);
output.Write(asmRef.ToString());
break;
default:
typeRef.ResolutionScope.WriteTo(module, output, GenericContext.Empty);
break;
}
return output.ToString();
}
}
public int NameStringHandle => MetadataTokens.GetHeapOffset(typeRef.Name);
public string Name => metadata.GetString(typeRef.Name);
public int NamespaceStringHandle => MetadataTokens.GetHeapOffset(typeRef.Namespace);
public string Namespace => metadata.GetString(typeRef.Namespace);
public TypeRefEntry(PEFile module, TypeReferenceHandle handle)
{
this.metadataOffset = module.Reader.PEHeaders.MetadataStartOffset;
this.module = module;
this.metadata = module.Metadata;
this.handle = handle;
this.typeRef = metadata.GetTypeReference(handle);
}
}
public override void Decompile(Language language, ITextOutput output, DecompilationOptions options)
{
language.WriteCommentLine(output, "TypeRefs");
}
}
}

110
ILSpy/Metadata/CorTables/TypeSpecTableTreeNode.cs

@ -0,0 +1,110 @@ @@ -0,0 +1,110 @@
// 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;
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
{
private PEFile module;
public TypeSpecTableTreeNode(PEFile module)
{
this.module = module;
}
public override object Text => $"1B TypeSpec ({module.Metadata.GetTableRowCount(TableIndex.TypeSpec)})";
public override object Icon => Images.Literal;
public override bool View(DecompilerTextView textView)
{
ListView view = Helpers.CreateListView("TypeSpecsView");
var metadata = module.Metadata;
var list = new List<TypeSpecEntry>();
foreach (var row in metadata.GetTypeSpecifications())
list.Add(new TypeSpecEntry(module, row));
view.ItemsSource = list;
textView.ShowContent(new[] { this }, view);
return true;
}
struct TypeSpecEntry
{
readonly int metadataOffset;
readonly PEFile module;
readonly MetadataReader metadata;
readonly TypeSpecificationHandle handle;
readonly TypeSpecification typeSpec;
public int RID => MetadataTokens.GetRowNumber(handle);
public int Token => MetadataTokens.GetToken(handle);
public int Offset => metadataOffset
+ metadata.GetTableMetadataOffset(TableIndex.TypeSpec)
+ metadata.GetTableRowSize(TableIndex.TypeSpec) * (RID-1);
public int Signature => MetadataTokens.GetHeapOffset(typeSpec.Signature);
public string SignatureTooltip {
get {
ITextOutput output = new PlainTextOutput();
typeSpec.DecodeSignature(new DisassemblerSignatureProvider(module, output), GenericContext.Empty)(ILNameSyntax.Signature);
return output.ToString();
}
}
public TypeSpecEntry(PEFile module, TypeSpecificationHandle handle)
{
this.metadataOffset = module.Reader.PEHeaders.MetadataStartOffset;
this.module = module;
this.metadata = module.Metadata;
this.handle = handle;
this.typeSpec = metadata.GetTypeSpecification(handle);
}
}
public override void Decompile(Language language, ITextOutput output, DecompilationOptions options)
{
language.WriteCommentLine(output, "TypeSpecs");
}
}
}

20
ILSpy/Metadata/DataDirectoriesTreeNode.cs

@ -1,4 +1,22 @@ @@ -1,4 +1,22 @@
using System.Reflection.PortableExecutable;
// 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.PortableExecutable;
using System.Windows.Controls;
using System.Windows.Data;
using ICSharpCode.Decompiler;

20
ILSpy/Metadata/DosHeaderTreeNode.cs

@ -1,4 +1,22 @@ @@ -1,4 +1,22 @@
using System.Collections.Generic;
// 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.Collections.Generic;
using System.Windows.Controls;
using System.Windows.Data;
using ICSharpCode.Decompiler;

73
ILSpy/Metadata/EntityHandleTemplate.cs

@ -1,10 +1,77 @@ @@ -1,10 +1,77 @@
using System.Windows;
// 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.Windows;
using System.Windows.Controls;
using System.Windows.Data;
namespace ICSharpCode.ILSpy.Metadata
{
public class HandleTemplate : DataTemplateSelector
{
public string ValueStringFormat { get; set; } = "X8";
public string ValuePropertyName { get; set; }
public string TooltipPropertyName { get; set; }
private DataTemplate template;
public override DataTemplate SelectTemplate(object item, DependencyObject container)
{
if (template != null)
return template;
var textBlock = new FrameworkElementFactory(typeof(TextBlock), "textBlock");
textBlock.SetValue(FrameworkElement.MarginProperty, new Thickness(3, 1, 0, 0));
textBlock.SetBinding(TextBlock.TextProperty, new Binding(ValuePropertyName) { StringFormat = ValueStringFormat });
var textBox = new FrameworkElementFactory(typeof(TextBox), "textBox");
textBox.SetBinding(TextBox.TextProperty, new Binding(ValuePropertyName) { StringFormat = ValueStringFormat, Mode = BindingMode.OneWay });
textBox.SetValue(TextBox.VisibilityProperty, Visibility.Hidden);
textBox.SetValue(TextBox.IsReadOnlyCaretVisibleProperty, true);
textBox.SetValue(TextBox.IsReadOnlyProperty, true);
if (TooltipPropertyName != null)
textBox.SetBinding(FrameworkElement.ToolTipProperty, new Binding(TooltipPropertyName));
var grid = new FrameworkElementFactory(typeof(Grid));
grid.AppendChild(textBlock);
grid.AppendChild(textBox);
template = new DataTemplate {
VisualTree = grid,
Triggers = {
new Trigger {
Property = UIElement.IsMouseOverProperty,
Value = true,
Setters = {
new Setter(UIElement.VisibilityProperty, Visibility.Visible, "textBox"),
new Setter(UIElement.VisibilityProperty, Visibility.Hidden, "textBlock"),
}
},
new Trigger {
Property = UIElement.IsKeyboardFocusWithinProperty,
Value = true,
Setters = {
new Setter(UIElement.VisibilityProperty, Visibility.Visible, "textBox"),
new Setter(UIElement.VisibilityProperty, Visibility.Hidden, "textBlock"),
}
}
}
};
return template;
}
}
public class EnumTemplate : DataTemplateSelector
{
public string ValuePropertyName { get; set; }
public string TooltipPropertyName { get; set; }
@ -17,9 +84,9 @@ namespace ICSharpCode.ILSpy.Metadata @@ -17,9 +84,9 @@ namespace ICSharpCode.ILSpy.Metadata
return template;
var textBlock = new FrameworkElementFactory(typeof(TextBlock), "textBlock");
textBlock.SetValue(FrameworkElement.MarginProperty, new Thickness(3, 1, 0, 0));
textBlock.SetBinding(TextBlock.TextProperty, new Binding(ValuePropertyName) { StringFormat = "X8" });
textBlock.SetBinding(TextBlock.TextProperty, new Binding(ValuePropertyName));
var textBox = new FrameworkElementFactory(typeof(TextBox), "textBox");
textBox.SetBinding(TextBox.TextProperty, new Binding(ValuePropertyName) { StringFormat = "X8", Mode = BindingMode.OneWay });
textBox.SetBinding(TextBox.TextProperty, new Binding(ValuePropertyName) { Mode = BindingMode.OneWay });
textBox.SetValue(TextBox.VisibilityProperty, Visibility.Hidden);
textBox.SetValue(TextBox.IsReadOnlyCaretVisibleProperty, true);
textBox.SetValue(TextBox.IsReadOnlyProperty, true);

20
ILSpy/Metadata/Helpers.cs

@ -1,4 +1,22 @@ @@ -1,4 +1,22 @@
using System.Collections.Generic;
// 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.Collections.Generic;
using System.Linq;
using System.Reflection;
using System.Reflection.Metadata.Ecma335;

384
ILSpy/Metadata/MetadataTableViews.xaml

@ -50,7 +50,8 @@ @@ -50,7 +50,8 @@
<local:StringHandleTemplate x:Key="NameStringHandleDataTemplate" ValuePropertyName="Name" HandlePropertyName="NameStringHandle" />
<local:StringHandleTemplate x:Key="NamespaceStringHandleDataTemplate" ValuePropertyName="Namespace" HandlePropertyName="NamespaceStringHandle" />
<local:HandleTemplate x:Key="SignatureBlobHandleDataTemplate" TooltipPropertyName="SignatureTooltip" ValuePropertyName="Signature" />
<local:HandleTemplate x:Key="SignatureBlobHandleDataTemplate" TooltipPropertyName="SignatureTooltip" ValuePropertyName="Signature" ValueStringFormat="X" />
<local:HandleTemplate x:Key="ValueBlobHandleDataTemplate" TooltipPropertyName="ValueTooltip" ValuePropertyName="Value" ValueStringFormat="X" />
<GridView x:Key="EntryView" AllowsColumnReorder="False">
<controls:FilterableGridViewColumn Header="Member" SortBy="Member" FilterBy="Member">
@ -139,13 +140,7 @@ @@ -139,13 +140,7 @@
<GridView x:Key="ModulesView" AllowsColumnReorder="False">
<controls:FilterableGridViewColumn Header="RID" SortBy="RID" FilterBy="RID" CellTemplate="{StaticResource RowIDDataTemplate}"/>
<controls:FilterableGridViewColumn Header="Token" SortBy="Token" FilterBy="Token" FilterFormatString="X8" CellTemplateSelector="{StaticResource DefinitionHandleDataTemplate}"/>
<controls:FilterableGridViewColumn Header="Offset" SortBy="Offset" FilterBy="Offset" FilterFormatString="X8">
<controls:FilterableGridViewColumn.CellTemplate>
<DataTemplate>
<TextBlock Text="{Binding Offset, StringFormat=X8}" />
</DataTemplate>
</controls:FilterableGridViewColumn.CellTemplate>
</controls:FilterableGridViewColumn>
<controls:FilterableGridViewColumn Header="Offset" SortBy="Offset" FilterBy="Offset" FilterFormatString="X8" CellTemplate="{StaticResource OffsetDataTemplate}"/>
<controls:FilterableGridViewColumn Header="Generation" SortBy="Generation" FilterBy="Generation">
<controls:FilterableGridViewColumn.CellTemplate>
<DataTemplate>
@ -177,16 +172,17 @@ @@ -177,16 +172,17 @@
</controls:FilterableGridViewColumn>
</GridView>
<GridView x:Key="ModuleRefsView" AllowsColumnReorder="False">
<controls:FilterableGridViewColumn Header="RID" SortBy="RID" FilterBy="RID" CellTemplate="{StaticResource RowIDDataTemplate}"/>
<controls:FilterableGridViewColumn Header="Token" SortBy="Token" FilterBy="Token" FilterFormatString="X8" CellTemplateSelector="{StaticResource DefinitionHandleDataTemplate}"/>
<controls:FilterableGridViewColumn Header="Offset" SortBy="Offset" FilterBy="Offset" FilterFormatString="X8" CellTemplate="{StaticResource OffsetDataTemplate}"/>
<controls:FilterableGridViewColumn Header="Name" SortBy="Name" FilterBy="Name" CellTemplateSelector="{StaticResource NameStringHandleDataTemplate}" />
</GridView>
<GridView x:Key="TypeRefsView" AllowsColumnReorder="False">
<controls:FilterableGridViewColumn Header="RID" SortBy="RID" FilterBy="RID" CellTemplate="{StaticResource RowIDDataTemplate}"/>
<controls:FilterableGridViewColumn Header="Token" SortBy="Token" FilterBy="Token" FilterFormatString="X8" CellTemplateSelector="{StaticResource DefinitionHandleDataTemplate}"/>
<controls:FilterableGridViewColumn Header="Offset" SortBy="Offset" FilterBy="Offset" FilterFormatString="X8">
<controls:FilterableGridViewColumn.CellTemplate>
<DataTemplate>
<TextBlock Text="{Binding Offset, StringFormat=X8}" />
</DataTemplate>
</controls:FilterableGridViewColumn.CellTemplate>
</controls:FilterableGridViewColumn>
<controls:FilterableGridViewColumn Header="Offset" SortBy="Offset" FilterBy="Offset" FilterFormatString="X8" CellTemplate="{StaticResource OffsetDataTemplate}"/>
<controls:FilterableGridViewColumn Header="ResolutionScope" SortBy="ResolutionScope" FilterBy="ResolutionScope">
<controls:FilterableGridViewColumn.CellTemplateSelector>
<local:HandleTemplate ValuePropertyName="ResolutionScope" TooltipPropertyName="ResolutionScopeSignature" />
@ -199,13 +195,7 @@ @@ -199,13 +195,7 @@
<GridView x:Key="TypeDefsView" AllowsColumnReorder="False">
<controls:FilterableGridViewColumn Header="RID" SortBy="RID" FilterBy="RID" CellTemplate="{StaticResource RowIDDataTemplate}"/>
<controls:FilterableGridViewColumn Header="Token" SortBy="Token" FilterBy="Token" FilterFormatString="X8" CellTemplateSelector="{StaticResource DefinitionHandleDataTemplate}"/>
<controls:FilterableGridViewColumn Header="Offset" SortBy="Offset" FilterBy="Offset" FilterFormatString="X8">
<controls:FilterableGridViewColumn.CellTemplate>
<DataTemplate>
<TextBlock Text="{Binding Offset, StringFormat=X8}" />
</DataTemplate>
</controls:FilterableGridViewColumn.CellTemplate>
</controls:FilterableGridViewColumn>
<controls:FilterableGridViewColumn Header="Offset" SortBy="Offset" FilterBy="Offset" FilterFormatString="X8" CellTemplate="{StaticResource OffsetDataTemplate}"/>
<controls:FilterableGridViewColumn Header="Attributes" SortBy="Attributes" FilterBy="Attributes">
<controls:FilterableGridViewColumn.CellTemplate>
<DataTemplate>
@ -236,16 +226,32 @@ @@ -236,16 +226,32 @@
</controls:FilterableGridViewColumn>
</GridView>
<GridView x:Key="TypeSpecsView" AllowsColumnReorder="False">
<controls:FilterableGridViewColumn Header="RID" SortBy="RID" FilterBy="RID" CellTemplate="{StaticResource RowIDDataTemplate}"/>
<controls:FilterableGridViewColumn Header="Token" SortBy="Token" FilterBy="Token" FilterFormatString="X8" CellTemplateSelector="{StaticResource DefinitionHandleDataTemplate}"/>
<controls:FilterableGridViewColumn Header="Offset" SortBy="Offset" FilterBy="Offset" FilterFormatString="X8" CellTemplate="{StaticResource OffsetDataTemplate}"/>
<controls:FilterableGridViewColumn Header="Signature" SortBy="Signature" FilterBy="Signature" CellTemplateSelector="{StaticResource SignatureBlobHandleDataTemplate}"/>
</GridView>
<GridView x:Key="FieldDefsView" AllowsColumnReorder="False">
<controls:FilterableGridViewColumn Header="RID" SortBy="RID" FilterBy="RID" CellTemplate="{StaticResource RowIDDataTemplate}"/>
<controls:FilterableGridViewColumn Header="Token" SortBy="Token" FilterBy="Token" FilterFormatString="X8" CellTemplateSelector="{StaticResource DefinitionHandleDataTemplate}"/>
<controls:FilterableGridViewColumn Header="Offset" SortBy="Offset" FilterBy="Offset" FilterFormatString="X8">
<controls:FilterableGridViewColumn Header="Offset" SortBy="Offset" FilterBy="Offset" FilterFormatString="X8" CellTemplate="{StaticResource OffsetDataTemplate}"/>
<controls:FilterableGridViewColumn Header="Attributes" SortBy="Attributes" FilterBy="Attributes">
<controls:FilterableGridViewColumn.CellTemplate>
<DataTemplate>
<TextBlock Text="{Binding Offset, StringFormat=X8}" />
<TextBlock Text="{Binding Attributes, StringFormat=X8}" ToolTip="{Binding AttributesTooltip}" />
</DataTemplate>
</controls:FilterableGridViewColumn.CellTemplate>
</controls:FilterableGridViewColumn>
<controls:FilterableGridViewColumn Header="Name" SortBy="Name" FilterBy="Name" CellTemplateSelector="{StaticResource NameStringHandleDataTemplate}"/>
<controls:FilterableGridViewColumn Header="Signature" SortBy="Signature" FilterBy="Signature" CellTemplateSelector="{StaticResource SignatureBlobHandleDataTemplate}"/>
</GridView>
<GridView x:Key="MethodDefsView" AllowsColumnReorder="False">
<controls:FilterableGridViewColumn Header="RID" SortBy="RID" FilterBy="RID" CellTemplate="{StaticResource RowIDDataTemplate}"/>
<controls:FilterableGridViewColumn Header="Token" SortBy="Token" FilterBy="Token" FilterFormatString="X8" CellTemplateSelector="{StaticResource DefinitionHandleDataTemplate}"/>
<controls:FilterableGridViewColumn Header="Offset" SortBy="Offset" FilterBy="Offset" FilterFormatString="X8" CellTemplate="{StaticResource OffsetDataTemplate}"/>
<controls:FilterableGridViewColumn Header="Attributes" SortBy="Attributes" FilterBy="Attributes">
<controls:FilterableGridViewColumn.CellTemplate>
<DataTemplate>
@ -257,16 +263,29 @@ @@ -257,16 +263,29 @@
<controls:FilterableGridViewColumn Header="Signature" SortBy="Signature" FilterBy="Signature" CellTemplateSelector="{StaticResource SignatureBlobHandleDataTemplate}"/>
</GridView>
<GridView x:Key="MethodDefsView" AllowsColumnReorder="False">
<GridView x:Key="EventDefsView" AllowsColumnReorder="False">
<controls:FilterableGridViewColumn Header="RID" SortBy="RID" FilterBy="RID" CellTemplate="{StaticResource RowIDDataTemplate}"/>
<controls:FilterableGridViewColumn Header="Token" SortBy="Token" FilterBy="Token" FilterFormatString="X8" CellTemplateSelector="{StaticResource DefinitionHandleDataTemplate}"/>
<controls:FilterableGridViewColumn Header="Offset" SortBy="Offset" FilterBy="Offset" FilterFormatString="X8">
<controls:FilterableGridViewColumn Header="Offset" SortBy="Offset" FilterBy="Offset" FilterFormatString="X8" CellTemplate="{StaticResource OffsetDataTemplate}"/>
<controls:FilterableGridViewColumn Header="Attributes" SortBy="Attributes" FilterBy="Attributes">
<controls:FilterableGridViewColumn.CellTemplate>
<DataTemplate>
<TextBlock Text="{Binding Offset, StringFormat=X8}" />
<TextBlock Text="{Binding Attributes, StringFormat=X8}" ToolTip="{Binding AttributesTooltip}" />
</DataTemplate>
</controls:FilterableGridViewColumn.CellTemplate>
</controls:FilterableGridViewColumn>
<controls:FilterableGridViewColumn Header="Name" SortBy="Name" FilterBy="Name" CellTemplateSelector="{StaticResource NameStringHandleDataTemplate}"/>
<controls:FilterableGridViewColumn Header="Type" SortBy="Type" FilterBy="Type">
<controls:FilterableGridViewColumn.CellTemplateSelector>
<local:HandleTemplate ValuePropertyName="Type" TooltipPropertyName="TypeTooltip" />
</controls:FilterableGridViewColumn.CellTemplateSelector>
</controls:FilterableGridViewColumn>
</GridView>
<GridView x:Key="PropertyDefsView" AllowsColumnReorder="False">
<controls:FilterableGridViewColumn Header="RID" SortBy="RID" FilterBy="RID" CellTemplate="{StaticResource RowIDDataTemplate}"/>
<controls:FilterableGridViewColumn Header="Token" SortBy="Token" FilterBy="Token" FilterFormatString="X8" CellTemplateSelector="{StaticResource DefinitionHandleDataTemplate}"/>
<controls:FilterableGridViewColumn Header="Offset" SortBy="Offset" FilterBy="Offset" FilterFormatString="X8" CellTemplate="{StaticResource OffsetDataTemplate}"/>
<controls:FilterableGridViewColumn Header="Attributes" SortBy="Attributes" FilterBy="Attributes">
<controls:FilterableGridViewColumn.CellTemplate>
<DataTemplate>
@ -278,62 +297,343 @@ @@ -278,62 +297,343 @@
<controls:FilterableGridViewColumn Header="Signature" SortBy="Signature" FilterBy="Signature" CellTemplateSelector="{StaticResource SignatureBlobHandleDataTemplate}"/>
</GridView>
<GridView x:Key="AssemblyView" AllowsColumnReorder="False">
<controls:FilterableGridViewColumn Header="RID" SortBy="RID" FilterBy="RID" CellTemplate="{StaticResource RowIDDataTemplate}"/>
<controls:FilterableGridViewColumn Header="Token" SortBy="Token" FilterBy="Token" FilterFormatString="X8" CellTemplateSelector="{StaticResource DefinitionHandleDataTemplate}"/>
<controls:FilterableGridViewColumn Header="Offset" SortBy="Offset" FilterBy="Offset" FilterFormatString="X8" CellTemplate="{StaticResource OffsetDataTemplate}"/>
<controls:FilterableGridViewColumn Header="HashAlgorithm" SortBy="HashAlgorithm" FilterBy="HashAlgorithm">
<controls:FilterableGridViewColumn.CellTemplateSelector>
<local:EnumTemplate ValuePropertyName="HashAlgorithm" TooltipPropertyName="HashAlgorithmTooltip"/>
</controls:FilterableGridViewColumn.CellTemplateSelector>
</controls:FilterableGridViewColumn>
<controls:FilterableGridViewColumn Header="Flags" SortBy="Flags" FilterBy="Flags">
<controls:FilterableGridViewColumn.CellTemplateSelector>
<local:EnumTemplate ValuePropertyName="Flags" TooltipPropertyName="FlagsTooltip"/>
</controls:FilterableGridViewColumn.CellTemplateSelector>
</controls:FilterableGridViewColumn>
<controls:FilterableGridViewColumn Header="Version" SortBy="Version" FilterBy="Version">
<controls:FilterableGridViewColumn.CellTemplate>
<DataTemplate>
<Grid>
<TextBlock Margin="3,1,0,0" x:Name="textBlock" Text="{Binding Version}" />
<TextBox x:Name="textBox" Text="{Binding Version, Mode=OneWay}" Visibility="Hidden" IsReadOnly="True" IsReadOnlyCaretVisible="True" />
</Grid>
<DataTemplate.Triggers>
<Trigger Property="IsMouseOver" Value="True">
<Setter TargetName="textBox" Property="Visibility" Value="Visible" />
<Setter TargetName="textBlock" Property="Visibility" Value="Hidden" />
</Trigger>
<Trigger Property="IsKeyboardFocusWithin" Value="True">
<Setter TargetName="textBox" Property="Visibility" Value="Visible" />
<Setter TargetName="textBlock" Property="Visibility" Value="Hidden" />
</Trigger>
</DataTemplate.Triggers>
</DataTemplate>
</controls:FilterableGridViewColumn.CellTemplate>
</controls:FilterableGridViewColumn>
<controls:FilterableGridViewColumn Header="Name" SortBy="Name" FilterBy="Name" CellTemplateSelector="{StaticResource NameStringHandleDataTemplate}"/>
<controls:FilterableGridViewColumn Header="Culture" SortBy="Culture" FilterBy="Culture">
<controls:FilterableGridViewColumn.CellTemplateSelector>
<local:StringHandleTemplate HandlePropertyName="CultureStringHandle" ValuePropertyName="Culture" />
</controls:FilterableGridViewColumn.CellTemplateSelector>
</controls:FilterableGridViewColumn>
</GridView>
<GridView x:Key="AssemblyRefView" AllowsColumnReorder="False">
<controls:FilterableGridViewColumn Header="RID" SortBy="RID" FilterBy="RID" CellTemplate="{StaticResource RowIDDataTemplate}"/>
<controls:FilterableGridViewColumn Header="Token" SortBy="Token" FilterBy="Token" FilterFormatString="X8" CellTemplateSelector="{StaticResource DefinitionHandleDataTemplate}"/>
<controls:FilterableGridViewColumn Header="Offset" SortBy="Offset" FilterBy="Offset" FilterFormatString="X8" CellTemplate="{StaticResource OffsetDataTemplate}"/>
<controls:FilterableGridViewColumn Header="Flags" SortBy="Flags" FilterBy="Flags">
<controls:FilterableGridViewColumn.CellTemplateSelector>
<local:EnumTemplate ValuePropertyName="Flags" TooltipPropertyName="FlagsTooltip"/>
</controls:FilterableGridViewColumn.CellTemplateSelector>
</controls:FilterableGridViewColumn>
<controls:FilterableGridViewColumn Header="PublicKeyOrToken" SortBy="PublicKeyOrToken" FilterBy="PublicKeyOrToken">
<controls:FilterableGridViewColumn.CellTemplateSelector>
<local:HandleTemplate ValuePropertyName="PublicKeyOrToken" TooltipPropertyName="PublicKeyOrTokenTooltip" ValueStringFormat="X" />
</controls:FilterableGridViewColumn.CellTemplateSelector>
</controls:FilterableGridViewColumn>
<controls:FilterableGridViewColumn Header="Version" SortBy="Version" FilterBy="Version">
<controls:FilterableGridViewColumn.CellTemplate>
<DataTemplate>
<Grid>
<TextBlock Margin="3,1,0,0" x:Name="textBlock" Text="{Binding Version}" />
<TextBox x:Name="textBox" Text="{Binding Version, Mode=OneWay}" Visibility="Hidden" IsReadOnly="True" IsReadOnlyCaretVisible="True" />
</Grid>
<DataTemplate.Triggers>
<Trigger Property="IsMouseOver" Value="True">
<Setter TargetName="textBox" Property="Visibility" Value="Visible" />
<Setter TargetName="textBlock" Property="Visibility" Value="Hidden" />
</Trigger>
<Trigger Property="IsKeyboardFocusWithin" Value="True">
<Setter TargetName="textBox" Property="Visibility" Value="Visible" />
<Setter TargetName="textBlock" Property="Visibility" Value="Hidden" />
</Trigger>
</DataTemplate.Triggers>
</DataTemplate>
</controls:FilterableGridViewColumn.CellTemplate>
</controls:FilterableGridViewColumn>
<controls:FilterableGridViewColumn Header="Name" SortBy="Name" FilterBy="Name" CellTemplateSelector="{StaticResource NameStringHandleDataTemplate}"/>
<controls:FilterableGridViewColumn Header="Culture" SortBy="Culture" FilterBy="Culture">
<controls:FilterableGridViewColumn.CellTemplateSelector>
<local:StringHandleTemplate HandlePropertyName="CultureStringHandle" ValuePropertyName="Culture" />
</controls:FilterableGridViewColumn.CellTemplateSelector>
</controls:FilterableGridViewColumn>
</GridView>
<GridView x:Key="ExportedTypesView" AllowsColumnReorder="False">
<controls:FilterableGridViewColumn Header="RID" SortBy="RID" FilterBy="RID">
<controls:FilterableGridViewColumn Header="RID" SortBy="RID" FilterBy="RID" CellTemplate="{StaticResource RowIDDataTemplate}"/>
<controls:FilterableGridViewColumn Header="Token" SortBy="Token" FilterBy="Token" FilterFormatString="X8" CellTemplateSelector="{StaticResource DefinitionHandleDataTemplate}"/>
<controls:FilterableGridViewColumn Header="Offset" SortBy="Offset" FilterBy="Offset" FilterFormatString="X8" CellTemplate="{StaticResource OffsetDataTemplate}"/>
<controls:FilterableGridViewColumn Header="Attributes" SortBy="Attributes" FilterBy="Attributes" FilterFormatString="X8">
<controls:FilterableGridViewColumn.CellTemplate>
<DataTemplate>
<TextBlock Text="{Binding RID}" />
<TextBlock Text="{Binding Attributes, StringFormat=X8}" ToolTip="{Binding AttributesTooltip}" />
</DataTemplate>
</controls:FilterableGridViewColumn.CellTemplate>
</controls:FilterableGridViewColumn>
<controls:FilterableGridViewColumn Header="Token" SortBy="Token" FilterBy="Token" FilterFormatString="X8">
<controls:FilterableGridViewColumn Header="TypeDefId" SortBy="TypeDefId" FilterBy="TypeDefId">
<controls:FilterableGridViewColumn.CellTemplate>
<DataTemplate>
<TextBlock Text="{Binding Token, StringFormat=X8}" />
<TextBlock Text="{Binding TypeDefId, StringFormat=X}" />
</DataTemplate>
</controls:FilterableGridViewColumn.CellTemplate>
</controls:FilterableGridViewColumn>
<controls:FilterableGridViewColumn Header="Offset" SortBy="Offset" FilterBy="Offset" FilterFormatString="X8">
<controls:FilterableGridViewColumn Header="TypeName" SortBy="TypeName" FilterBy="TypeName">
<controls:FilterableGridViewColumn.CellTemplateSelector>
<local:StringHandleTemplate HandlePropertyName="TypeNamespaceStringHandle" ValuePropertyName="TypeName"/>
</controls:FilterableGridViewColumn.CellTemplateSelector>
</controls:FilterableGridViewColumn>
<controls:FilterableGridViewColumn Header="TypeNamespace" SortBy="TypeNamespace" FilterBy="TypeNamespace">
<controls:FilterableGridViewColumn.CellTemplateSelector>
<local:StringHandleTemplate HandlePropertyName="TypeNamespaceStringHandle" ValuePropertyName="TypeNamespace"/>
</controls:FilterableGridViewColumn.CellTemplateSelector>
</controls:FilterableGridViewColumn>
<controls:FilterableGridViewColumn Header="Implementation" SortBy="Implementation" FilterBy="Implementation">
<controls:FilterableGridViewColumn.CellTemplate>
<DataTemplate>
<TextBlock Text="{Binding Offset, StringFormat=X8}" />
<TextBlock Text="{Binding Implementation, StringFormat=X8}" />
</DataTemplate>
</controls:FilterableGridViewColumn.CellTemplate>
</controls:FilterableGridViewColumn>
<controls:FilterableGridViewColumn Header="Attributes" SortBy="Attributes" FilterBy="Attributes" FilterFormatString="X8">
</GridView>
<GridView x:Key="MethodSpecsView" AllowsColumnReorder="False">
<controls:FilterableGridViewColumn Header="RID" SortBy="RID" FilterBy="RID" CellTemplate="{StaticResource RowIDDataTemplate}"/>
<controls:FilterableGridViewColumn Header="Token" SortBy="Token" FilterBy="Token" FilterFormatString="X8" CellTemplateSelector="{StaticResource DefinitionHandleDataTemplate}"/>
<controls:FilterableGridViewColumn Header="Offset" SortBy="Offset" FilterBy="Offset" FilterFormatString="X8" CellTemplate="{StaticResource OffsetDataTemplate}"/>
<controls:FilterableGridViewColumn Header="Method" SortBy="MethodHandle" FilterBy="MethodHandle" FilterFormatString="X8">
<controls:FilterableGridViewColumn.CellTemplateSelector>
<local:HandleTemplate ValuePropertyName="MethodHandle" TooltipPropertyName="Method" />
</controls:FilterableGridViewColumn.CellTemplateSelector>
</controls:FilterableGridViewColumn>
<controls:FilterableGridViewColumn Header="Signature" SortBy="Signature" FilterBy="Signature" CellTemplateSelector="{StaticResource SignatureBlobHandleDataTemplate}"/>
</GridView>
<GridView x:Key="MemberRefsView" AllowsColumnReorder="False">
<controls:FilterableGridViewColumn Header="RID" SortBy="RID" FilterBy="RID" CellTemplate="{StaticResource RowIDDataTemplate}"/>
<controls:FilterableGridViewColumn Header="Token" SortBy="Token" FilterBy="Token" FilterFormatString="X8" CellTemplateSelector="{StaticResource DefinitionHandleDataTemplate}"/>
<controls:FilterableGridViewColumn Header="Offset" SortBy="Offset" FilterBy="Offset" FilterFormatString="X8" CellTemplate="{StaticResource OffsetDataTemplate}"/>
<controls:FilterableGridViewColumn Header="Name" SortBy="Name" FilterBy="Name" CellTemplateSelector="{StaticResource NameStringHandleDataTemplate}"/>
<controls:FilterableGridViewColumn Header="Parent" SortBy="ParentHandle" FilterBy="ParentHandle" FilterFormatString="X8">
<controls:FilterableGridViewColumn.CellTemplateSelector>
<local:HandleTemplate ValuePropertyName="ParentHandle" TooltipPropertyName="ParentTooltip" />
</controls:FilterableGridViewColumn.CellTemplateSelector>
</controls:FilterableGridViewColumn>
<controls:FilterableGridViewColumn Header="Signature" SortBy="Signature" FilterBy="Signature" CellTemplateSelector="{StaticResource SignatureBlobHandleDataTemplate}"/>
</GridView>
<GridView x:Key="CustomAttributesView" AllowsColumnReorder="False">
<controls:FilterableGridViewColumn Header="RID" SortBy="RID" FilterBy="RID" CellTemplate="{StaticResource RowIDDataTemplate}"/>
<controls:FilterableGridViewColumn Header="Token" SortBy="Token" FilterBy="Token" FilterFormatString="X8" CellTemplateSelector="{StaticResource DefinitionHandleDataTemplate}"/>
<controls:FilterableGridViewColumn Header="Offset" SortBy="Offset" FilterBy="Offset" FilterFormatString="X8" CellTemplate="{StaticResource OffsetDataTemplate}"/>
<controls:FilterableGridViewColumn Header="Parent" SortBy="ParentHandle" FilterBy="ParentHandle" FilterFormatString="X8">
<controls:FilterableGridViewColumn.CellTemplateSelector>
<local:HandleTemplate ValuePropertyName="ParentHandle" TooltipPropertyName="ParentTooltip" />
</controls:FilterableGridViewColumn.CellTemplateSelector>
</controls:FilterableGridViewColumn>
<controls:FilterableGridViewColumn Header="Constructor" SortBy="ConstructorHandle" FilterBy="ConstructorHandle" FilterFormatString="X8">
<controls:FilterableGridViewColumn.CellTemplateSelector>
<local:HandleTemplate ValuePropertyName="ConstructorHandle" TooltipPropertyName="ConstructorTooltip" />
</controls:FilterableGridViewColumn.CellTemplateSelector>
</controls:FilterableGridViewColumn>
<controls:FilterableGridViewColumn Header="Value" SortBy="ValueHandle" FilterBy="ValueHandle">
<controls:FilterableGridViewColumn.CellTemplateSelector>
<local:HandleTemplate ValuePropertyName="ValueHandle" TooltipPropertyName="ValueTooltip" ValueStringFormat="X" />
</controls:FilterableGridViewColumn.CellTemplateSelector>
</controls:FilterableGridViewColumn>
</GridView>
<GridView x:Key="DeclSecurityAttrsView" AllowsColumnReorder="False">
<controls:FilterableGridViewColumn Header="RID" SortBy="RID" FilterBy="RID" CellTemplate="{StaticResource RowIDDataTemplate}"/>
<controls:FilterableGridViewColumn Header="Token" SortBy="Token" FilterBy="Token" FilterFormatString="X8" CellTemplateSelector="{StaticResource DefinitionHandleDataTemplate}"/>
<controls:FilterableGridViewColumn Header="Offset" SortBy="Offset" FilterBy="Offset" FilterFormatString="X8" CellTemplate="{StaticResource OffsetDataTemplate}"/>
<controls:FilterableGridViewColumn Header="Parent" SortBy="ParentHandle" FilterBy="ParentHandle" FilterFormatString="X8">
<controls:FilterableGridViewColumn.CellTemplateSelector>
<local:HandleTemplate ValuePropertyName="ParentHandle" TooltipPropertyName="ParentTooltip" />
</controls:FilterableGridViewColumn.CellTemplateSelector>
</controls:FilterableGridViewColumn>
<controls:FilterableGridViewColumn Header="Action" SortBy="Action" FilterBy="Action" FilterFormatString="X8">
<controls:FilterableGridViewColumn.CellTemplate>
<DataTemplate>
<TextBlock Text="{Binding Action, StringFormat=X8}" ToolTip="{Binding ActionTooltip}" />
</DataTemplate>
</controls:FilterableGridViewColumn.CellTemplate>
</controls:FilterableGridViewColumn>
<controls:FilterableGridViewColumn Header="PermissionSet" SortBy="PermissionSetHandle" FilterBy="PermissionSetHandle">
<controls:FilterableGridViewColumn.CellTemplateSelector>
<local:HandleTemplate ValuePropertyName="PermissionSetHandle" TooltipPropertyName="PermissionSetTooltip" ValueStringFormat="X" />
</controls:FilterableGridViewColumn.CellTemplateSelector>
</controls:FilterableGridViewColumn>
</GridView>
<GridView x:Key="MethodSemanticsView" AllowsColumnReorder="False">
<controls:FilterableGridViewColumn Header="RID" SortBy="RID" FilterBy="RID" CellTemplate="{StaticResource RowIDDataTemplate}"/>
<controls:FilterableGridViewColumn Header="Token" SortBy="Token" FilterBy="Token" FilterFormatString="X8" CellTemplateSelector="{StaticResource DefinitionHandleDataTemplate}"/>
<controls:FilterableGridViewColumn Header="Offset" SortBy="Offset" FilterBy="Offset" FilterFormatString="X8" CellTemplate="{StaticResource OffsetDataTemplate}"/>
<controls:FilterableGridViewColumn Header="Semantics" SortBy="Semantics" FilterBy="Semantics" FilterFormatString="X8">
<controls:FilterableGridViewColumn.CellTemplate>
<DataTemplate>
<TextBlock Text="{Binding Semantics, StringFormat=X8}" ToolTip="{Binding SemanticsTooltip}" />
</DataTemplate>
</controls:FilterableGridViewColumn.CellTemplate>
</controls:FilterableGridViewColumn>
<controls:FilterableGridViewColumn Header="Method" SortBy="MethodHandle" FilterBy="MethodHandle" FilterFormatString="X8">
<controls:FilterableGridViewColumn.CellTemplateSelector>
<local:HandleTemplate ValuePropertyName="MethodHandle" TooltipPropertyName="Method" />
</controls:FilterableGridViewColumn.CellTemplateSelector>
</controls:FilterableGridViewColumn>
<controls:FilterableGridViewColumn Header="Association" SortBy="AssociationHandle" FilterBy="AssociationHandle" FilterFormatString="X8">
<controls:FilterableGridViewColumn.CellTemplateSelector>
<local:HandleTemplate ValuePropertyName="AssociationHandle" TooltipPropertyName="Association" />
</controls:FilterableGridViewColumn.CellTemplateSelector>
</controls:FilterableGridViewColumn>
</GridView>
<GridView x:Key="ManifestResourcesView" AllowsColumnReorder="False">
<controls:FilterableGridViewColumn Header="RID" SortBy="RID" FilterBy="RID" CellTemplate="{StaticResource RowIDDataTemplate}"/>
<controls:FilterableGridViewColumn Header="Token" SortBy="Token" FilterBy="Token" FilterFormatString="X8" CellTemplateSelector="{StaticResource DefinitionHandleDataTemplate}"/>
<controls:FilterableGridViewColumn Header="Offset" SortBy="Offset" FilterBy="Offset" FilterFormatString="X8" CellTemplate="{StaticResource OffsetDataTemplate}"/>
<controls:FilterableGridViewColumn Header="Attributes" SortBy="Attributes" FilterBy="Attributes">
<controls:FilterableGridViewColumn.CellTemplate>
<DataTemplate>
<TextBlock Text="{Binding Attributes, StringFormat=X8}" ToolTip="{Binding AttributesTooltip}" />
</DataTemplate>
</controls:FilterableGridViewColumn.CellTemplate>
</controls:FilterableGridViewColumn>
<controls:FilterableGridViewColumn Header="TypeDefId" SortBy="TypeDefId" FilterBy="TypeDefId">
<controls:FilterableGridViewColumn Header="Name" SortBy="Name" FilterBy="Name" CellTemplateSelector="{StaticResource NameStringHandleDataTemplate}"/>
<controls:FilterableGridViewColumn Header="Implementation" SortBy="ImplementationHandle" FilterBy="ImplementationHandle" FilterFormatString="X8">
<controls:FilterableGridViewColumn.CellTemplateSelector>
<local:HandleTemplate ValuePropertyName="ImplementationHandle" TooltipPropertyName="ImplementationTooltip" />
</controls:FilterableGridViewColumn.CellTemplateSelector>
</controls:FilterableGridViewColumn>
</GridView>
<GridView x:Key="FilesView" AllowsColumnReorder="False">
<controls:FilterableGridViewColumn Header="RID" SortBy="RID" FilterBy="RID" CellTemplate="{StaticResource RowIDDataTemplate}"/>
<controls:FilterableGridViewColumn Header="Token" SortBy="Token" FilterBy="Token" FilterFormatString="X8" CellTemplateSelector="{StaticResource DefinitionHandleDataTemplate}"/>
<controls:FilterableGridViewColumn Header="Offset" SortBy="Offset" FilterBy="Offset" FilterFormatString="X8" CellTemplate="{StaticResource OffsetDataTemplate}"/>
<controls:FilterableGridViewColumn Header="Attributes" SortBy="Attributes" FilterBy="Attributes">
<controls:FilterableGridViewColumn.CellTemplate>
<DataTemplate>
<TextBlock Text="{Binding TypeDefId, StringFormat=X}" />
<TextBlock Text="{Binding Attributes, StringFormat=X8}" ToolTip="{Binding AttributesTooltip}" />
</DataTemplate>
</controls:FilterableGridViewColumn.CellTemplate>
</controls:FilterableGridViewColumn>
<controls:FilterableGridViewColumn Header="TypeName" SortBy="TypeName" FilterBy="TypeName">
<controls:FilterableGridViewColumn Header="Name" SortBy="Name" FilterBy="Name" CellTemplateSelector="{StaticResource NameStringHandleDataTemplate}"/>
<controls:FilterableGridViewColumn Header="HashValue" SortBy="HashValue" FilterBy="HashValue">
<controls:FilterableGridViewColumn.CellTemplateSelector>
<local:HandleTemplate ValuePropertyName="HashValue" TooltipPropertyName="HashValueTooltip" ValueStringFormat="X" />
</controls:FilterableGridViewColumn.CellTemplateSelector>
</controls:FilterableGridViewColumn>
</GridView>
<GridView x:Key="StandAloneSigsView" AllowsColumnReorder="False">
<controls:FilterableGridViewColumn Header="RID" SortBy="RID" FilterBy="RID" CellTemplate="{StaticResource RowIDDataTemplate}"/>
<controls:FilterableGridViewColumn Header="Token" SortBy="Token" FilterBy="Token" FilterFormatString="X8" CellTemplateSelector="{StaticResource DefinitionHandleDataTemplate}"/>
<controls:FilterableGridViewColumn Header="Offset" SortBy="Offset" FilterBy="Offset" FilterFormatString="X8" CellTemplate="{StaticResource OffsetDataTemplate}"/>
<controls:FilterableGridViewColumn Header="Signature" SortBy="Signature" FilterBy="Signature" CellTemplateSelector="{StaticResource SignatureBlobHandleDataTemplate}"/>
</GridView>
<GridView x:Key="ConstantsView" AllowsColumnReorder="False">
<controls:FilterableGridViewColumn Header="RID" SortBy="RID" FilterBy="RID" CellTemplate="{StaticResource RowIDDataTemplate}"/>
<controls:FilterableGridViewColumn Header="Token" SortBy="Token" FilterBy="Token" FilterFormatString="X8" CellTemplateSelector="{StaticResource DefinitionHandleDataTemplate}"/>
<controls:FilterableGridViewColumn Header="Offset" SortBy="Offset" FilterBy="Offset" FilterFormatString="X8" CellTemplate="{StaticResource OffsetDataTemplate}"/>
<controls:FilterableGridViewColumn Header="Type" SortBy="Type" FilterBy="Type">
<controls:FilterableGridViewColumn.CellTemplate>
<DataTemplate>
<TextBlock Text="{Binding TypeName, StringFormat=X}" ToolTip="{Binding TypeNameTooltip}" />
<TextBlock Text="{Binding Type, StringFormat=X8}" ToolTip="{Binding TypeTooltip}" />
</DataTemplate>
</controls:FilterableGridViewColumn.CellTemplate>
</controls:FilterableGridViewColumn>
<controls:FilterableGridViewColumn Header="TypeNamespace" SortBy="TypeNamespace" FilterBy="TypeNamespace">
<controls:FilterableGridViewColumn Header="Parent" SortBy="ParentHandle" FilterBy="ParentHandle" FilterFormatString="X8">
<controls:FilterableGridViewColumn.CellTemplateSelector>
<local:HandleTemplate ValuePropertyName="ParentHandle" TooltipPropertyName="ParentTooltip" />
</controls:FilterableGridViewColumn.CellTemplateSelector>
</controls:FilterableGridViewColumn>
<controls:FilterableGridViewColumn Header="Value" SortBy="Value" FilterBy="Value" CellTemplateSelector="{StaticResource ValueBlobHandleDataTemplate}"/>
</GridView>
<GridView x:Key="ParamsView" AllowsColumnReorder="False">
<controls:FilterableGridViewColumn Header="RID" SortBy="RID" FilterBy="RID" CellTemplate="{StaticResource RowIDDataTemplate}"/>
<controls:FilterableGridViewColumn Header="Token" SortBy="Token" FilterBy="Token" FilterFormatString="X8" CellTemplateSelector="{StaticResource DefinitionHandleDataTemplate}"/>
<controls:FilterableGridViewColumn Header="Offset" SortBy="Offset" FilterBy="Offset" FilterFormatString="X8" CellTemplate="{StaticResource OffsetDataTemplate}"/>
<controls:FilterableGridViewColumn Header="Sequence" SortBy="Sequence" FilterBy="Sequence">
<controls:FilterableGridViewColumn.CellTemplate>
<DataTemplate>
<TextBlock Text="{Binding TypeNamespace, StringFormat=X}" ToolTip="{Binding TypeNamespaceTooltip}" />
<TextBlock Text="{Binding Sequence}" />
</DataTemplate>
</controls:FilterableGridViewColumn.CellTemplate>
</controls:FilterableGridViewColumn>
<controls:FilterableGridViewColumn Header="Implementation" SortBy="Implementation" FilterBy="Implementation">
<controls:FilterableGridViewColumn Header="Attributes" SortBy="Attributes" FilterBy="Attributes">
<controls:FilterableGridViewColumn.CellTemplate>
<DataTemplate>
<TextBlock Text="{Binding Implementation, StringFormat=X8}" />
<TextBlock Text="{Binding Attributes, StringFormat=X8}" ToolTip="{Binding AttributesTooltip}" />
</DataTemplate>
</controls:FilterableGridViewColumn.CellTemplate>
</controls:FilterableGridViewColumn>
<controls:FilterableGridViewColumn Header="Name" SortBy="Name" FilterBy="Name" CellTemplateSelector="{StaticResource NameStringHandleDataTemplate}"/>
</GridView>
<GridView x:Key="GenericParamsView" AllowsColumnReorder="False">
<controls:FilterableGridViewColumn Header="RID" SortBy="RID" FilterBy="RID" CellTemplate="{StaticResource RowIDDataTemplate}"/>
<controls:FilterableGridViewColumn Header="Token" SortBy="Token" FilterBy="Token" FilterFormatString="X8" CellTemplateSelector="{StaticResource DefinitionHandleDataTemplate}"/>
<controls:FilterableGridViewColumn Header="Offset" SortBy="Offset" FilterBy="Offset" FilterFormatString="X8" CellTemplate="{StaticResource OffsetDataTemplate}"/>
<controls:FilterableGridViewColumn Header="Number" SortBy="Number" FilterBy="Number">
<controls:FilterableGridViewColumn.CellTemplate>
<DataTemplate>
<TextBlock Text="{Binding Number}" />
</DataTemplate>
</controls:FilterableGridViewColumn.CellTemplate>
</controls:FilterableGridViewColumn>
<controls:FilterableGridViewColumn Header="Attributes" SortBy="Attributes" FilterBy="Attributes">
<controls:FilterableGridViewColumn.CellTemplate>
<DataTemplate>
<TextBlock Text="{Binding Attributes, StringFormat=X8}" ToolTip="{Binding AttributesTooltip}" />
</DataTemplate>
</controls:FilterableGridViewColumn.CellTemplate>
</controls:FilterableGridViewColumn>
<controls:FilterableGridViewColumn Header="Owner" SortBy="OwnerHandle" FilterBy="OwnerHandle" FilterFormatString="X8">
<controls:FilterableGridViewColumn.CellTemplateSelector>
<local:HandleTemplate ValuePropertyName="OwnerHandle" TooltipPropertyName="Owner" />
</controls:FilterableGridViewColumn.CellTemplateSelector>
</controls:FilterableGridViewColumn>
<controls:FilterableGridViewColumn Header="Name" SortBy="Name" FilterBy="Name" CellTemplateSelector="{StaticResource NameStringHandleDataTemplate}"/>
</GridView>
<GridView x:Key="GenericParamConstraintsView" AllowsColumnReorder="False">
<controls:FilterableGridViewColumn Header="RID" SortBy="RID" FilterBy="RID" CellTemplate="{StaticResource RowIDDataTemplate}"/>
<controls:FilterableGridViewColumn Header="Token" SortBy="Token" FilterBy="Token" FilterFormatString="X8" CellTemplateSelector="{StaticResource DefinitionHandleDataTemplate}"/>
<controls:FilterableGridViewColumn Header="Offset" SortBy="Offset" FilterBy="Offset" FilterFormatString="X8" CellTemplate="{StaticResource OffsetDataTemplate}"/>
<controls:FilterableGridViewColumn Header="Owner" SortBy="OwnerHandle" FilterBy="OwnerHandle" FilterFormatString="X8">
<controls:FilterableGridViewColumn.CellTemplateSelector>
<local:HandleTemplate ValuePropertyName="OwnerHandle" TooltipPropertyName="Owner" />
</controls:FilterableGridViewColumn.CellTemplateSelector>
</controls:FilterableGridViewColumn>
<controls:FilterableGridViewColumn Header="Type" SortBy="Type" FilterBy="Type">
<controls:FilterableGridViewColumn.CellTemplateSelector>
<local:HandleTemplate ValuePropertyName="Type" TooltipPropertyName="TypeTooltip" />
</controls:FilterableGridViewColumn.CellTemplateSelector>
</controls:FilterableGridViewColumn>
</GridView>
</ResourceDictionary>

39
ILSpy/Metadata/MetadataTreeNode.cs

@ -1,4 +1,22 @@ @@ -1,4 +1,22 @@
using System;
// 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;
using System.Collections.Generic;
using System.Globalization;
using System.Linq;
@ -45,7 +63,26 @@ namespace ICSharpCode.ILSpy.Metadata @@ -45,7 +63,26 @@ namespace ICSharpCode.ILSpy.Metadata
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 DeclSecurityTableTreeNode(module));
this.Children.Add(new StandAloneSigTableTreeNode(module));
this.Children.Add(new EventTableTreeNode(module));
this.Children.Add(new PropertyTableTreeNode(module));
this.Children.Add(new MethodSemanticsTableTreeNode(module));
this.Children.Add(new ModuleRefTableTreeNode(module));
this.Children.Add(new TypeSpecTableTreeNode(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 GenericParamTableTreeNode(module));
this.Children.Add(new MethodSpecTableTreeNode(module));
this.Children.Add(new GenericParamConstraintTableTreeNode(module));
}
}

95
ILSpy/Metadata/ModuleTableTreeNode.cs

@ -1,95 +0,0 @@ @@ -1,95 +0,0 @@
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
{
private PEFile module;
public ModuleTableTreeNode(PEFile module)
{
this.module = module;
}
public override object Text => $"00 Module ({module.Metadata.GetTableRowCount(TableIndex.Module)})";
public override object Icon => Images.Literal;
public override bool View(DecompilerTextView textView)
{
ListView view = Helpers.CreateListView("ModulesView");
var metadata = module.Metadata;
var list = new List<ModuleEntry>();
list.Add(new ModuleEntry(module.Reader.PEHeaders.MetadataStartOffset, metadata, EntityHandle.ModuleDefinition, metadata.GetModuleDefinition()));
view.ItemsSource = list;
textView.ShowContent(new[] { this }, view);
return true;
}
struct ModuleEntry
{
readonly int metadataOffset;
readonly MetadataReader metadata;
readonly ModuleDefinitionHandle handle;
readonly ModuleDefinition module;
public int RID => MetadataTokens.GetRowNumber(handle);
public int Token => MetadataTokens.GetToken(handle);
public int Offset => metadataOffset
+ metadata.GetTableMetadataOffset(TableIndex.Module)
+ metadata.GetTableRowSize(TableIndex.Module) * (RID-1);
public int Generation => module.Generation;
public int NameStringHandle => MetadataTokens.GetHeapOffset(module.Name);
public string Name => metadata.GetString(module.Name);
public int Mvid => MetadataTokens.GetHeapOffset(module.Mvid);
public string MvidTooltip => metadata.GetGuid(module.Mvid).ToString();
public int GenerationId => MetadataTokens.GetHeapOffset(module.GenerationId);
public string GenerationIdTooltip => module.GenerationId.IsNil ? null : metadata.GetGuid(module.GenerationId).ToString();
public int BaseGenerationId => MetadataTokens.GetHeapOffset(module.BaseGenerationId);
public string BaseGenerationIdTooltip => module.BaseGenerationId.IsNil ? null : metadata.GetGuid(module.BaseGenerationId).ToString();
public ModuleEntry(int metadataOffset, MetadataReader metadata, ModuleDefinitionHandle handle, ModuleDefinition module)
{
this.metadataOffset = metadataOffset;
this.metadata = metadata;
this.handle = handle;
this.module = module;
}
}
public override void Decompile(Language language, ITextOutput output, DecompilationOptions options)
{
language.WriteCommentLine(output, "Modules");
}
}
}

20
ILSpy/Metadata/OptionalHeaderTreeNode.cs

@ -1,4 +1,22 @@ @@ -1,4 +1,22 @@
using System.Collections.Generic;
// 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.Collections.Generic;
using System.Reflection.PortableExecutable;
using System.Windows;
using System.Windows.Controls;

20
ILSpy/Metadata/StringHandleTemplate.cs

@ -1,4 +1,22 @@ @@ -1,4 +1,22 @@
using System;
// 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;
using System.Globalization;
using System.Windows;
using System.Windows.Controls;

89
ILSpy/Metadata/TypeRefTableTreeNode.cs

@ -1,89 +0,0 @@ @@ -1,89 +0,0 @@
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 TypeRefTableTreeNode : ILSpyTreeNode
{
private PEFile module;
public TypeRefTableTreeNode(PEFile module)
{
this.module = module;
}
public override object Text => $"01 TypeRef ({module.Metadata.GetTableRowCount(TableIndex.TypeRef)})";
public override object Icon => Images.Literal;
public override bool View(DecompilerTextView textView)
{
ListView view = Helpers.CreateListView("TypeRefsView");
var metadata = module.Metadata;
var list = new List<TypeRefEntry>();
foreach (var row in metadata.TypeReferences)
list.Add(new TypeRefEntry(module.Reader.PEHeaders.MetadataStartOffset, metadata, row, metadata.GetTypeReference(row)));
view.ItemsSource = list;
textView.ShowContent(new[] { this }, view);
return true;
}
struct TypeRefEntry
{
readonly int metadataOffset;
readonly MetadataReader metadata;
readonly TypeReferenceHandle handle;
readonly TypeReference typeRef;
public int RID => MetadataTokens.GetRowNumber(handle);
public int Token => MetadataTokens.GetToken(handle);
public int Offset => metadataOffset
+ metadata.GetTableMetadataOffset(TableIndex.TypeRef)
+ metadata.GetTableRowSize(TableIndex.TypeRef) * (RID-1);
public int ResolutionScope => MetadataTokens.GetToken(typeRef.ResolutionScope);
public int Name => MetadataTokens.GetHeapOffset(typeRef.Name);
public string NameTooltip => metadata.GetString(typeRef.Name);
public int Namespace => MetadataTokens.GetHeapOffset(typeRef.Namespace);
public string NamespaceTooltip => metadata.GetString(typeRef.Namespace);
public TypeRefEntry(int metadataOffset, MetadataReader metadata, TypeReferenceHandle handle, TypeReference typeRef)
{
this.metadataOffset = metadataOffset;
this.metadata = metadata;
this.handle = handle;
this.typeRef = typeRef;
}
}
public override void Decompile(Language language, ITextOutput output, DecompilationOptions options)
{
language.WriteCommentLine(output, "TypeRefs");
}
}
}
Loading…
Cancel
Save