From 92a69cc12cbc2b3a8a6e93aa98c8c7083cdf8a88 Mon Sep 17 00:00:00 2001 From: Siegfried Pammer Date: Sat, 24 Jun 2023 15:56:48 +0200 Subject: [PATCH] Introduce ColumnKind enum. Rename StringFormatAttribute -> ColumnInfoAttribute. --- .../CorTables/AssemblyRefTableTreeNode.cs | 4 +-- .../CorTables/AssemblyTableTreeNode.cs | 4 +-- .../CorTables/ClassLayoutTableTreeNode.cs | 9 +++--- .../CorTables/ConstantTableTreeNode.cs | 7 ++--- .../CorTables/CustomAttributeTableTreeNode.cs | 8 ++--- .../CorTables/DeclSecurityTableTreeNode.cs | 7 ++--- .../CorTables/EventMapTableTreeNode.cs | 6 ++-- .../Metadata/CorTables/EventTableTreeNode.cs | 5 ++-- .../CorTables/ExportedTypeTableTreeNode.cs | 5 ++-- .../CorTables/FieldLayoutTableTreeNode.cs | 5 ++-- .../CorTables/FieldMarshalTableTreeNode.cs | 5 ++-- .../CorTables/FieldRVATableTreeNode.cs | 13 ++++---- .../Metadata/CorTables/FieldTableTreeNode.cs | 4 +-- ILSpy/Metadata/CorTables/FileTableTreeNode.cs | 4 +-- .../GenericParamConstraintTableTreeNode.cs | 6 ++-- .../CorTables/GenericParamTableTreeNode.cs | 5 ++-- .../CorTables/ImplMapTableTreeNode.cs | 8 ++--- .../CorTables/InterfaceImplTableTreeNode.cs | 6 ++-- .../ManifestResourceTableTreeNode.cs | 5 ++-- .../CorTables/MemberRefTableTreeNode.cs | 5 ++-- .../CorTables/MethodImplTableTreeNode.cs | 9 ++---- .../CorTables/MethodSemanticsTableTreeNode.cs | 8 ++--- .../CorTables/MethodSpecTableTreeNode.cs | 5 ++-- .../Metadata/CorTables/MethodTableTreeNode.cs | 6 ++-- .../Metadata/CorTables/ModuleTableTreeNode.cs | 6 ++-- .../CorTables/NestedClassTableTreeNode.cs | 6 ++-- .../Metadata/CorTables/ParamTableTreeNode.cs | 2 +- .../CorTables/PropertyMapTableTreeNode.cs | 6 ++-- .../CorTables/PropertyTableTreeNode.cs | 4 +-- .../CorTables/StandAloneSigTableTreeNode.cs | 2 +- .../CorTables/TypeDefTableTreeNode.cs | 11 +++---- .../CorTables/TypeRefTableTreeNode.cs | 3 +- .../CorTables/TypeSpecTableTreeNode.cs | 2 +- .../CustomDebugInformationTableTreeNode.cs | 5 ++-- .../DebugTables/DocumentTableTreeNode.cs | 6 ++-- .../DebugTables/ImportScopeTableTreeNode.cs | 5 ++-- .../DebugTables/LocalConstantTableTreeNode.cs | 2 +- .../DebugTables/LocalScopeTableTreeNode.cs | 12 +++----- .../DebugTables/LocalVariableTableTreeNode.cs | 2 +- .../MethodDebugInformationTableTreeNode.cs | 8 ++--- .../StateMachineMethodTableTreeNode.cs | 6 ++-- ILSpy/Metadata/GoToTokenCommand.cs | 2 +- ILSpy/Metadata/Helpers.cs | 30 ++++++++++++------- 43 files changed, 116 insertions(+), 153 deletions(-) diff --git a/ILSpy/Metadata/CorTables/AssemblyRefTableTreeNode.cs b/ILSpy/Metadata/CorTables/AssemblyRefTableTreeNode.cs index 4be8cd37a..4ad56815d 100644 --- a/ILSpy/Metadata/CorTables/AssemblyRefTableTreeNode.cs +++ b/ILSpy/Metadata/CorTables/AssemblyRefTableTreeNode.cs @@ -87,14 +87,14 @@ namespace ICSharpCode.ILSpy.Metadata public Version Version => assemblyRef.Version; - [StringFormat("X8")] + [ColumnInfo("X8", Kind = ColumnKind.Other)] public AssemblyFlags Flags => assemblyRef.Flags; public object FlagsTooltip => new FlagsTooltip((int)assemblyRef.Flags, null) { FlagGroup.CreateMultipleChoiceGroup(typeof(AssemblyFlags), selectedValue: (int)assemblyRef.Flags, includeAll: false) }; - [StringFormat("X")] + [ColumnInfo("X8", Kind = ColumnKind.HeapOffset)] public int PublicKeyOrToken => MetadataTokens.GetHeapOffset(assemblyRef.PublicKeyOrToken); public string PublicKeyOrTokenTooltip { diff --git a/ILSpy/Metadata/CorTables/AssemblyTableTreeNode.cs b/ILSpy/Metadata/CorTables/AssemblyTableTreeNode.cs index 4c16f6713..5d8409657 100644 --- a/ILSpy/Metadata/CorTables/AssemblyTableTreeNode.cs +++ b/ILSpy/Metadata/CorTables/AssemblyTableTreeNode.cs @@ -72,14 +72,14 @@ namespace ICSharpCode.ILSpy.Metadata + metadata.GetTableMetadataOffset(TableIndex.Assembly) + metadata.GetTableRowSize(TableIndex.Assembly) * (RID - 1); - [StringFormat("X4")] + [ColumnInfo("X4", Kind = ColumnKind.Other)] public AssemblyHashAlgorithm HashAlgorithm => assembly.HashAlgorithm; public object HashAlgorithmTooltip => new FlagsTooltip() { FlagGroup.CreateSingleChoiceGroup(typeof(AssemblyHashAlgorithm), selectedValue: (int)assembly.HashAlgorithm, defaultFlag: new Flag("None (0000)", 0, false), includeAny: false) }; - [StringFormat("X4")] + [ColumnInfo("X4", Kind = ColumnKind.Other)] public AssemblyFlags Flags => assembly.Flags; public object FlagsTooltip => new FlagsTooltip() { diff --git a/ILSpy/Metadata/CorTables/ClassLayoutTableTreeNode.cs b/ILSpy/Metadata/CorTables/ClassLayoutTableTreeNode.cs index 97be91596..9da461b58 100644 --- a/ILSpy/Metadata/CorTables/ClassLayoutTableTreeNode.cs +++ b/ILSpy/Metadata/CorTables/ClassLayoutTableTreeNode.cs @@ -100,8 +100,7 @@ namespace ICSharpCode.ILSpy.Metadata public int Offset { get; } - [StringFormat("X8")] - [LinkToTable] + [ColumnInfo("X8", Kind = ColumnKind.Token)] public int Parent => MetadataTokens.GetToken(classLayout.Parent); public void OnParentClick() @@ -113,15 +112,15 @@ namespace ICSharpCode.ILSpy.Metadata get { ITextOutput output = new PlainTextOutput(); var context = new MetadataGenericContext(default(TypeDefinitionHandle), module); - ((EntityHandle)classLayout.Parent).WriteTo(module, output, context); + classLayout.Parent.WriteTo(module, output, context); return output.ToString(); } } - [StringFormat("X4")] + [ColumnInfo("X4", Kind = ColumnKind.Other)] public ushort PackingSize => classLayout.PackingSize; - [StringFormat("X8")] + [ColumnInfo("X8", Kind = ColumnKind.Other)] public uint ClassSize => classLayout.ClassSize; public ClassLayoutEntry(PEFile module, byte* ptr, int metadataOffset, int row) diff --git a/ILSpy/Metadata/CorTables/ConstantTableTreeNode.cs b/ILSpy/Metadata/CorTables/ConstantTableTreeNode.cs index 0493abd8f..d7b30b4b8 100644 --- a/ILSpy/Metadata/CorTables/ConstantTableTreeNode.cs +++ b/ILSpy/Metadata/CorTables/ConstantTableTreeNode.cs @@ -87,13 +87,12 @@ namespace ICSharpCode.ILSpy.Metadata + metadata.GetTableMetadataOffset(TableIndex.Constant) + metadata.GetTableRowSize(TableIndex.Constant) * (RID - 1); - [StringFormat("X8")] + [ColumnInfo("X8", Kind = ColumnKind.Other)] public ConstantTypeCode Type => constant.TypeCode; public string TypeTooltip => constant.TypeCode.ToString(); - [StringFormat("X8")] - [LinkToTable] + [ColumnInfo("X8", Kind = ColumnKind.Token)] public int Parent => MetadataTokens.GetToken(constant.Parent); public void OnParentClick() @@ -110,7 +109,7 @@ namespace ICSharpCode.ILSpy.Metadata } } - [StringFormat("X")] + [ColumnInfo("X8", Kind = ColumnKind.HeapOffset)] public int Value => MetadataTokens.GetHeapOffset(constant.Value); public string ValueTooltip { diff --git a/ILSpy/Metadata/CorTables/CustomAttributeTableTreeNode.cs b/ILSpy/Metadata/CorTables/CustomAttributeTableTreeNode.cs index 4070ad9be..7691be4b8 100644 --- a/ILSpy/Metadata/CorTables/CustomAttributeTableTreeNode.cs +++ b/ILSpy/Metadata/CorTables/CustomAttributeTableTreeNode.cs @@ -87,8 +87,7 @@ namespace ICSharpCode.ILSpy.Metadata + metadata.GetTableMetadataOffset(TableIndex.CustomAttribute) + metadata.GetTableRowSize(TableIndex.CustomAttribute) * (RID - 1); - [StringFormat("X8")] - [LinkToTable] + [ColumnInfo("X8", Kind = ColumnKind.Token)] public int Parent => MetadataTokens.GetToken(customAttr.Parent); public void OnParentClick() @@ -105,8 +104,7 @@ namespace ICSharpCode.ILSpy.Metadata } } - [StringFormat("X8")] - [LinkToTable] + [ColumnInfo("X8", Kind = ColumnKind.Token)] public int Constructor => MetadataTokens.GetToken(customAttr.Constructor); public void OnConstructorClick() @@ -123,7 +121,7 @@ namespace ICSharpCode.ILSpy.Metadata } } - [StringFormat("X")] + [ColumnInfo("X8", Kind = ColumnKind.HeapOffset)] public int Value => MetadataTokens.GetHeapOffset(customAttr.Value); public string ValueTooltip { diff --git a/ILSpy/Metadata/CorTables/DeclSecurityTableTreeNode.cs b/ILSpy/Metadata/CorTables/DeclSecurityTableTreeNode.cs index bcfb719ad..8e3b82330 100644 --- a/ILSpy/Metadata/CorTables/DeclSecurityTableTreeNode.cs +++ b/ILSpy/Metadata/CorTables/DeclSecurityTableTreeNode.cs @@ -88,8 +88,7 @@ namespace ICSharpCode.ILSpy.Metadata + metadata.GetTableMetadataOffset(TableIndex.DeclSecurity) + metadata.GetTableRowSize(TableIndex.DeclSecurity) * (RID - 1); - [StringFormat("X8")] - [LinkToTable] + [ColumnInfo("X8", Kind = ColumnKind.Token)] public int Parent => MetadataTokens.GetToken(declSecAttr.Parent); public void OnParentClick() @@ -106,7 +105,7 @@ namespace ICSharpCode.ILSpy.Metadata } } - [StringFormat("X8")] + [ColumnInfo("X8", Kind = ColumnKind.Other)] public DeclarativeSecurityAction Action => declSecAttr.Action; public string ActionTooltip { @@ -115,7 +114,7 @@ namespace ICSharpCode.ILSpy.Metadata } } - [StringFormat("X")] + [ColumnInfo("X8", Kind = ColumnKind.HeapOffset)] public int PermissionSet => MetadataTokens.GetHeapOffset(declSecAttr.PermissionSet); public string PermissionSetTooltip { diff --git a/ILSpy/Metadata/CorTables/EventMapTableTreeNode.cs b/ILSpy/Metadata/CorTables/EventMapTableTreeNode.cs index d25738f72..6cf0f9349 100644 --- a/ILSpy/Metadata/CorTables/EventMapTableTreeNode.cs +++ b/ILSpy/Metadata/CorTables/EventMapTableTreeNode.cs @@ -98,8 +98,7 @@ namespace ICSharpCode.ILSpy.Metadata public int Offset { get; } - [StringFormat("X8")] - [LinkToTable] + [ColumnInfo("X8", Kind = ColumnKind.Token)] public int Parent => MetadataTokens.GetToken(eventMap.Parent); public void OnParentClick() @@ -116,8 +115,7 @@ namespace ICSharpCode.ILSpy.Metadata } } - [StringFormat("X8")] - [LinkToTable] + [ColumnInfo("X8", Kind = ColumnKind.Token)] public int EventList => MetadataTokens.GetToken(eventMap.EventList); public void OnEventListClick() diff --git a/ILSpy/Metadata/CorTables/EventTableTreeNode.cs b/ILSpy/Metadata/CorTables/EventTableTreeNode.cs index 4ed3b9a84..dabcb7cc4 100644 --- a/ILSpy/Metadata/CorTables/EventTableTreeNode.cs +++ b/ILSpy/Metadata/CorTables/EventTableTreeNode.cs @@ -90,7 +90,7 @@ namespace ICSharpCode.ILSpy.Metadata + metadata.GetTableMetadataOffset(TableIndex.Event) + metadata.GetTableRowSize(TableIndex.Event) * (RID - 1); - [StringFormat("X8")] + [ColumnInfo("X8", Kind = ColumnKind.Other)] public EventAttributes Attributes => eventDef.Attributes; public object AttributesTooltip => new FlagsTooltip { @@ -103,8 +103,7 @@ namespace ICSharpCode.ILSpy.Metadata IEntity IMemberTreeNode.Member => ((MetadataModule)module.GetTypeSystemWithCurrentOptionsOrNull()?.MainModule).GetDefinition(handle); - [StringFormat("X8")] - [LinkToTable] + [ColumnInfo("X8", Kind = ColumnKind.Token)] public int Type => MetadataTokens.GetToken(eventDef.Type); public void OnTypeClick() diff --git a/ILSpy/Metadata/CorTables/ExportedTypeTableTreeNode.cs b/ILSpy/Metadata/CorTables/ExportedTypeTableTreeNode.cs index fee2aff10..878024a00 100644 --- a/ILSpy/Metadata/CorTables/ExportedTypeTableTreeNode.cs +++ b/ILSpy/Metadata/CorTables/ExportedTypeTableTreeNode.cs @@ -86,7 +86,7 @@ namespace ICSharpCode.ILSpy.Metadata + metadata.GetTableMetadataOffset(TableIndex.ExportedType) + metadata.GetTableRowSize(TableIndex.ExportedType) * (RID - 1); - [StringFormat("X8")] + [ColumnInfo("X8", Kind = ColumnKind.Other)] public TypeAttributes Attributes => type.Attributes; const TypeAttributes otherFlagsMask = ~(TypeAttributes.VisibilityMask | TypeAttributes.LayoutMask | TypeAttributes.ClassSemanticsMask | TypeAttributes.StringFormatMask | TypeAttributes.CustomFormatMask); @@ -110,8 +110,7 @@ namespace ICSharpCode.ILSpy.Metadata public string TypeNamespace => metadata.GetString(type.Namespace); - [StringFormat("X8")] - [LinkToTable] + [ColumnInfo("X8", Kind = ColumnKind.Token)] public int Implementation => MetadataTokens.GetToken(type.Implementation); public void OnImplementationClick() diff --git a/ILSpy/Metadata/CorTables/FieldLayoutTableTreeNode.cs b/ILSpy/Metadata/CorTables/FieldLayoutTableTreeNode.cs index d959a49b6..c5aa00d71 100644 --- a/ILSpy/Metadata/CorTables/FieldLayoutTableTreeNode.cs +++ b/ILSpy/Metadata/CorTables/FieldLayoutTableTreeNode.cs @@ -98,8 +98,7 @@ namespace ICSharpCode.ILSpy.Metadata public int Offset { get; } - [StringFormat("X8")] - [LinkToTable] + [ColumnInfo("X8", Kind = ColumnKind.Token)] public int Field => MetadataTokens.GetToken(fieldLayout.Field); public void OnFieldClick() @@ -116,7 +115,7 @@ namespace ICSharpCode.ILSpy.Metadata } } - [StringFormat("X")] + [ColumnInfo("X8", Kind = ColumnKind.Other)] public int FieldOffset => fieldLayout.Offset; public FieldLayoutEntry(PEFile module, byte* ptr, int metadataOffset, int row) diff --git a/ILSpy/Metadata/CorTables/FieldMarshalTableTreeNode.cs b/ILSpy/Metadata/CorTables/FieldMarshalTableTreeNode.cs index a4d74b9bc..b85d3c5ec 100644 --- a/ILSpy/Metadata/CorTables/FieldMarshalTableTreeNode.cs +++ b/ILSpy/Metadata/CorTables/FieldMarshalTableTreeNode.cs @@ -98,8 +98,7 @@ namespace ICSharpCode.ILSpy.Metadata public int Offset { get; } - [StringFormat("X8")] - [LinkToTable] + [ColumnInfo("X8", Kind = ColumnKind.Token)] public int Parent => MetadataTokens.GetToken(fieldMarshal.Parent); public void OnParentClick() @@ -116,7 +115,7 @@ namespace ICSharpCode.ILSpy.Metadata } } - [StringFormat("X")] + [ColumnInfo("X8", Kind = ColumnKind.HeapOffset)] public int NativeType => MetadataTokens.GetHeapOffset(fieldMarshal.NativeType); public FieldMarshalEntry(PEFile module, byte* ptr, int metadataOffset, int row) diff --git a/ILSpy/Metadata/CorTables/FieldRVATableTreeNode.cs b/ILSpy/Metadata/CorTables/FieldRVATableTreeNode.cs index c0d54a023..890b71cdf 100644 --- a/ILSpy/Metadata/CorTables/FieldRVATableTreeNode.cs +++ b/ILSpy/Metadata/CorTables/FieldRVATableTreeNode.cs @@ -90,7 +90,7 @@ namespace ICSharpCode.ILSpy.Metadata { readonly PEFile module; readonly MetadataReader metadata; - readonly FieldRVA fieldLayout; + readonly FieldRVA fieldRVA; public int RID { get; } @@ -98,13 +98,12 @@ namespace ICSharpCode.ILSpy.Metadata public int Offset { get; } - [StringFormat("X8")] - [LinkToTable] - public int Field => MetadataTokens.GetToken(fieldLayout.Field); + [ColumnInfo("X8", Kind = ColumnKind.Token)] + public int Field => MetadataTokens.GetToken(fieldRVA.Field); public void OnFieldClick() { - MainWindow.Instance.JumpToReference(new EntityReference(module, fieldLayout.Field, protocol: "metadata")); + MainWindow.Instance.JumpToReference(new EntityReference(module, fieldRVA.Field, protocol: "metadata")); } public string FieldTooltip { @@ -116,8 +115,8 @@ namespace ICSharpCode.ILSpy.Metadata } } - [StringFormat("X")] - public int FieldOffset => fieldLayout.Offset; + [ColumnInfo("X8", Kind = ColumnKind.Other)] + public int FieldOffset => fieldRVA.Offset; public FieldRVAEntry(PEFile module, byte* ptr, int metadataOffset, int row) { diff --git a/ILSpy/Metadata/CorTables/FieldTableTreeNode.cs b/ILSpy/Metadata/CorTables/FieldTableTreeNode.cs index bdc927b28..73eceefa1 100644 --- a/ILSpy/Metadata/CorTables/FieldTableTreeNode.cs +++ b/ILSpy/Metadata/CorTables/FieldTableTreeNode.cs @@ -94,7 +94,7 @@ namespace ICSharpCode.ILSpy.Metadata + metadata.GetTableMetadataOffset(TableIndex.Field) + metadata.GetTableRowSize(TableIndex.Field) * (RID - 1); - [StringFormat("X8")] + [ColumnInfo("X8", Kind = ColumnKind.Other)] public FieldAttributes Attributes => fieldDef.Attributes; const FieldAttributes otherFlagsMask = ~(FieldAttributes.FieldAccessMask); @@ -110,7 +110,7 @@ namespace ICSharpCode.ILSpy.Metadata IEntity IMemberTreeNode.Member => ((MetadataModule)module.GetTypeSystemWithCurrentOptionsOrNull()?.MainModule).GetDefinition(handle); - [StringFormat("X")] + [ColumnInfo("X8", Kind = ColumnKind.HeapOffset)] public int Signature => MetadataTokens.GetHeapOffset(fieldDef.Signature); public string SignatureTooltip { diff --git a/ILSpy/Metadata/CorTables/FileTableTreeNode.cs b/ILSpy/Metadata/CorTables/FileTableTreeNode.cs index c48b8890b..ddf0e5189 100644 --- a/ILSpy/Metadata/CorTables/FileTableTreeNode.cs +++ b/ILSpy/Metadata/CorTables/FileTableTreeNode.cs @@ -85,7 +85,7 @@ namespace ICSharpCode.ILSpy.Metadata + metadata.GetTableMetadataOffset(TableIndex.File) + metadata.GetTableRowSize(TableIndex.File) * (RID - 1); - [StringFormat("X8")] + [ColumnInfo("X8", Kind = ColumnKind.Other)] public int Attributes => assemblyFile.ContainsMetadata ? 1 : 0; public string AttributesTooltip => assemblyFile.ContainsMetadata ? "ContainsMetaData" : "ContainsNoMetaData"; @@ -94,7 +94,7 @@ namespace ICSharpCode.ILSpy.Metadata public string NameTooltip => $"{MetadataTokens.GetHeapOffset(assemblyFile.Name):X} \"{Name}\""; - [StringFormat("X")] + [ColumnInfo("X8", Kind = ColumnKind.HeapOffset)] public int HashValue => MetadataTokens.GetHeapOffset(assemblyFile.HashValue); public string HashValueTooltip { diff --git a/ILSpy/Metadata/CorTables/GenericParamConstraintTableTreeNode.cs b/ILSpy/Metadata/CorTables/GenericParamConstraintTableTreeNode.cs index 760cb2df1..4fcf1bc66 100644 --- a/ILSpy/Metadata/CorTables/GenericParamConstraintTableTreeNode.cs +++ b/ILSpy/Metadata/CorTables/GenericParamConstraintTableTreeNode.cs @@ -86,8 +86,7 @@ namespace ICSharpCode.ILSpy.Metadata + metadata.GetTableMetadataOffset(TableIndex.GenericParamConstraint) + metadata.GetTableRowSize(TableIndex.GenericParamConstraint) * (RID - 1); - [StringFormat("X8")] - [LinkToTable] + [ColumnInfo("X8", Kind = ColumnKind.Token)] public int Owner => MetadataTokens.GetToken(genericParamConstraint.Parameter); public void OnOwnerClick() @@ -111,8 +110,7 @@ namespace ICSharpCode.ILSpy.Metadata } } - [StringFormat("X8")] - [LinkToTable] + [ColumnInfo("X8", Kind = ColumnKind.Token)] public int Type => MetadataTokens.GetToken(genericParamConstraint.Type); public void OnTypeClick() diff --git a/ILSpy/Metadata/CorTables/GenericParamTableTreeNode.cs b/ILSpy/Metadata/CorTables/GenericParamTableTreeNode.cs index 5bb682d2b..fd1590817 100644 --- a/ILSpy/Metadata/CorTables/GenericParamTableTreeNode.cs +++ b/ILSpy/Metadata/CorTables/GenericParamTableTreeNode.cs @@ -88,7 +88,7 @@ namespace ICSharpCode.ILSpy.Metadata public int Number => genericParam.Index; - [StringFormat("X8")] + [ColumnInfo("X8", Kind = ColumnKind.Other)] public GenericParameterAttributes Attributes => genericParam.Attributes; public object AttributesTooltip => new FlagsTooltip { @@ -96,8 +96,7 @@ namespace ICSharpCode.ILSpy.Metadata FlagGroup.CreateSingleChoiceGroup(typeof(GenericParameterAttributes), "Managed type: ", (int)GenericParameterAttributes.SpecialConstraintMask, (int)(genericParam.Attributes & GenericParameterAttributes.SpecialConstraintMask), new Flag("None (0000)", 0, false), includeAny: false), }; - [StringFormat("X8")] - [LinkToTable] + [ColumnInfo("X8", Kind = ColumnKind.Token)] public int Owner => MetadataTokens.GetToken(genericParam.Parent); public void OnParentClick() diff --git a/ILSpy/Metadata/CorTables/ImplMapTableTreeNode.cs b/ILSpy/Metadata/CorTables/ImplMapTableTreeNode.cs index ccfd7801b..8ad12af71 100644 --- a/ILSpy/Metadata/CorTables/ImplMapTableTreeNode.cs +++ b/ILSpy/Metadata/CorTables/ImplMapTableTreeNode.cs @@ -104,7 +104,7 @@ namespace ICSharpCode.ILSpy.Metadata public int Offset { get; } - [StringFormat("X8")] + [ColumnInfo("X8", Kind = ColumnKind.Other)] public PInvokeAttributes MappingFlags => implMap.MappingFlags; const PInvokeAttributes otherFlagsMask = ~(PInvokeAttributes.CallConvMask | PInvokeAttributes.CharSetMask); @@ -115,8 +115,7 @@ namespace ICSharpCode.ILSpy.Metadata FlagGroup.CreateMultipleChoiceGroup(typeof(PInvokeAttributes), "Flags:", (int)otherFlagsMask, (int)(implMap.MappingFlags & otherFlagsMask), includeAll: false), }; - [StringFormat("X8")] - [LinkToTable] + [ColumnInfo("X8", Kind = ColumnKind.Token)] public int MemberForwarded => MetadataTokens.GetToken(implMap.MemberForwarded); public void OnMemberForwardedClick() @@ -133,8 +132,7 @@ namespace ICSharpCode.ILSpy.Metadata } } - [StringFormat("X8")] - [LinkToTable] + [ColumnInfo("X8", Kind = ColumnKind.Token)] public int ImportScope => MetadataTokens.GetToken(implMap.ImportScope); public void OnImportScopeClick() diff --git a/ILSpy/Metadata/CorTables/InterfaceImplTableTreeNode.cs b/ILSpy/Metadata/CorTables/InterfaceImplTableTreeNode.cs index 6f5090032..8764c1c5a 100644 --- a/ILSpy/Metadata/CorTables/InterfaceImplTableTreeNode.cs +++ b/ILSpy/Metadata/CorTables/InterfaceImplTableTreeNode.cs @@ -98,8 +98,7 @@ namespace ICSharpCode.ILSpy.Metadata public int Offset { get; } - [StringFormat("X8")] - [LinkToTable] + [ColumnInfo("X8", Kind = ColumnKind.Token)] public int Class => MetadataTokens.GetToken(interfaceImpl.Class); public void OnClassClick() @@ -116,8 +115,7 @@ namespace ICSharpCode.ILSpy.Metadata } } - [StringFormat("X8")] - [LinkToTable] + [ColumnInfo("X8", Kind = ColumnKind.Token)] public int Interface => MetadataTokens.GetToken(interfaceImpl.Interface); public void OnInterfaceClick() diff --git a/ILSpy/Metadata/CorTables/ManifestResourceTableTreeNode.cs b/ILSpy/Metadata/CorTables/ManifestResourceTableTreeNode.cs index e720ee1c1..0d9619cd9 100644 --- a/ILSpy/Metadata/CorTables/ManifestResourceTableTreeNode.cs +++ b/ILSpy/Metadata/CorTables/ManifestResourceTableTreeNode.cs @@ -88,7 +88,7 @@ namespace ICSharpCode.ILSpy.Metadata + metadata.GetTableMetadataOffset(TableIndex.ManifestResource) + metadata.GetTableRowSize(TableIndex.ManifestResource) * (RID - 1); - [StringFormat("X8")] + [ColumnInfo("X8", Kind = ColumnKind.Other)] public ManifestResourceAttributes Attributes => manifestResource.Attributes; public object AttributesTooltip => manifestResource.Attributes.ToString(); @@ -97,8 +97,7 @@ namespace ICSharpCode.ILSpy.Metadata public string NameTooltip => $"{MetadataTokens.GetHeapOffset(manifestResource.Name):X} \"{Name}\""; - [StringFormat("X8")] - [LinkToTable] + [ColumnInfo("X8", Kind = ColumnKind.Token)] public int Implementation => MetadataTokens.GetToken(manifestResource.Implementation); public void OnImplementationClick() diff --git a/ILSpy/Metadata/CorTables/MemberRefTableTreeNode.cs b/ILSpy/Metadata/CorTables/MemberRefTableTreeNode.cs index 5c4987846..e4701270f 100644 --- a/ILSpy/Metadata/CorTables/MemberRefTableTreeNode.cs +++ b/ILSpy/Metadata/CorTables/MemberRefTableTreeNode.cs @@ -87,8 +87,7 @@ namespace ICSharpCode.ILSpy.Metadata + metadata.GetTableMetadataOffset(TableIndex.MemberRef) + metadata.GetTableRowSize(TableIndex.MemberRef) * (RID - 1); - [StringFormat("X8")] - [LinkToTable] + [ColumnInfo("X8", Kind = ColumnKind.Token)] public int Parent => MetadataTokens.GetToken(memberRef.Parent); public void OnParentClick() @@ -108,7 +107,7 @@ namespace ICSharpCode.ILSpy.Metadata public string NameTooltip => $"{MetadataTokens.GetHeapOffset(memberRef.Name):X} \"{Name}\""; - [StringFormat("X")] + [ColumnInfo("X8", Kind = ColumnKind.HeapOffset)] public int Signature => MetadataTokens.GetHeapOffset(memberRef.Signature); public string SignatureTooltip { diff --git a/ILSpy/Metadata/CorTables/MethodImplTableTreeNode.cs b/ILSpy/Metadata/CorTables/MethodImplTableTreeNode.cs index bd7292df8..8b761b27d 100644 --- a/ILSpy/Metadata/CorTables/MethodImplTableTreeNode.cs +++ b/ILSpy/Metadata/CorTables/MethodImplTableTreeNode.cs @@ -86,8 +86,7 @@ namespace ICSharpCode.ILSpy.Metadata + metadata.GetTableMetadataOffset(TableIndex.MethodDef) + metadata.GetTableRowSize(TableIndex.MethodDef) * (RID - 1); - [StringFormat("X8")] - [LinkToTable] + [ColumnInfo("X8", Kind = ColumnKind.Token)] public int MethodDeclaration => MetadataTokens.GetToken(methodImpl.MethodDeclaration); public void OnMethodDeclarationClick() @@ -103,8 +102,7 @@ namespace ICSharpCode.ILSpy.Metadata } } - [StringFormat("X8")] - [LinkToTable] + [ColumnInfo("X8", Kind = ColumnKind.Token)] public int MethodBody => MetadataTokens.GetToken(methodImpl.MethodBody); public void OnMethodBodyClick() @@ -120,8 +118,7 @@ namespace ICSharpCode.ILSpy.Metadata } } - [StringFormat("X8")] - [LinkToTable] + [ColumnInfo("X8", Kind = ColumnKind.Token)] public int Type => MetadataTokens.GetToken(methodImpl.Type); public void OnTypeClick() diff --git a/ILSpy/Metadata/CorTables/MethodSemanticsTableTreeNode.cs b/ILSpy/Metadata/CorTables/MethodSemanticsTableTreeNode.cs index 73316effc..6956e0cc6 100644 --- a/ILSpy/Metadata/CorTables/MethodSemanticsTableTreeNode.cs +++ b/ILSpy/Metadata/CorTables/MethodSemanticsTableTreeNode.cs @@ -90,13 +90,12 @@ namespace ICSharpCode.ILSpy.Metadata + metadata.GetTableMetadataOffset(TableIndex.MethodDef) + metadata.GetTableRowSize(TableIndex.MethodDef) * (RID - 1); - [StringFormat("X8")] + [ColumnInfo("X8", Kind = ColumnKind.Other)] public MethodSemanticsAttributes Semantics => semantics; public string SemanticsTooltip => semantics.ToString(); - [StringFormat("X8")] - [LinkToTable] + [ColumnInfo("X8", Kind = ColumnKind.Token)] public int Method => MetadataTokens.GetToken(method); public void OnMethodClick() @@ -112,8 +111,7 @@ namespace ICSharpCode.ILSpy.Metadata } } - [StringFormat("X8")] - [LinkToTable] + [ColumnInfo("X8", Kind = ColumnKind.Token)] public int Association => MetadataTokens.GetToken(association); public void OnAssociationClick() diff --git a/ILSpy/Metadata/CorTables/MethodSpecTableTreeNode.cs b/ILSpy/Metadata/CorTables/MethodSpecTableTreeNode.cs index 702f66594..780b502ef 100644 --- a/ILSpy/Metadata/CorTables/MethodSpecTableTreeNode.cs +++ b/ILSpy/Metadata/CorTables/MethodSpecTableTreeNode.cs @@ -87,8 +87,7 @@ namespace ICSharpCode.ILSpy.Metadata + metadata.GetTableMetadataOffset(TableIndex.MethodSpec) + metadata.GetTableRowSize(TableIndex.MethodSpec) * (RID - 1); - [StringFormat("X8")] - [LinkToTable] + [ColumnInfo("X8", Kind = ColumnKind.Token)] public int Method => MetadataTokens.GetToken(methodSpec.Method); public void OnMethodClick() @@ -104,7 +103,7 @@ namespace ICSharpCode.ILSpy.Metadata } } - [StringFormat("X")] + [ColumnInfo("X8", Kind = ColumnKind.HeapOffset)] public int Signature => MetadataTokens.GetHeapOffset(methodSpec.Signature); public string SignatureTooltip { diff --git a/ILSpy/Metadata/CorTables/MethodTableTreeNode.cs b/ILSpy/Metadata/CorTables/MethodTableTreeNode.cs index c1b1160f2..639e6f025 100644 --- a/ILSpy/Metadata/CorTables/MethodTableTreeNode.cs +++ b/ILSpy/Metadata/CorTables/MethodTableTreeNode.cs @@ -92,7 +92,7 @@ namespace ICSharpCode.ILSpy.Metadata + metadata.GetTableMetadataOffset(TableIndex.MethodDef) + metadata.GetTableRowSize(TableIndex.MethodDef) * (RID - 1); - [StringFormat("X8")] + [ColumnInfo("X8", Kind = ColumnKind.Other)] public MethodAttributes Attributes => methodDef.Attributes; const MethodAttributes otherFlagsMask = ~(MethodAttributes.MemberAccessMask | MethodAttributes.VtableLayoutMask); @@ -103,7 +103,7 @@ namespace ICSharpCode.ILSpy.Metadata FlagGroup.CreateMultipleChoiceGroup(typeof(MethodAttributes), "Flags:", (int)otherFlagsMask, (int)(methodDef.Attributes & otherFlagsMask), includeAll: false), }; - [StringFormat("X8")] + [ColumnInfo("X8", Kind = ColumnKind.Other)] public MethodImplAttributes ImplAttributes => methodDef.ImplAttributes; public object ImplAttributesTooltip => new FlagsTooltip { @@ -117,7 +117,7 @@ namespace ICSharpCode.ILSpy.Metadata public string NameTooltip => $"{MetadataTokens.GetHeapOffset(methodDef.Name):X} \"{Name}\""; - [StringFormat("X")] + [ColumnInfo("X8", Kind = ColumnKind.HeapOffset)] public int Signature => MetadataTokens.GetHeapOffset(methodDef.Signature); string signatureTooltip; diff --git a/ILSpy/Metadata/CorTables/ModuleTableTreeNode.cs b/ILSpy/Metadata/CorTables/ModuleTableTreeNode.cs index b86387ecd..ba6509426 100644 --- a/ILSpy/Metadata/CorTables/ModuleTableTreeNode.cs +++ b/ILSpy/Metadata/CorTables/ModuleTableTreeNode.cs @@ -82,17 +82,17 @@ namespace ICSharpCode.ILSpy.Metadata public string NameTooltip => $"{MetadataTokens.GetHeapOffset(moduleDef.Name):X} \"{Name}\""; - [StringFormat("X")] + [ColumnInfo("X8", Kind = ColumnKind.HeapOffset)] public int Mvid => MetadataTokens.GetHeapOffset(moduleDef.Mvid); public string MvidTooltip => metadata.GetGuid(moduleDef.Mvid).ToString(); - [StringFormat("X")] + [ColumnInfo("X8", Kind = ColumnKind.HeapOffset)] public int GenerationId => MetadataTokens.GetHeapOffset(moduleDef.GenerationId); public string GenerationIdTooltip => moduleDef.GenerationId.IsNil ? null : metadata.GetGuid(moduleDef.GenerationId).ToString(); - [StringFormat("X")] + [ColumnInfo("X8", Kind = ColumnKind.HeapOffset)] public int BaseGenerationId => MetadataTokens.GetHeapOffset(moduleDef.BaseGenerationId); public string BaseGenerationIdTooltip => moduleDef.BaseGenerationId.IsNil ? null : metadata.GetGuid(moduleDef.BaseGenerationId).ToString(); diff --git a/ILSpy/Metadata/CorTables/NestedClassTableTreeNode.cs b/ILSpy/Metadata/CorTables/NestedClassTableTreeNode.cs index d9560ab7e..dda3ad8e1 100644 --- a/ILSpy/Metadata/CorTables/NestedClassTableTreeNode.cs +++ b/ILSpy/Metadata/CorTables/NestedClassTableTreeNode.cs @@ -98,8 +98,7 @@ namespace ICSharpCode.ILSpy.Metadata public int Offset { get; } - [StringFormat("X8")] - [LinkToTable] + [ColumnInfo("X8", Kind = ColumnKind.Token)] public int NestedClass => MetadataTokens.GetToken(nestedClass.Nested); public void OnNestedClassClick() @@ -116,8 +115,7 @@ namespace ICSharpCode.ILSpy.Metadata } } - [StringFormat("X8")] - [LinkToTable] + [ColumnInfo("X8", Kind = ColumnKind.Token)] public int EnclosingClass => MetadataTokens.GetToken(nestedClass.Enclosing); public void OnEnclosingClassClick() diff --git a/ILSpy/Metadata/CorTables/ParamTableTreeNode.cs b/ILSpy/Metadata/CorTables/ParamTableTreeNode.cs index 5aea6118d..5fee320ee 100644 --- a/ILSpy/Metadata/CorTables/ParamTableTreeNode.cs +++ b/ILSpy/Metadata/CorTables/ParamTableTreeNode.cs @@ -85,7 +85,7 @@ namespace ICSharpCode.ILSpy.Metadata + metadata.GetTableMetadataOffset(TableIndex.Param) + metadata.GetTableRowSize(TableIndex.Param) * (RID - 1); - [StringFormat("X8")] + [ColumnInfo("X8", Kind = ColumnKind.Other)] public ParameterAttributes Attributes => param.Attributes; public object AttributesTooltip => new FlagsTooltip { diff --git a/ILSpy/Metadata/CorTables/PropertyMapTableTreeNode.cs b/ILSpy/Metadata/CorTables/PropertyMapTableTreeNode.cs index c4291171f..b34023f2a 100644 --- a/ILSpy/Metadata/CorTables/PropertyMapTableTreeNode.cs +++ b/ILSpy/Metadata/CorTables/PropertyMapTableTreeNode.cs @@ -98,8 +98,7 @@ namespace ICSharpCode.ILSpy.Metadata public int Offset { get; } - [StringFormat("X8")] - [LinkToTable] + [ColumnInfo("X8", Kind = ColumnKind.Token)] public int Parent => MetadataTokens.GetToken(propertyMap.Parent); public void OnParentClick() @@ -116,8 +115,7 @@ namespace ICSharpCode.ILSpy.Metadata } } - [StringFormat("X8")] - [LinkToTable] + [ColumnInfo("X8", Kind = ColumnKind.Token)] public int PropertyList => MetadataTokens.GetToken(propertyMap.PropertyList); public void OnPropertyListClick() diff --git a/ILSpy/Metadata/CorTables/PropertyTableTreeNode.cs b/ILSpy/Metadata/CorTables/PropertyTableTreeNode.cs index 39c380806..0b428934e 100644 --- a/ILSpy/Metadata/CorTables/PropertyTableTreeNode.cs +++ b/ILSpy/Metadata/CorTables/PropertyTableTreeNode.cs @@ -90,7 +90,7 @@ namespace ICSharpCode.ILSpy.Metadata + metadata.GetTableMetadataOffset(TableIndex.Property) + metadata.GetTableRowSize(TableIndex.Property) * (RID - 1); - [StringFormat("X8")] + [ColumnInfo("X8", Kind = ColumnKind.Other)] public PropertyAttributes Attributes => propertyDef.Attributes; public object AttributesTooltip => new FlagsTooltip { @@ -103,7 +103,7 @@ namespace ICSharpCode.ILSpy.Metadata IEntity IMemberTreeNode.Member => ((MetadataModule)module.GetTypeSystemWithCurrentOptionsOrNull()?.MainModule).GetDefinition(handle); - [StringFormat("X")] + [ColumnInfo("X8", Kind = ColumnKind.HeapOffset)] public int Signature => MetadataTokens.GetHeapOffset(propertyDef.Signature); public string SignatureTooltip { diff --git a/ILSpy/Metadata/CorTables/StandAloneSigTableTreeNode.cs b/ILSpy/Metadata/CorTables/StandAloneSigTableTreeNode.cs index ff6fbfb76..89e79afbc 100644 --- a/ILSpy/Metadata/CorTables/StandAloneSigTableTreeNode.cs +++ b/ILSpy/Metadata/CorTables/StandAloneSigTableTreeNode.cs @@ -86,7 +86,7 @@ namespace ICSharpCode.ILSpy.Metadata + metadata.GetTableMetadataOffset(TableIndex.StandAloneSig) + metadata.GetTableRowSize(TableIndex.StandAloneSig) * (RID - 1); - [StringFormat("X")] + [ColumnInfo("X8", Kind = ColumnKind.HeapOffset)] public int Signature => MetadataTokens.GetHeapOffset(standaloneSig.Signature); public string SignatureTooltip { diff --git a/ILSpy/Metadata/CorTables/TypeDefTableTreeNode.cs b/ILSpy/Metadata/CorTables/TypeDefTableTreeNode.cs index 078d8afb0..47b38af0a 100644 --- a/ILSpy/Metadata/CorTables/TypeDefTableTreeNode.cs +++ b/ILSpy/Metadata/CorTables/TypeDefTableTreeNode.cs @@ -91,7 +91,7 @@ namespace ICSharpCode.ILSpy.Metadata + metadata.GetTableMetadataOffset(TableIndex.TypeDef) + metadata.GetTableRowSize(TableIndex.TypeDef) * (RID - 1); - [StringFormat("X8")] + [ColumnInfo("X8", Kind = ColumnKind.Other)] public TypeAttributes Attributes => typeDef.Attributes; const TypeAttributes otherFlagsMask = ~(TypeAttributes.VisibilityMask | TypeAttributes.LayoutMask | TypeAttributes.ClassSemanticsMask | TypeAttributes.StringFormatMask | TypeAttributes.CustomFormatMask); @@ -113,8 +113,7 @@ namespace ICSharpCode.ILSpy.Metadata public string Namespace => metadata.GetString(typeDef.Namespace); - [StringFormat("X8")] - [LinkToTable] + [ColumnInfo("X8", Kind = ColumnKind.Token)] public int BaseType => MetadataTokens.GetToken(typeDef.BaseType); public void OnBaseTypeClick() @@ -145,8 +144,7 @@ namespace ICSharpCode.ILSpy.Metadata } } - [StringFormat("X8")] - [LinkToTable] + [ColumnInfo("X8", Kind = ColumnKind.Token)] public int FieldList => MetadataTokens.GetToken(typeDef.GetFields().FirstOrDefault()); public void OnFieldListClick() @@ -166,8 +164,7 @@ namespace ICSharpCode.ILSpy.Metadata } } - [StringFormat("X8")] - [LinkToTable] + [ColumnInfo("X8", Kind = ColumnKind.Token)] public int MethodList => MetadataTokens.GetToken(typeDef.GetMethods().FirstOrDefault()); public void OnMethodListClick() diff --git a/ILSpy/Metadata/CorTables/TypeRefTableTreeNode.cs b/ILSpy/Metadata/CorTables/TypeRefTableTreeNode.cs index 24db219f9..6e34da4da 100644 --- a/ILSpy/Metadata/CorTables/TypeRefTableTreeNode.cs +++ b/ILSpy/Metadata/CorTables/TypeRefTableTreeNode.cs @@ -86,8 +86,7 @@ namespace ICSharpCode.ILSpy.Metadata + metadata.GetTableMetadataOffset(TableIndex.TypeRef) + metadata.GetTableRowSize(TableIndex.TypeRef) * (RID - 1); - [StringFormat("X8")] - [LinkToTable] + [ColumnInfo("X8", Kind = ColumnKind.Token)] public int ResolutionScope => MetadataTokens.GetToken(typeRef.ResolutionScope); public void OnResolutionScopeClick() diff --git a/ILSpy/Metadata/CorTables/TypeSpecTableTreeNode.cs b/ILSpy/Metadata/CorTables/TypeSpecTableTreeNode.cs index 1d19874e5..5b87adaa1 100644 --- a/ILSpy/Metadata/CorTables/TypeSpecTableTreeNode.cs +++ b/ILSpy/Metadata/CorTables/TypeSpecTableTreeNode.cs @@ -86,7 +86,7 @@ namespace ICSharpCode.ILSpy.Metadata + metadata.GetTableMetadataOffset(TableIndex.TypeSpec) + metadata.GetTableRowSize(TableIndex.TypeSpec) * (RID - 1); - [StringFormat("X")] + [ColumnInfo("X8", Kind = ColumnKind.HeapOffset)] public int Signature => MetadataTokens.GetHeapOffset(typeSpec.Signature); public string SignatureTooltip { diff --git a/ILSpy/Metadata/DebugTables/CustomDebugInformationTableTreeNode.cs b/ILSpy/Metadata/DebugTables/CustomDebugInformationTableTreeNode.cs index 981802be0..329cc86b6 100644 --- a/ILSpy/Metadata/DebugTables/CustomDebugInformationTableTreeNode.cs +++ b/ILSpy/Metadata/DebugTables/CustomDebugInformationTableTreeNode.cs @@ -197,8 +197,7 @@ namespace ICSharpCode.ILSpy.Metadata public object Offset => offset == null ? "n/a" : (object)offset; - [StringFormat("X8")] - [LinkToTable] + [ColumnInfo("X8", Kind = ColumnKind.Token)] public int Parent => MetadataTokens.GetToken(debugInfo.Parent); public void OnParentClick() @@ -251,7 +250,7 @@ namespace ICSharpCode.ILSpy.Metadata } } - [StringFormat("X8")] + [ColumnInfo("X8", Kind = ColumnKind.HeapOffset)] public int Value => MetadataTokens.GetHeapOffset(debugInfo.Value); public string ValueTooltip { diff --git a/ILSpy/Metadata/DebugTables/DocumentTableTreeNode.cs b/ILSpy/Metadata/DebugTables/DocumentTableTreeNode.cs index c3cef36da..2a7fdb8e4 100644 --- a/ILSpy/Metadata/DebugTables/DocumentTableTreeNode.cs +++ b/ILSpy/Metadata/DebugTables/DocumentTableTreeNode.cs @@ -90,7 +90,7 @@ namespace ICSharpCode.ILSpy.Metadata public string NameTooltip => $"{MetadataTokens.GetHeapOffset(document.Name):X} \"{Name}\""; - [StringFormat("X")] + [ColumnInfo("X8", Kind = ColumnKind.HeapOffset)] public int HashAlgorithm => MetadataTokens.GetHeapOffset(document.HashAlgorithm); public string HashAlgorithmTooltip { @@ -106,7 +106,7 @@ namespace ICSharpCode.ILSpy.Metadata } } - [StringFormat("X")] + [ColumnInfo("X8", Kind = ColumnKind.HeapOffset)] public int Hash => MetadataTokens.GetHeapOffset(document.Hash); public string HashTooltip { @@ -118,7 +118,7 @@ namespace ICSharpCode.ILSpy.Metadata } } - [StringFormat("X")] + [ColumnInfo("X8", Kind = ColumnKind.HeapOffset)] public int Language => MetadataTokens.GetHeapOffset(document.Language); public string LanguageTooltip { diff --git a/ILSpy/Metadata/DebugTables/ImportScopeTableTreeNode.cs b/ILSpy/Metadata/DebugTables/ImportScopeTableTreeNode.cs index e7841965d..0e6ee99d0 100644 --- a/ILSpy/Metadata/DebugTables/ImportScopeTableTreeNode.cs +++ b/ILSpy/Metadata/DebugTables/ImportScopeTableTreeNode.cs @@ -90,8 +90,7 @@ namespace ICSharpCode.ILSpy.Metadata public object Offset => offset == null ? "n/a" : (object)offset; - [StringFormat("X8")] - [LinkToTable] + [ColumnInfo("X8", Kind = ColumnKind.Token)] public int Parent => MetadataTokens.GetToken(localScope.Parent); public void OnParentClick() @@ -99,7 +98,7 @@ namespace ICSharpCode.ILSpy.Metadata MainWindow.Instance.JumpToReference(new EntityReference(module, localScope.Parent, protocol: "metadata")); } - [StringFormat("X")] + [ColumnInfo("X8", Kind = ColumnKind.HeapOffset)] public int Imports => MetadataTokens.GetHeapOffset(localScope.ImportsBlob); public ImportScopeEntry(PEFile module, MetadataReader metadata, bool isEmbedded, ImportScopeHandle handle) diff --git a/ILSpy/Metadata/DebugTables/LocalConstantTableTreeNode.cs b/ILSpy/Metadata/DebugTables/LocalConstantTableTreeNode.cs index 2a095fee4..9eaf8be2a 100644 --- a/ILSpy/Metadata/DebugTables/LocalConstantTableTreeNode.cs +++ b/ILSpy/Metadata/DebugTables/LocalConstantTableTreeNode.cs @@ -92,7 +92,7 @@ namespace ICSharpCode.ILSpy.Metadata public string NameTooltip => $"{MetadataTokens.GetHeapOffset(localConst.Name):X} \"{Name}\""; - [StringFormat("X")] + [ColumnInfo("X8", Kind = ColumnKind.HeapOffset)] public int Signature => MetadataTokens.GetHeapOffset(localConst.Signature); public LocalConstantEntry(PEFile module, MetadataReader metadata, bool isEmbedded, LocalConstantHandle handle) diff --git a/ILSpy/Metadata/DebugTables/LocalScopeTableTreeNode.cs b/ILSpy/Metadata/DebugTables/LocalScopeTableTreeNode.cs index 546e5c395..6854b64e0 100644 --- a/ILSpy/Metadata/DebugTables/LocalScopeTableTreeNode.cs +++ b/ILSpy/Metadata/DebugTables/LocalScopeTableTreeNode.cs @@ -90,8 +90,7 @@ namespace ICSharpCode.ILSpy.Metadata public object Offset => offset == null ? "n/a" : (object)offset; - [StringFormat("X8")] - [LinkToTable] + [ColumnInfo("X8", Kind = ColumnKind.Token)] public int Method => MetadataTokens.GetToken(localScope.Method); public void OnMethodClick() @@ -107,8 +106,7 @@ namespace ICSharpCode.ILSpy.Metadata } } - [StringFormat("X8")] - [LinkToTable] + [ColumnInfo("X8", Kind = ColumnKind.Token)] public int ImportScope => MetadataTokens.GetToken(localScope.ImportScope); public void OnImportScopeClick() @@ -116,8 +114,7 @@ namespace ICSharpCode.ILSpy.Metadata MainWindow.Instance.JumpToReference(new EntityReference(module, localScope.ImportScope, protocol: "metadata")); } - [StringFormat("X8")] - [LinkToTable] + [ColumnInfo("X8", Kind = ColumnKind.Token)] public int VariableList => MetadataTokens.GetToken(localScope.GetLocalVariables().FirstOrDefault()); public void OnVariableListClick() @@ -125,8 +122,7 @@ namespace ICSharpCode.ILSpy.Metadata MainWindow.Instance.JumpToReference(new EntityReference(module, localScope.GetLocalVariables().FirstOrDefault(), protocol: "metadata")); } - [StringFormat("X8")] - [LinkToTable] + [ColumnInfo("X8", Kind = ColumnKind.Token)] public int ConstantList => MetadataTokens.GetToken(localScope.GetLocalConstants().FirstOrDefault()); public void OnConstantListClick() diff --git a/ILSpy/Metadata/DebugTables/LocalVariableTableTreeNode.cs b/ILSpy/Metadata/DebugTables/LocalVariableTableTreeNode.cs index ed8744e2e..9913e1a6b 100644 --- a/ILSpy/Metadata/DebugTables/LocalVariableTableTreeNode.cs +++ b/ILSpy/Metadata/DebugTables/LocalVariableTableTreeNode.cs @@ -84,7 +84,7 @@ namespace ICSharpCode.ILSpy.Metadata public object Offset => offset == null ? "n/a" : (object)offset; - [StringFormat("X8")] + [ColumnInfo("X8", Kind = ColumnKind.Other)] public LocalVariableAttributes Attributes => localVar.Attributes; public object AttributesTooltip => new FlagsTooltip() { diff --git a/ILSpy/Metadata/DebugTables/MethodDebugInformationTableTreeNode.cs b/ILSpy/Metadata/DebugTables/MethodDebugInformationTableTreeNode.cs index 46dc93885..d439308e4 100644 --- a/ILSpy/Metadata/DebugTables/MethodDebugInformationTableTreeNode.cs +++ b/ILSpy/Metadata/DebugTables/MethodDebugInformationTableTreeNode.cs @@ -88,8 +88,7 @@ namespace ICSharpCode.ILSpy.Metadata public object Offset => offset == null ? "n/a" : (object)offset; - [StringFormat("X8")] - [LinkToTable] + [ColumnInfo("X8", Kind = ColumnKind.Token)] public int Document => MetadataTokens.GetToken(debugInfo.Document); public void OnDocumentClick() @@ -106,7 +105,7 @@ namespace ICSharpCode.ILSpy.Metadata } } - [StringFormat("X")] + [ColumnInfo("X8", Kind = ColumnKind.HeapOffset)] public int SequencePoints => MetadataTokens.GetHeapOffset(debugInfo.SequencePointsBlob); public string SequencePointsTooltip { @@ -122,8 +121,7 @@ namespace ICSharpCode.ILSpy.Metadata } } - [StringFormat("X")] - [LinkToTable] + [ColumnInfo("X8", Kind = ColumnKind.Token)] public int LocalSignature => MetadataTokens.GetToken(debugInfo.LocalSignature); public void OnLocalSignatureClick() diff --git a/ILSpy/Metadata/DebugTables/StateMachineMethodTableTreeNode.cs b/ILSpy/Metadata/DebugTables/StateMachineMethodTableTreeNode.cs index 5e30b145f..4973f38d3 100644 --- a/ILSpy/Metadata/DebugTables/StateMachineMethodTableTreeNode.cs +++ b/ILSpy/Metadata/DebugTables/StateMachineMethodTableTreeNode.cs @@ -92,8 +92,7 @@ namespace ICSharpCode.ILSpy.Metadata public object Offset => offset == null ? "n/a" : (object)offset; - [StringFormat("X8")] - [LinkToTable] + [ColumnInfo("X8", Kind = ColumnKind.Token)] public int MoveNextMethod => MetadataTokens.GetToken(moveNextMethod); public void OnMoveNextMethodClick() @@ -110,8 +109,7 @@ namespace ICSharpCode.ILSpy.Metadata } } - [StringFormat("X8")] - [LinkToTable] + [ColumnInfo("X8", Kind = ColumnKind.Token)] public int KickoffMethod => MetadataTokens.GetToken(kickoffMethod); public void OnKickofMethodClick() diff --git a/ILSpy/Metadata/GoToTokenCommand.cs b/ILSpy/Metadata/GoToTokenCommand.cs index b35db7d08..d8963ce60 100644 --- a/ILSpy/Metadata/GoToTokenCommand.cs +++ b/ILSpy/Metadata/GoToTokenCommand.cs @@ -60,7 +60,7 @@ namespace ICSharpCode.ILSpy.Commands Type type = cell.Item.GetType(); var property = type.GetProperty(cell.Column.Header.ToString()); var moduleField = type.GetField("module", BindingFlags.NonPublic | BindingFlags.Instance); - if (property == null || property.PropertyType != typeof(int) || !property.GetCustomAttributes(false).Any(a => a is StringFormatAttribute sf && sf.Format == "X8")) + if (property == null || property.PropertyType != typeof(int) || !property.GetCustomAttributes(false).Any(a => a is ColumnInfoAttribute { Kind: ColumnKind.Token } c)) return null; module = (PEFile)moduleField.GetValue(cell.Item); return (int)property.GetValue(cell.Item); diff --git a/ILSpy/Metadata/Helpers.cs b/ILSpy/Metadata/Helpers.cs index cd6558a17..da418b554 100644 --- a/ILSpy/Metadata/Helpers.cs +++ b/ILSpy/Metadata/Helpers.cs @@ -143,7 +143,7 @@ namespace ICSharpCode.ILSpy.Metadata var descriptor = (PropertyDescriptor)e.PropertyDescriptor; - if (descriptor.Attributes.OfType().Any()) + if (descriptor.Attributes.OfType().Any(c => c.Kind == ColumnKind.Token || c.LinkToTable)) { return new DataGridTemplateColumn() { Header = e.PropertyName, @@ -200,12 +200,12 @@ namespace ICSharpCode.ILSpy.Metadata string key = descriptor.PropertyType.Name + "Filter"; column.SetTemplate((ControlTemplate)MetadataTableViews.Instance[key]); } - var stringFormat = descriptor.Attributes.OfType().FirstOrDefault(); - if (stringFormat != null) + var columnInfo = descriptor.Attributes.OfType().FirstOrDefault(); + if (columnInfo != null) { - binding.StringFormat = stringFormat.Format; + binding.StringFormat = columnInfo.Format; if (!descriptor.PropertyType.IsEnum - && stringFormat.Format.StartsWith("X", StringComparison.OrdinalIgnoreCase)) + && columnInfo.Format.StartsWith("X", StringComparison.OrdinalIgnoreCase)) { column.SetTemplate((ControlTemplate)MetadataTableViews.Instance["HexFilter"]); } @@ -297,20 +297,28 @@ namespace ICSharpCode.ILSpy.Metadata } } - class StringFormatAttribute : Attribute + enum ColumnKind + { + HeapOffset, + Token, + Other + } + + [AttributeUsage(AttributeTargets.Property)] + class ColumnInfoAttribute : Attribute { public string Format { get; } - public StringFormatAttribute(string format) + public ColumnKind Kind { get; set; } + + public bool LinkToTable { get; set; } + + public ColumnInfoAttribute(string format) { this.Format = format; } } - class LinkToTableAttribute : Attribute - { - } - [Flags] internal enum TableMask : ulong {