diff --git a/ICSharpCode.Decompiler/Metadata/Dom.cs b/ICSharpCode.Decompiler/Metadata/Dom.cs index ff440f8dc..464781a0a 100644 --- a/ICSharpCode.Decompiler/Metadata/Dom.cs +++ b/ICSharpCode.Decompiler/Metadata/Dom.cs @@ -110,7 +110,7 @@ namespace ICSharpCode.Decompiler.Metadata } } - public sealed class FullTypeNameSignatureDecoder : ISignatureTypeProvider + public sealed class FullTypeNameSignatureDecoder : ISignatureTypeProvider, ICustomAttributeTypeProvider { readonly MetadataReader 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 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 diff --git a/ICSharpCode.Decompiler/Metadata/MetadataExtensions.cs b/ICSharpCode.Decompiler/Metadata/MetadataExtensions.cs index 7d8f06f34..7f3743a48 100644 --- a/ICSharpCode.Decompiler/Metadata/MetadataExtensions.cs +++ b/ICSharpCode.Decompiler/Metadata/MetadataExtensions.cs @@ -251,5 +251,76 @@ namespace ICSharpCode.Decompiler.Metadata yield return MetadataTokens.ModuleReferenceHandle(row); } } + + public static IEnumerable 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 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 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); + } } } diff --git a/ILSpy/ILSpy.csproj b/ILSpy/ILSpy.csproj index 1dd089b63..aa67ff964 100644 --- a/ILSpy/ILSpy.csproj +++ b/ILSpy/ILSpy.csproj @@ -160,18 +160,112 @@ + + Code + MSBuild:Compile + + + Code + MSBuild:Compile + + + Code + MSBuild:Compile + + + Code + MSBuild:Compile + + + Code + MSBuild:Compile + + + Code + MSBuild:Compile + + + Code + MSBuild:Compile + + + Code + MSBuild:Compile + + + Code + MSBuild:Compile + + + Code + MSBuild:Compile + + + Code + MSBuild:Compile + + + Code + MSBuild:Compile + + + Code + MSBuild:Compile + + + Code + MSBuild:Compile + + + Code + MSBuild:Compile + + + Code + MSBuild:Compile + + + Code + MSBuild:Compile + + + Code + MSBuild:Compile + + + Code + MSBuild:Compile + + + Code + MSBuild:Compile + + + Code + MSBuild:Compile + + + Code + MSBuild:Compile + + + Code + MSBuild:Compile + + + Code + MSBuild:Compile + + + Code + MSBuild:Compile + - - - - - - diff --git a/ILSpy/Metadata/CoffHeaderTreeNode.cs b/ILSpy/Metadata/CoffHeaderTreeNode.cs index 0055f52d0..6605511a0 100644 --- a/ILSpy/Metadata/CoffHeaderTreeNode.cs +++ b/ILSpy/Metadata/CoffHeaderTreeNode.cs @@ -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; diff --git a/ILSpy/Metadata/CorTables/AssemblyRefTableTreeNode.cs b/ILSpy/Metadata/CorTables/AssemblyRefTableTreeNode.cs new file mode 100644 index 000000000..c6908a268 --- /dev/null +++ b/ILSpy/Metadata/CorTables/AssemblyRefTableTreeNode.cs @@ -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(); + + 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 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"); + } + } +} \ No newline at end of file diff --git a/ILSpy/Metadata/CorTables/AssemblyTableTreeNode.cs b/ILSpy/Metadata/CorTables/AssemblyTableTreeNode.cs new file mode 100644 index 000000000..d98f98f26 --- /dev/null +++ b/ILSpy/Metadata/CorTables/AssemblyTableTreeNode.cs @@ -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(); + + 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"); + } + } +} \ No newline at end of file diff --git a/ILSpy/Metadata/CorTables/ConstantTableTreeNode.cs b/ILSpy/Metadata/CorTables/ConstantTableTreeNode.cs new file mode 100644 index 000000000..0a0e88acc --- /dev/null +++ b/ILSpy/Metadata/CorTables/ConstantTableTreeNode.cs @@ -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(); + + 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"); + } + } +} diff --git a/ILSpy/Metadata/CorTables/CustomAttributeTableTreeNode.cs b/ILSpy/Metadata/CorTables/CustomAttributeTableTreeNode.cs new file mode 100644 index 000000000..2269e79bc --- /dev/null +++ b/ILSpy/Metadata/CorTables/CustomAttributeTableTreeNode.cs @@ -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(); + + 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"); + } + } +} diff --git a/ILSpy/Metadata/CorTables/DeclSecurityTableTreeNode.cs b/ILSpy/Metadata/CorTables/DeclSecurityTableTreeNode.cs new file mode 100644 index 000000000..f337faa93 --- /dev/null +++ b/ILSpy/Metadata/CorTables/DeclSecurityTableTreeNode.cs @@ -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(); + + 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"); + } + } +} diff --git a/ILSpy/Metadata/CorTables/EventTableTreeNode.cs b/ILSpy/Metadata/CorTables/EventTableTreeNode.cs new file mode 100644 index 000000000..8e6b83195 --- /dev/null +++ b/ILSpy/Metadata/CorTables/EventTableTreeNode.cs @@ -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(); + + 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"); + } + } +} diff --git a/ILSpy/Metadata/ExportedTypeTableTreeNode.cs b/ILSpy/Metadata/CorTables/ExportedTypeTableTreeNode.cs similarity index 63% rename from ILSpy/Metadata/ExportedTypeTableTreeNode.cs rename to ILSpy/Metadata/CorTables/ExportedTypeTableTreeNode.cs index c5beb64af..3018e1449 100644 --- a/ILSpy/Metadata/ExportedTypeTableTreeNode.cs +++ b/ILSpy/Metadata/CorTables/ExportedTypeTableTreeNode.cs @@ -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 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); diff --git a/ILSpy/Metadata/CorTables/FieldLayoutTableTreeNode.cs b/ILSpy/Metadata/CorTables/FieldLayoutTableTreeNode.cs new file mode 100644 index 000000000..598f96c3a --- /dev/null +++ b/ILSpy/Metadata/CorTables/FieldLayoutTableTreeNode.cs @@ -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(); + + 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"); + } + } +} diff --git a/ILSpy/Metadata/FieldTableTreeNode.cs b/ILSpy/Metadata/CorTables/FieldTableTreeNode.cs similarity index 71% rename from ILSpy/Metadata/FieldTableTreeNode.cs rename to ILSpy/Metadata/CorTables/FieldTableTreeNode.cs index c7b0fe010..0ec838b5c 100644 --- a/ILSpy/Metadata/FieldTableTreeNode.cs +++ b/ILSpy/Metadata/CorTables/FieldTableTreeNode.cs @@ -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; diff --git a/ILSpy/Metadata/CorTables/FileTableTreeNode.cs b/ILSpy/Metadata/CorTables/FileTableTreeNode.cs new file mode 100644 index 000000000..ca1f19f93 --- /dev/null +++ b/ILSpy/Metadata/CorTables/FileTableTreeNode.cs @@ -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(); + + 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 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"); + } + } +} diff --git a/ILSpy/Metadata/CorTables/GenericParamConstraintTableTreeNode.cs b/ILSpy/Metadata/CorTables/GenericParamConstraintTableTreeNode.cs new file mode 100644 index 000000000..0b4964a51 --- /dev/null +++ b/ILSpy/Metadata/CorTables/GenericParamConstraintTableTreeNode.cs @@ -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(); + + 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"); + } + } +} \ No newline at end of file diff --git a/ILSpy/Metadata/CorTables/GenericParamTableTreeNode.cs b/ILSpy/Metadata/CorTables/GenericParamTableTreeNode.cs new file mode 100644 index 000000000..676ffbcae --- /dev/null +++ b/ILSpy/Metadata/CorTables/GenericParamTableTreeNode.cs @@ -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(); + + 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"); + } + } +} \ No newline at end of file diff --git a/ILSpy/Metadata/CorTables/ManifestResourceTableTreeNode.cs b/ILSpy/Metadata/CorTables/ManifestResourceTableTreeNode.cs new file mode 100644 index 000000000..23838fbfe --- /dev/null +++ b/ILSpy/Metadata/CorTables/ManifestResourceTableTreeNode.cs @@ -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(); + + 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"); + } + } +} diff --git a/ILSpy/Metadata/CorTables/MemberRefTableTreeNode.cs b/ILSpy/Metadata/CorTables/MemberRefTableTreeNode.cs new file mode 100644 index 000000000..b884adc61 --- /dev/null +++ b/ILSpy/Metadata/CorTables/MemberRefTableTreeNode.cs @@ -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(); + + 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"); + } + } +} diff --git a/ILSpy/Metadata/CorTables/MethodSemanticsTableTreeNode.cs b/ILSpy/Metadata/CorTables/MethodSemanticsTableTreeNode.cs new file mode 100644 index 000000000..4d0411421 --- /dev/null +++ b/ILSpy/Metadata/CorTables/MethodSemanticsTableTreeNode.cs @@ -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(); + + 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"); + } + } +} diff --git a/ILSpy/Metadata/CorTables/MethodSpecTableTreeNode.cs b/ILSpy/Metadata/CorTables/MethodSpecTableTreeNode.cs new file mode 100644 index 000000000..a58feae98 --- /dev/null +++ b/ILSpy/Metadata/CorTables/MethodSpecTableTreeNode.cs @@ -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(); + + 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"); + } + } +} \ No newline at end of file diff --git a/ILSpy/Metadata/MethodTableTreeNode.cs b/ILSpy/Metadata/CorTables/MethodTableTreeNode.cs similarity index 72% rename from ILSpy/Metadata/MethodTableTreeNode.cs rename to ILSpy/Metadata/CorTables/MethodTableTreeNode.cs index 18dfaae3c..8b815de54 100644 --- a/ILSpy/Metadata/MethodTableTreeNode.cs +++ b/ILSpy/Metadata/CorTables/MethodTableTreeNode.cs @@ -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; diff --git a/ILSpy/Metadata/CorTables/ModuleRefTableTreeNode.cs b/ILSpy/Metadata/CorTables/ModuleRefTableTreeNode.cs new file mode 100644 index 000000000..fe2eab8e6 --- /dev/null +++ b/ILSpy/Metadata/CorTables/ModuleRefTableTreeNode.cs @@ -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(); + + 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"); + } + } +} \ No newline at end of file diff --git a/ILSpy/Metadata/CorTables/ModuleTableTreeNode.cs b/ILSpy/Metadata/CorTables/ModuleTableTreeNode.cs new file mode 100644 index 000000000..972a29ea7 --- /dev/null +++ b/ILSpy/Metadata/CorTables/ModuleTableTreeNode.cs @@ -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(); + + 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"); + } + } +} \ No newline at end of file diff --git a/ILSpy/Metadata/CorTables/ParamTableTreeNode.cs b/ILSpy/Metadata/CorTables/ParamTableTreeNode.cs new file mode 100644 index 000000000..5d3d84103 --- /dev/null +++ b/ILSpy/Metadata/CorTables/ParamTableTreeNode.cs @@ -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(); + + 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"); + } + } +} \ No newline at end of file diff --git a/ILSpy/Metadata/CorTables/PropertyTableTreeNode.cs b/ILSpy/Metadata/CorTables/PropertyTableTreeNode.cs new file mode 100644 index 000000000..17b407101 --- /dev/null +++ b/ILSpy/Metadata/CorTables/PropertyTableTreeNode.cs @@ -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(); + + 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"); + } + } +} diff --git a/ILSpy/Metadata/CorTables/StandAloneSigTableTreeNode.cs b/ILSpy/Metadata/CorTables/StandAloneSigTableTreeNode.cs new file mode 100644 index 000000000..946f906ec --- /dev/null +++ b/ILSpy/Metadata/CorTables/StandAloneSigTableTreeNode.cs @@ -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(); + + 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"); + } + } +} diff --git a/ILSpy/Metadata/TypeDefTableTreeNode.cs b/ILSpy/Metadata/CorTables/TypeDefTableTreeNode.cs similarity index 77% rename from ILSpy/Metadata/TypeDefTableTreeNode.cs rename to ILSpy/Metadata/CorTables/TypeDefTableTreeNode.cs index df1a17fd6..5de470bab 100644 --- a/ILSpy/Metadata/TypeDefTableTreeNode.cs +++ b/ILSpy/Metadata/CorTables/TypeDefTableTreeNode.cs @@ -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; diff --git a/ILSpy/Metadata/CorTables/TypeRefTableTreeNode.cs b/ILSpy/Metadata/CorTables/TypeRefTableTreeNode.cs new file mode 100644 index 000000000..b1af0fd1d --- /dev/null +++ b/ILSpy/Metadata/CorTables/TypeRefTableTreeNode.cs @@ -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(); + + 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"); + } + } +} \ No newline at end of file diff --git a/ILSpy/Metadata/CorTables/TypeSpecTableTreeNode.cs b/ILSpy/Metadata/CorTables/TypeSpecTableTreeNode.cs new file mode 100644 index 000000000..8cf8e4165 --- /dev/null +++ b/ILSpy/Metadata/CorTables/TypeSpecTableTreeNode.cs @@ -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(); + + 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"); + } + } +} \ No newline at end of file diff --git a/ILSpy/Metadata/DataDirectoriesTreeNode.cs b/ILSpy/Metadata/DataDirectoriesTreeNode.cs index 3e1432514..09d371717 100644 --- a/ILSpy/Metadata/DataDirectoriesTreeNode.cs +++ b/ILSpy/Metadata/DataDirectoriesTreeNode.cs @@ -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; diff --git a/ILSpy/Metadata/DosHeaderTreeNode.cs b/ILSpy/Metadata/DosHeaderTreeNode.cs index 9fa4bddd5..24a690d3d 100644 --- a/ILSpy/Metadata/DosHeaderTreeNode.cs +++ b/ILSpy/Metadata/DosHeaderTreeNode.cs @@ -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; diff --git a/ILSpy/Metadata/EntityHandleTemplate.cs b/ILSpy/Metadata/EntityHandleTemplate.cs index fb153315b..25c913ec0 100644 --- a/ILSpy/Metadata/EntityHandleTemplate.cs +++ b/ILSpy/Metadata/EntityHandleTemplate.cs @@ -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 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); diff --git a/ILSpy/Metadata/Helpers.cs b/ILSpy/Metadata/Helpers.cs index fcd4abf4c..90eb31124 100644 --- a/ILSpy/Metadata/Helpers.cs +++ b/ILSpy/Metadata/Helpers.cs @@ -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; diff --git a/ILSpy/Metadata/MetadataTableViews.xaml b/ILSpy/Metadata/MetadataTableViews.xaml index df572c3b0..ec084b25e 100644 --- a/ILSpy/Metadata/MetadataTableViews.xaml +++ b/ILSpy/Metadata/MetadataTableViews.xaml @@ -1,9 +1,9 @@  + xmlns:local="clr-namespace:ICSharpCode.ILSpy.Metadata">