diff --git a/ILSpy/Metadata/CorTables/ClassLayoutTableTreeNode.cs b/ILSpy/Metadata/CorTables/ClassLayoutTableTreeNode.cs index 9da461b58..af78f3044 100644 --- a/ILSpy/Metadata/CorTables/ClassLayoutTableTreeNode.cs +++ b/ILSpy/Metadata/CorTables/ClassLayoutTableTreeNode.cs @@ -108,14 +108,8 @@ namespace ICSharpCode.ILSpy.Metadata MainWindow.Instance.JumpToReference(new EntityReference(module, classLayout.Parent, protocol: "metadata")); } - public string ParentTooltip { - get { - ITextOutput output = new PlainTextOutput(); - var context = new MetadataGenericContext(default(TypeDefinitionHandle), module); - classLayout.Parent.WriteTo(module, output, context); - return output.ToString(); - } - } + string parentTooltip; + public string ParentTooltip => GenerateTooltip(ref parentTooltip, module, classLayout.Parent); [ColumnInfo("X4", Kind = ColumnKind.Other)] public ushort PackingSize => classLayout.PackingSize; @@ -132,6 +126,7 @@ namespace ICSharpCode.ILSpy.Metadata + metadata.GetTableRowSize(TableIndex.ClassLayout) * (row - 1); this.Offset = metadataOffset + rowOffset; this.classLayout = new ClassLayout(ptr + rowOffset, metadata.GetTableRowCount(TableIndex.TypeDef) < ushort.MaxValue ? 2 : 4); + this.parentTooltip = null; } } diff --git a/ILSpy/Metadata/CorTables/ConstantTableTreeNode.cs b/ILSpy/Metadata/CorTables/ConstantTableTreeNode.cs index d7b30b4b8..3f9dc97c8 100644 --- a/ILSpy/Metadata/CorTables/ConstantTableTreeNode.cs +++ b/ILSpy/Metadata/CorTables/ConstantTableTreeNode.cs @@ -100,14 +100,8 @@ namespace ICSharpCode.ILSpy.Metadata MainWindow.Instance.JumpToReference(new EntityReference(module, constant.Parent, protocol: "metadata")); } - public string ParentTooltip { - get { - ITextOutput output = new PlainTextOutput(); - var context = new MetadataGenericContext(default(TypeDefinitionHandle), module); - constant.Parent.WriteTo(module, output, context); - return output.ToString(); - } - } + string parentTooltip; + public string ParentTooltip => GenerateTooltip(ref parentTooltip, module, constant.Parent); [ColumnInfo("X8", Kind = ColumnKind.HeapOffset)] public int Value => MetadataTokens.GetHeapOffset(constant.Value); @@ -125,6 +119,7 @@ namespace ICSharpCode.ILSpy.Metadata this.metadata = module.Metadata; this.handle = handle; this.constant = metadata.GetConstant(handle); + this.parentTooltip = null; } } diff --git a/ILSpy/Metadata/CorTables/CustomAttributeTableTreeNode.cs b/ILSpy/Metadata/CorTables/CustomAttributeTableTreeNode.cs index 7691be4b8..30a6cf47f 100644 --- a/ILSpy/Metadata/CorTables/CustomAttributeTableTreeNode.cs +++ b/ILSpy/Metadata/CorTables/CustomAttributeTableTreeNode.cs @@ -95,14 +95,8 @@ namespace ICSharpCode.ILSpy.Metadata MainWindow.Instance.JumpToReference(new EntityReference(module, customAttr.Parent, protocol: "metadata")); } - public string ParentTooltip { - get { - ITextOutput output = new PlainTextOutput(); - var context = new MetadataGenericContext(default(TypeDefinitionHandle), module); - customAttr.Parent.WriteTo(module, output, context); - return output.ToString(); - } - } + string parentTooltip; + public string ParentTooltip => GenerateTooltip(ref parentTooltip, module, customAttr.Parent); [ColumnInfo("X8", Kind = ColumnKind.Token)] public int Constructor => MetadataTokens.GetToken(customAttr.Constructor); @@ -112,14 +106,8 @@ namespace ICSharpCode.ILSpy.Metadata MainWindow.Instance.JumpToReference(new EntityReference(module, customAttr.Constructor, protocol: "metadata")); } - public string ConstructorTooltip { - get { - ITextOutput output = new PlainTextOutput(); - var context = new MetadataGenericContext(default(TypeDefinitionHandle), module); - customAttr.Constructor.WriteTo(module, output, context); - return output.ToString(); - } - } + string constructorTooltip; + public string ConstructorTooltip => GenerateTooltip(ref constructorTooltip, module, customAttr.Constructor); [ColumnInfo("X8", Kind = ColumnKind.HeapOffset)] public int Value => MetadataTokens.GetHeapOffset(customAttr.Value); @@ -137,6 +125,8 @@ namespace ICSharpCode.ILSpy.Metadata this.metadata = module.Metadata; this.handle = handle; this.customAttr = metadata.GetCustomAttribute(handle); + this.parentTooltip = null; + this.constructorTooltip = null; } } diff --git a/ILSpy/Metadata/CorTables/DeclSecurityTableTreeNode.cs b/ILSpy/Metadata/CorTables/DeclSecurityTableTreeNode.cs index 8e3b82330..601b7a8b1 100644 --- a/ILSpy/Metadata/CorTables/DeclSecurityTableTreeNode.cs +++ b/ILSpy/Metadata/CorTables/DeclSecurityTableTreeNode.cs @@ -96,14 +96,8 @@ namespace ICSharpCode.ILSpy.Metadata MainWindow.Instance.JumpToReference(new EntityReference(module, declSecAttr.Parent, protocol: "metadata")); } - public string ParentTooltip { - get { - ITextOutput output = new PlainTextOutput(); - var context = new MetadataGenericContext(default(TypeDefinitionHandle), module); - declSecAttr.Parent.WriteTo(module, output, context); - return output.ToString(); - } - } + string parentTooltip; + public string ParentTooltip => GenerateTooltip(ref parentTooltip, module, declSecAttr.Parent); [ColumnInfo("X8", Kind = ColumnKind.Other)] public DeclarativeSecurityAction Action => declSecAttr.Action; @@ -130,6 +124,7 @@ namespace ICSharpCode.ILSpy.Metadata this.metadata = module.Metadata; this.handle = handle; this.declSecAttr = metadata.GetDeclarativeSecurityAttribute(handle); + this.parentTooltip = null; } } diff --git a/ILSpy/Metadata/CorTables/EventMapTableTreeNode.cs b/ILSpy/Metadata/CorTables/EventMapTableTreeNode.cs index 6cf0f9349..ae0833708 100644 --- a/ILSpy/Metadata/CorTables/EventMapTableTreeNode.cs +++ b/ILSpy/Metadata/CorTables/EventMapTableTreeNode.cs @@ -106,14 +106,8 @@ namespace ICSharpCode.ILSpy.Metadata MainWindow.Instance.JumpToReference(new EntityReference(module, eventMap.Parent, protocol: "metadata")); } - public string ParentTooltip { - get { - ITextOutput output = new PlainTextOutput(); - var context = new MetadataGenericContext(default(TypeDefinitionHandle), module); - ((EntityHandle)eventMap.Parent).WriteTo(module, output, context); - return output.ToString(); - } - } + string parentTooltip; + public string ParentTooltip => GenerateTooltip(ref parentTooltip, module, eventMap.Parent); [ColumnInfo("X8", Kind = ColumnKind.Token)] public int EventList => MetadataTokens.GetToken(eventMap.EventList); @@ -123,14 +117,8 @@ namespace ICSharpCode.ILSpy.Metadata MainWindow.Instance.JumpToReference(new EntityReference(module, eventMap.EventList, protocol: "metadata")); } - public string EventListTooltip { - get { - ITextOutput output = new PlainTextOutput(); - var context = new MetadataGenericContext(default(TypeDefinitionHandle), module); - ((EntityHandle)eventMap.EventList).WriteTo(module, output, context); - return output.ToString(); - } - } + string eventListTooltip; + public string EventListTooltip => GenerateTooltip(ref eventListTooltip, module, eventMap.EventList); public EventMapEntry(PEFile module, byte* ptr, int metadataOffset, int row) { @@ -143,6 +131,8 @@ namespace ICSharpCode.ILSpy.Metadata int typeDefSize = metadata.GetTableRowCount(TableIndex.TypeDef) < ushort.MaxValue ? 2 : 4; int eventDefSize = metadata.GetTableRowCount(TableIndex.Event) < ushort.MaxValue ? 2 : 4; this.eventMap = new EventMap(ptr + rowOffset, typeDefSize, eventDefSize); + this.parentTooltip = null; + this.eventListTooltip = null; } } diff --git a/ILSpy/Metadata/CorTables/EventTableTreeNode.cs b/ILSpy/Metadata/CorTables/EventTableTreeNode.cs index dabcb7cc4..b24f093dc 100644 --- a/ILSpy/Metadata/CorTables/EventTableTreeNode.cs +++ b/ILSpy/Metadata/CorTables/EventTableTreeNode.cs @@ -111,13 +111,8 @@ namespace ICSharpCode.ILSpy.Metadata MainWindow.Instance.JumpToReference(new EntityReference(module, eventDef.Type, protocol: "metadata")); } - public string TypeTooltip { - get { - ITextOutput output = new PlainTextOutput(); - eventDef.Type.WriteTo(module, output, default); - return output.ToString(); - } - } + string typeTooltip; + public string TypeTooltip => GenerateTooltip(ref typeTooltip, module, eventDef.Type); public EventDefEntry(PEFile module, EventDefinitionHandle handle) { @@ -126,6 +121,7 @@ namespace ICSharpCode.ILSpy.Metadata this.metadata = module.Metadata; this.handle = handle; this.eventDef = metadata.GetEventDefinition(handle); + this.typeTooltip = null; } } diff --git a/ILSpy/Metadata/CorTables/ExportedTypeTableTreeNode.cs b/ILSpy/Metadata/CorTables/ExportedTypeTableTreeNode.cs index 878024a00..b95a5a9e8 100644 --- a/ILSpy/Metadata/CorTables/ExportedTypeTableTreeNode.cs +++ b/ILSpy/Metadata/CorTables/ExportedTypeTableTreeNode.cs @@ -118,16 +118,8 @@ namespace ICSharpCode.ILSpy.Metadata MainWindow.Instance.JumpToReference(new EntityReference(module, type.Implementation, protocol: "metadata")); } - public string ImplementationTooltip { - get { - if (type.Implementation.IsNil) - return null; - ITextOutput output = new PlainTextOutput(); - var context = new MetadataGenericContext(default(TypeDefinitionHandle), module); - type.Implementation.WriteTo(module, output, context); - return output.ToString(); - } - } + string implementationTooltip; + public string ImplementationTooltip => GenerateTooltip(ref implementationTooltip, module, type.Implementation); public ExportedTypeEntry(int metadataOffset, PEFile module, ExportedTypeHandle handle, ExportedType type) { @@ -136,6 +128,7 @@ namespace ICSharpCode.ILSpy.Metadata this.metadata = module.Metadata; this.handle = handle; this.type = type; + this.implementationTooltip = null; } } diff --git a/ILSpy/Metadata/CorTables/FieldLayoutTableTreeNode.cs b/ILSpy/Metadata/CorTables/FieldLayoutTableTreeNode.cs index c5aa00d71..8a80966b0 100644 --- a/ILSpy/Metadata/CorTables/FieldLayoutTableTreeNode.cs +++ b/ILSpy/Metadata/CorTables/FieldLayoutTableTreeNode.cs @@ -106,14 +106,8 @@ namespace ICSharpCode.ILSpy.Metadata MainWindow.Instance.JumpToReference(new EntityReference(module, fieldLayout.Field, protocol: "metadata")); } - public string FieldTooltip { - get { - ITextOutput output = new PlainTextOutput(); - var context = new Decompiler.Metadata.MetadataGenericContext(default(TypeDefinitionHandle), module); - ((EntityHandle)fieldLayout.Field).WriteTo(module, output, context); - return output.ToString(); - } - } + string fieldTooltip; + public string FieldTooltip => GenerateTooltip(ref fieldTooltip, module, fieldLayout.Field); [ColumnInfo("X8", Kind = ColumnKind.Other)] public int FieldOffset => fieldLayout.Offset; @@ -128,6 +122,7 @@ namespace ICSharpCode.ILSpy.Metadata this.Offset = metadataOffset + rowOffset; int fieldDefSize = metadata.GetTableRowCount(TableIndex.Field) < ushort.MaxValue ? 2 : 4; this.fieldLayout = new FieldLayout(ptr + rowOffset, fieldDefSize); + this.fieldTooltip = null; } } diff --git a/ILSpy/Metadata/CorTables/FieldMarshalTableTreeNode.cs b/ILSpy/Metadata/CorTables/FieldMarshalTableTreeNode.cs index b85d3c5ec..a9f26ff13 100644 --- a/ILSpy/Metadata/CorTables/FieldMarshalTableTreeNode.cs +++ b/ILSpy/Metadata/CorTables/FieldMarshalTableTreeNode.cs @@ -106,14 +106,8 @@ namespace ICSharpCode.ILSpy.Metadata MainWindow.Instance.JumpToReference(new EntityReference(module, fieldMarshal.Parent, protocol: "metadata")); } - public string ParentTooltip { - get { - ITextOutput output = new PlainTextOutput(); - var context = new Decompiler.Metadata.MetadataGenericContext(default(TypeDefinitionHandle), module); - ((EntityHandle)fieldMarshal.Parent).WriteTo(module, output, context); - return output.ToString(); - } - } + string parentTooltip; + public string ParentTooltip => GenerateTooltip(ref parentTooltip, module, fieldMarshal.Parent); [ColumnInfo("X8", Kind = ColumnKind.HeapOffset)] public int NativeType => MetadataTokens.GetHeapOffset(fieldMarshal.NativeType); @@ -129,6 +123,7 @@ namespace ICSharpCode.ILSpy.Metadata int hasFieldMarshalRefSize = metadata.ComputeCodedTokenSize(32768, TableMask.Field | TableMask.Param); int blobHeapSize = metadata.GetHeapSize(HeapIndex.Blob) < ushort.MaxValue ? 2 : 4; this.fieldMarshal = new FieldMarshal(ptr + rowOffset, blobHeapSize, hasFieldMarshalRefSize); + this.parentTooltip = null; } } diff --git a/ILSpy/Metadata/CorTables/FieldRVATableTreeNode.cs b/ILSpy/Metadata/CorTables/FieldRVATableTreeNode.cs index 890b71cdf..9317bb336 100644 --- a/ILSpy/Metadata/CorTables/FieldRVATableTreeNode.cs +++ b/ILSpy/Metadata/CorTables/FieldRVATableTreeNode.cs @@ -106,14 +106,8 @@ namespace ICSharpCode.ILSpy.Metadata MainWindow.Instance.JumpToReference(new EntityReference(module, fieldRVA.Field, protocol: "metadata")); } - public string FieldTooltip { - get { - ITextOutput output = new PlainTextOutput(); - var context = new Decompiler.Metadata.MetadataGenericContext(default(TypeDefinitionHandle), module); - ((EntityHandle)fieldLayout.Field).WriteTo(module, output, context); - return output.ToString(); - } - } + string fieldTooltip; + public string FieldTooltip => GenerateTooltip(ref fieldTooltip, module, fieldRVA.Field); [ColumnInfo("X8", Kind = ColumnKind.Other)] public int FieldOffset => fieldRVA.Offset; @@ -127,7 +121,8 @@ namespace ICSharpCode.ILSpy.Metadata + metadata.GetTableRowSize(TableIndex.FieldRva) * (row - 1); this.Offset = metadataOffset + rowOffset; int fieldDefSize = metadata.GetTableRowCount(TableIndex.Field) < ushort.MaxValue ? 2 : 4; - this.fieldLayout = new FieldRVA(ptr + rowOffset, fieldDefSize); + this.fieldRVA = new FieldRVA(ptr + rowOffset, fieldDefSize); + this.fieldTooltip = null; } } diff --git a/ILSpy/Metadata/CorTables/FieldTableTreeNode.cs b/ILSpy/Metadata/CorTables/FieldTableTreeNode.cs index 73eceefa1..f03666168 100644 --- a/ILSpy/Metadata/CorTables/FieldTableTreeNode.cs +++ b/ILSpy/Metadata/CorTables/FieldTableTreeNode.cs @@ -113,14 +113,8 @@ namespace ICSharpCode.ILSpy.Metadata [ColumnInfo("X8", Kind = ColumnKind.HeapOffset)] public int Signature => MetadataTokens.GetHeapOffset(fieldDef.Signature); - public string SignatureTooltip { - get { - ITextOutput output = new PlainTextOutput(); - var context = new Decompiler.Metadata.MetadataGenericContext(default(TypeDefinitionHandle), module); - ((EntityHandle)handle).WriteTo(module, output, context); - return output.ToString(); - } - } + string signatureTooltip; + public string SignatureTooltip => GenerateTooltip(ref signatureTooltip, module, handle); public FieldDefEntry(PEFile module, FieldDefinitionHandle handle) { @@ -129,6 +123,7 @@ namespace ICSharpCode.ILSpy.Metadata this.metadata = module.Metadata; this.handle = handle; this.fieldDef = metadata.GetFieldDefinition(handle); + this.signatureTooltip = null; } } diff --git a/ILSpy/Metadata/CorTables/GenericParamConstraintTableTreeNode.cs b/ILSpy/Metadata/CorTables/GenericParamConstraintTableTreeNode.cs index 4fcf1bc66..1f97fdce6 100644 --- a/ILSpy/Metadata/CorTables/GenericParamConstraintTableTreeNode.cs +++ b/ILSpy/Metadata/CorTables/GenericParamConstraintTableTreeNode.cs @@ -118,13 +118,8 @@ namespace ICSharpCode.ILSpy.Metadata MainWindow.Instance.JumpToReference(new EntityReference(module, genericParamConstraint.Type, protocol: "metadata")); } - public string TypeTooltip { - get { - ITextOutput output = new PlainTextOutput(); - genericParamConstraint.Type.WriteTo(module, output, default); - return output.ToString(); - } - } + string typeTooltip; + public string TypeTooltip => GenerateTooltip(ref typeTooltip, module, genericParamConstraint.Type); public GenericParamConstraintEntry(PEFile module, GenericParameterConstraintHandle handle) { @@ -134,6 +129,7 @@ namespace ICSharpCode.ILSpy.Metadata this.handle = handle; this.genericParamConstraint = metadata.GetGenericParameterConstraint(handle); this.ownerTooltip = null; + this.typeTooltip = null; } } diff --git a/ILSpy/Metadata/CorTables/GenericParamTableTreeNode.cs b/ILSpy/Metadata/CorTables/GenericParamTableTreeNode.cs index fd1590817..789670a59 100644 --- a/ILSpy/Metadata/CorTables/GenericParamTableTreeNode.cs +++ b/ILSpy/Metadata/CorTables/GenericParamTableTreeNode.cs @@ -99,18 +99,13 @@ namespace ICSharpCode.ILSpy.Metadata [ColumnInfo("X8", Kind = ColumnKind.Token)] public int Owner => MetadataTokens.GetToken(genericParam.Parent); - public void OnParentClick() + public void OnOwnerClick() { MainWindow.Instance.JumpToReference(new EntityReference(module, genericParam.Parent, protocol: "metadata")); } - public string OwnerTooltip { - get { - ITextOutput output = new PlainTextOutput(); - genericParam.Parent.WriteTo(module, output, default); - return output.ToString(); - } - } + string ownerTooltip; + public string OwnerTooltip => GenerateTooltip(ref ownerTooltip, module, genericParam.Parent); public string Name => metadata.GetString(genericParam.Name); @@ -123,6 +118,7 @@ namespace ICSharpCode.ILSpy.Metadata this.metadata = module.Metadata; this.handle = handle; this.genericParam = metadata.GetGenericParameter(handle); + this.ownerTooltip = null; } } diff --git a/ILSpy/Metadata/CorTables/ImplMapTableTreeNode.cs b/ILSpy/Metadata/CorTables/ImplMapTableTreeNode.cs index 8ad12af71..c6c228ba6 100644 --- a/ILSpy/Metadata/CorTables/ImplMapTableTreeNode.cs +++ b/ILSpy/Metadata/CorTables/ImplMapTableTreeNode.cs @@ -123,14 +123,8 @@ namespace ICSharpCode.ILSpy.Metadata MainWindow.Instance.JumpToReference(new EntityReference(module, implMap.MemberForwarded, protocol: "metadata")); } - public string MemberForwardedTooltip { - get { - ITextOutput output = new PlainTextOutput(); - var context = new MetadataGenericContext(default(TypeDefinitionHandle), module); - ((EntityHandle)implMap.MemberForwarded).WriteTo(module, output, context); - return output.ToString(); - } - } + string memberForwardedTooltip; + public string MemberForwardedTooltip => GenerateTooltip(ref memberForwardedTooltip, module, implMap.MemberForwarded); [ColumnInfo("X8", Kind = ColumnKind.Token)] public int ImportScope => MetadataTokens.GetToken(implMap.ImportScope); @@ -140,14 +134,8 @@ namespace ICSharpCode.ILSpy.Metadata MainWindow.Instance.JumpToReference(new EntityReference(module, implMap.ImportScope, protocol: "metadata")); } - public string ImportScopeTooltip { - get { - ITextOutput output = new PlainTextOutput(); - var context = new MetadataGenericContext(default(TypeDefinitionHandle), module); - ((EntityHandle)implMap.ImportScope).WriteTo(module, output, context); - return output.ToString(); - } - } + string importScopeTooltip; + public string ImportScopeTooltip => GenerateTooltip(ref importScopeTooltip, module, implMap.ImportScope); public string ImportName => metadata.GetString(implMap.ImportName); @@ -165,6 +153,8 @@ namespace ICSharpCode.ILSpy.Metadata int memberForwardedTagRefSize = metadata.ComputeCodedTokenSize(32768, TableMask.MethodDef | TableMask.Field); int stringHandleSize = metadata.GetHeapSize(HeapIndex.String) < ushort.MaxValue ? 2 : 4; this.implMap = new ImplMap(ptr + rowOffset, moduleRefSize, memberForwardedTagRefSize, stringHandleSize); + this.importScopeTooltip = null; + this.memberForwardedTooltip = null; } } diff --git a/ILSpy/Metadata/CorTables/InterfaceImplTableTreeNode.cs b/ILSpy/Metadata/CorTables/InterfaceImplTableTreeNode.cs index 8764c1c5a..35c66ab85 100644 --- a/ILSpy/Metadata/CorTables/InterfaceImplTableTreeNode.cs +++ b/ILSpy/Metadata/CorTables/InterfaceImplTableTreeNode.cs @@ -106,14 +106,8 @@ namespace ICSharpCode.ILSpy.Metadata MainWindow.Instance.JumpToReference(new EntityReference(module, interfaceImpl.Class, protocol: "metadata")); } - public string ClassTooltip { - get { - ITextOutput output = new PlainTextOutput(); - var context = new MetadataGenericContext(default(TypeDefinitionHandle), module); - ((EntityHandle)interfaceImpl.Class).WriteTo(module, output, context); - return output.ToString(); - } - } + string classTooltip; + public string ClassTooltip => GenerateTooltip(ref classTooltip, module, interfaceImpl.Class); [ColumnInfo("X8", Kind = ColumnKind.Token)] public int Interface => MetadataTokens.GetToken(interfaceImpl.Interface); @@ -123,14 +117,8 @@ namespace ICSharpCode.ILSpy.Metadata MainWindow.Instance.JumpToReference(new EntityReference(module, interfaceImpl.Interface, protocol: "metadata")); } - public string InterfaceTooltip { - get { - ITextOutput output = new PlainTextOutput(); - var context = new MetadataGenericContext(default(TypeDefinitionHandle), module); - ((EntityHandle)interfaceImpl.Interface).WriteTo(module, output, context); - return output.ToString(); - } - } + string interfaceTooltip; + public string InterfaceTooltip => GenerateTooltip(ref interfaceTooltip, module, interfaceImpl.Interface); public InterfaceImplEntry(PEFile module, byte* ptr, int metadataOffset, int row) { @@ -141,6 +129,8 @@ namespace ICSharpCode.ILSpy.Metadata + metadata.GetTableRowSize(TableIndex.InterfaceImpl) * (row - 1); this.Offset = metadataOffset + rowOffset; this.interfaceImpl = new InterfaceImpl(ptr + rowOffset, metadata.GetTableRowCount(TableIndex.TypeDef) < ushort.MaxValue ? 2 : 4, metadata.ComputeCodedTokenSize(16384, TableMask.TypeDef | TableMask.TypeRef | TableMask.TypeSpec)); + this.interfaceTooltip = null; + this.classTooltip = null; } } diff --git a/ILSpy/Metadata/CorTables/ManifestResourceTableTreeNode.cs b/ILSpy/Metadata/CorTables/ManifestResourceTableTreeNode.cs index 0d9619cd9..79fd5b76b 100644 --- a/ILSpy/Metadata/CorTables/ManifestResourceTableTreeNode.cs +++ b/ILSpy/Metadata/CorTables/ManifestResourceTableTreeNode.cs @@ -105,16 +105,8 @@ namespace ICSharpCode.ILSpy.Metadata MainWindow.Instance.JumpToReference(new EntityReference(module, manifestResource.Implementation, protocol: "metadata")); } - public string ImplementationTooltip { - get { - if (manifestResource.Implementation.IsNil) - return null; - ITextOutput output = new PlainTextOutput(); - var context = new MetadataGenericContext(default(TypeDefinitionHandle), module); - manifestResource.Implementation.WriteTo(module, output, context); - return output.ToString(); - } - } + string implementationTooltip; + public string ImplementationTooltip => GenerateTooltip(ref implementationTooltip, module, manifestResource.Implementation); public ManifestResourceEntry(PEFile module, ManifestResourceHandle handle) { @@ -123,6 +115,7 @@ namespace ICSharpCode.ILSpy.Metadata this.metadata = module.Metadata; this.handle = handle; this.manifestResource = metadata.GetManifestResource(handle); + this.implementationTooltip = null; } } diff --git a/ILSpy/Metadata/CorTables/MemberRefTableTreeNode.cs b/ILSpy/Metadata/CorTables/MemberRefTableTreeNode.cs index e4701270f..01e7806dc 100644 --- a/ILSpy/Metadata/CorTables/MemberRefTableTreeNode.cs +++ b/ILSpy/Metadata/CorTables/MemberRefTableTreeNode.cs @@ -95,13 +95,8 @@ namespace ICSharpCode.ILSpy.Metadata MainWindow.Instance.JumpToReference(new EntityReference(module, memberRef.Parent, protocol: "metadata")); } - public string ParentTooltip { - get { - ITextOutput output = new PlainTextOutput(); - memberRef.Parent.WriteTo(module, output, default); - return output.ToString(); - } - } + string parentTooltip; + public string ParentTooltip => GenerateTooltip(ref parentTooltip, module, memberRef.Parent); public string Name => metadata.GetString(memberRef.Name); @@ -110,14 +105,8 @@ namespace ICSharpCode.ILSpy.Metadata [ColumnInfo("X8", Kind = ColumnKind.HeapOffset)] public int Signature => MetadataTokens.GetHeapOffset(memberRef.Signature); - public string SignatureTooltip { - get { - ITextOutput output = new PlainTextOutput(); - var context = new MetadataGenericContext(default(TypeDefinitionHandle), module); - ((EntityHandle)handle).WriteTo(module, output, context); - return output.ToString(); - } - } + string signatureTooltip; + public string SignatureTooltip => GenerateTooltip(ref signatureTooltip, module, handle); public MemberRefEntry(PEFile module, MemberReferenceHandle handle) { @@ -126,6 +115,8 @@ namespace ICSharpCode.ILSpy.Metadata this.metadata = module.Metadata; this.handle = handle; this.memberRef = metadata.GetMemberReference(handle); + this.signatureTooltip = null; + this.parentTooltip = null; } } diff --git a/ILSpy/Metadata/CorTables/MethodImplTableTreeNode.cs b/ILSpy/Metadata/CorTables/MethodImplTableTreeNode.cs index 8b761b27d..24b93afd0 100644 --- a/ILSpy/Metadata/CorTables/MethodImplTableTreeNode.cs +++ b/ILSpy/Metadata/CorTables/MethodImplTableTreeNode.cs @@ -94,13 +94,8 @@ namespace ICSharpCode.ILSpy.Metadata MainWindow.Instance.JumpToReference(new EntityReference(module, methodImpl.MethodDeclaration, protocol: "metadata")); } - public string MethodDeclarationTooltip { - get { - ITextOutput output = new PlainTextOutput(); - methodImpl.MethodDeclaration.WriteTo(module, output, default); - return output.ToString(); - } - } + string methodDeclarationTooltip; + public string MethodDeclarationTooltip => GenerateTooltip(ref methodDeclarationTooltip, module, methodImpl.MethodDeclaration); [ColumnInfo("X8", Kind = ColumnKind.Token)] public int MethodBody => MetadataTokens.GetToken(methodImpl.MethodBody); @@ -110,13 +105,8 @@ namespace ICSharpCode.ILSpy.Metadata MainWindow.Instance.JumpToReference(new EntityReference(module, methodImpl.MethodBody, protocol: "metadata")); } - public string MethodBodyTooltip { - get { - ITextOutput output = new PlainTextOutput(); - methodImpl.MethodBody.WriteTo(module, output, default); - return output.ToString(); - } - } + string methodBodyTooltip; + public string MethodBodyTooltip => GenerateTooltip(ref methodBodyTooltip, module, methodImpl.MethodBody); [ColumnInfo("X8", Kind = ColumnKind.Token)] public int Type => MetadataTokens.GetToken(methodImpl.Type); @@ -126,13 +116,8 @@ namespace ICSharpCode.ILSpy.Metadata MainWindow.Instance.JumpToReference(new EntityReference(module, methodImpl.Type, protocol: "metadata")); } - public string TypeTooltip { - get { - ITextOutput output = new PlainTextOutput(); - ((EntityHandle)methodImpl.Type).WriteTo(module, output, default); - return output.ToString(); - } - } + string typeTooltip; + public string TypeTooltip => GenerateTooltip(ref typeTooltip, module, methodImpl.Type); public MethodImplEntry(PEFile module, MethodImplementationHandle handle) { @@ -141,6 +126,9 @@ namespace ICSharpCode.ILSpy.Metadata this.metadata = module.Metadata; this.handle = handle; this.methodImpl = metadata.GetMethodImplementation(handle); + this.typeTooltip = null; + this.methodBodyTooltip = null; + this.methodDeclarationTooltip = null; } } diff --git a/ILSpy/Metadata/CorTables/MethodSemanticsTableTreeNode.cs b/ILSpy/Metadata/CorTables/MethodSemanticsTableTreeNode.cs index 6956e0cc6..3f3ab38df 100644 --- a/ILSpy/Metadata/CorTables/MethodSemanticsTableTreeNode.cs +++ b/ILSpy/Metadata/CorTables/MethodSemanticsTableTreeNode.cs @@ -103,13 +103,8 @@ namespace ICSharpCode.ILSpy.Metadata MainWindow.Instance.JumpToReference(new EntityReference(module, method, protocol: "metadata")); } - public string MethodTooltip { - get { - ITextOutput output = new PlainTextOutput(); - ((EntityHandle)method).WriteTo(module, output, default); - return output.ToString(); - } - } + string methodTooltip; + public string MethodTooltip => GenerateTooltip(ref methodTooltip, module, method); [ColumnInfo("X8", Kind = ColumnKind.Token)] public int Association => MetadataTokens.GetToken(association); @@ -119,13 +114,8 @@ namespace ICSharpCode.ILSpy.Metadata MainWindow.Instance.JumpToReference(new EntityReference(module, association, protocol: "metadata")); } - public string AssociationTooltip { - get { - ITextOutput output = new PlainTextOutput(); - association.WriteTo(module, output, default); - return output.ToString(); - } - } + string associationTooltip; + public string AssociationTooltip => GenerateTooltip(ref associationTooltip, module, association); public MethodSemanticsEntry(PEFile module, Handle handle, MethodSemanticsAttributes semantics, MethodDefinitionHandle method, EntityHandle association) { @@ -136,6 +126,8 @@ namespace ICSharpCode.ILSpy.Metadata this.semantics = semantics; this.method = method; this.association = association; + this.methodTooltip = null; + this.associationTooltip = null; } } diff --git a/ILSpy/Metadata/CorTables/MethodSpecTableTreeNode.cs b/ILSpy/Metadata/CorTables/MethodSpecTableTreeNode.cs index 780b502ef..c050dbc58 100644 --- a/ILSpy/Metadata/CorTables/MethodSpecTableTreeNode.cs +++ b/ILSpy/Metadata/CorTables/MethodSpecTableTreeNode.cs @@ -95,13 +95,8 @@ namespace ICSharpCode.ILSpy.Metadata MainWindow.Instance.JumpToReference(new EntityReference(module, methodSpec.Method, protocol: "metadata")); } - public string MethodTooltip { - get { - ITextOutput output = new PlainTextOutput(); - methodSpec.Method.WriteTo(module, output, default); - return output.ToString(); - } - } + string methodTooltip; + public string MethodTooltip => GenerateTooltip(ref methodTooltip, module, methodSpec.Method); [ColumnInfo("X8", Kind = ColumnKind.HeapOffset)] public int Signature => MetadataTokens.GetHeapOffset(methodSpec.Signature); @@ -130,6 +125,7 @@ namespace ICSharpCode.ILSpy.Metadata this.metadata = module.Metadata; this.handle = handle; this.methodSpec = metadata.GetMethodSpecification(handle); + this.methodTooltip = null; } } diff --git a/ILSpy/Metadata/CorTables/MethodTableTreeNode.cs b/ILSpy/Metadata/CorTables/MethodTableTreeNode.cs index 639e6f025..46f81cde4 100644 --- a/ILSpy/Metadata/CorTables/MethodTableTreeNode.cs +++ b/ILSpy/Metadata/CorTables/MethodTableTreeNode.cs @@ -122,18 +122,7 @@ namespace ICSharpCode.ILSpy.Metadata string signatureTooltip; - public string SignatureTooltip { - get { - if (signatureTooltip == null) - { - ITextOutput output = new PlainTextOutput(); - var context = new Decompiler.Metadata.MetadataGenericContext(default(TypeDefinitionHandle), module); - ((EntityHandle)handle).WriteTo(module, output, context); - signatureTooltip = output.ToString(); - } - return signatureTooltip; - } - } + public string SignatureTooltip => GenerateTooltip(ref signatureTooltip, module, handle); IEntity IMemberTreeNode.Member => ((MetadataModule)module.GetTypeSystemWithCurrentOptionsOrNull()?.MainModule).GetDefinition(handle); diff --git a/ILSpy/Metadata/CorTables/NestedClassTableTreeNode.cs b/ILSpy/Metadata/CorTables/NestedClassTableTreeNode.cs index dda3ad8e1..de347fd33 100644 --- a/ILSpy/Metadata/CorTables/NestedClassTableTreeNode.cs +++ b/ILSpy/Metadata/CorTables/NestedClassTableTreeNode.cs @@ -106,14 +106,8 @@ namespace ICSharpCode.ILSpy.Metadata MainWindow.Instance.JumpToReference(new EntityReference(module, nestedClass.Nested, protocol: "metadata")); } - public string NestedClassTooltip { - get { - ITextOutput output = new PlainTextOutput(); - var context = new Decompiler.Metadata.MetadataGenericContext(default(TypeDefinitionHandle), module); - ((EntityHandle)nestedClass.Nested).WriteTo(module, output, context); - return output.ToString(); - } - } + string nestedClassTooltip; + public string NestedClassTooltip => GenerateTooltip(ref nestedClassTooltip, module, nestedClass.Nested); [ColumnInfo("X8", Kind = ColumnKind.Token)] public int EnclosingClass => MetadataTokens.GetToken(nestedClass.Enclosing); @@ -123,14 +117,8 @@ namespace ICSharpCode.ILSpy.Metadata MainWindow.Instance.JumpToReference(new EntityReference(module, nestedClass.Enclosing, protocol: "metadata")); } - public string EnclosingClassTooltip { - get { - ITextOutput output = new PlainTextOutput(); - var context = new Decompiler.Metadata.MetadataGenericContext(default(TypeDefinitionHandle), module); - ((EntityHandle)nestedClass.Enclosing).WriteTo(module, output, context); - return output.ToString(); - } - } + string enclosingClassTooltip; + public string EnclosingClassTooltip => GenerateTooltip(ref enclosingClassTooltip, module, nestedClass.Enclosing); public unsafe NestedClassEntry(PEFile module, byte* ptr, int metadataOffset, int row) { @@ -142,6 +130,8 @@ namespace ICSharpCode.ILSpy.Metadata this.Offset = metadataOffset + rowOffset; int typeDefSize = metadata.GetTableRowCount(TableIndex.TypeDef) < ushort.MaxValue ? 2 : 4; this.nestedClass = new NestedClass(ptr + rowOffset, typeDefSize); + this.nestedClassTooltip = null; + this.enclosingClassTooltip = null; } } diff --git a/ILSpy/Metadata/CorTables/PropertyMapTableTreeNode.cs b/ILSpy/Metadata/CorTables/PropertyMapTableTreeNode.cs index b34023f2a..64d9bb19a 100644 --- a/ILSpy/Metadata/CorTables/PropertyMapTableTreeNode.cs +++ b/ILSpy/Metadata/CorTables/PropertyMapTableTreeNode.cs @@ -106,14 +106,8 @@ namespace ICSharpCode.ILSpy.Metadata MainWindow.Instance.JumpToReference(new EntityReference(module, propertyMap.Parent, protocol: "metadata")); } - public string ParentTooltip { - get { - ITextOutput output = new PlainTextOutput(); - var context = new MetadataGenericContext(default(TypeDefinitionHandle), module); - ((EntityHandle)propertyMap.Parent).WriteTo(module, output, context); - return output.ToString(); - } - } + string parentTooltip; + public string ParentTooltip => GenerateTooltip(ref parentTooltip, module, propertyMap.Parent); [ColumnInfo("X8", Kind = ColumnKind.Token)] public int PropertyList => MetadataTokens.GetToken(propertyMap.PropertyList); @@ -123,14 +117,8 @@ namespace ICSharpCode.ILSpy.Metadata MainWindow.Instance.JumpToReference(new EntityReference(module, propertyMap.PropertyList, protocol: "metadata")); } - public string PropertyListTooltip { - get { - ITextOutput output = new PlainTextOutput(); - var context = new MetadataGenericContext(default(TypeDefinitionHandle), module); - ((EntityHandle)propertyMap.PropertyList).WriteTo(module, output, context); - return output.ToString(); - } - } + string propertyListTooltip; + public string PropertyListTooltip => GenerateTooltip(ref propertyListTooltip, module, propertyMap.PropertyList); public PropertyMapEntry(PEFile module, byte* ptr, int metadataOffset, int row) { @@ -143,6 +131,8 @@ namespace ICSharpCode.ILSpy.Metadata int typeDefSize = metadata.GetTableRowCount(TableIndex.TypeDef) < ushort.MaxValue ? 2 : 4; int propertyDefSize = metadata.GetTableRowCount(TableIndex.Property) < ushort.MaxValue ? 2 : 4; this.propertyMap = new PropertyMap(ptr + rowOffset, typeDefSize, propertyDefSize); + this.propertyListTooltip = null; + this.parentTooltip = null; } } diff --git a/ILSpy/Metadata/CorTables/PropertyTableTreeNode.cs b/ILSpy/Metadata/CorTables/PropertyTableTreeNode.cs index 0b428934e..8240c2ac5 100644 --- a/ILSpy/Metadata/CorTables/PropertyTableTreeNode.cs +++ b/ILSpy/Metadata/CorTables/PropertyTableTreeNode.cs @@ -106,13 +106,8 @@ namespace ICSharpCode.ILSpy.Metadata [ColumnInfo("X8", Kind = ColumnKind.HeapOffset)] public int Signature => MetadataTokens.GetHeapOffset(propertyDef.Signature); - public string SignatureTooltip { - get { - ITextOutput output = new PlainTextOutput(); - ((EntityHandle)handle).WriteTo(module, output, default); - return output.ToString(); - } - } + string signatureTooltip; + public string SignatureTooltip => GenerateTooltip(ref signatureTooltip, module, handle); public PropertyDefEntry(PEFile module, PropertyDefinitionHandle handle) { @@ -121,6 +116,7 @@ namespace ICSharpCode.ILSpy.Metadata this.metadata = module.Metadata; this.handle = handle; this.propertyDef = metadata.GetPropertyDefinition(handle); + this.signatureTooltip = null; } } diff --git a/ILSpy/Metadata/CorTables/StandAloneSigTableTreeNode.cs b/ILSpy/Metadata/CorTables/StandAloneSigTableTreeNode.cs index 89e79afbc..0e618aad2 100644 --- a/ILSpy/Metadata/CorTables/StandAloneSigTableTreeNode.cs +++ b/ILSpy/Metadata/CorTables/StandAloneSigTableTreeNode.cs @@ -89,14 +89,8 @@ namespace ICSharpCode.ILSpy.Metadata [ColumnInfo("X8", Kind = ColumnKind.HeapOffset)] public int Signature => MetadataTokens.GetHeapOffset(standaloneSig.Signature); - public string SignatureTooltip { - get { - ITextOutput output = new PlainTextOutput(); - var context = new Decompiler.Metadata.MetadataGenericContext(default(TypeDefinitionHandle), module); - ((EntityHandle)handle).WriteTo(module, output, context); - return output.ToString(); - } - } + string signatureTooltip; + public string SignatureTooltip => GenerateTooltip(ref signatureTooltip, module, handle); public StandAloneSigEntry(PEFile module, StandaloneSignatureHandle handle) { @@ -105,6 +99,7 @@ namespace ICSharpCode.ILSpy.Metadata this.metadata = module.Metadata; this.handle = handle; this.standaloneSig = metadata.GetStandaloneSignature(handle); + this.signatureTooltip = null; } } diff --git a/ILSpy/Metadata/CorTables/TypeDefTableTreeNode.cs b/ILSpy/Metadata/CorTables/TypeDefTableTreeNode.cs index 47b38af0a..3388a244a 100644 --- a/ILSpy/Metadata/CorTables/TypeDefTableTreeNode.cs +++ b/ILSpy/Metadata/CorTables/TypeDefTableTreeNode.cs @@ -152,15 +152,13 @@ namespace ICSharpCode.ILSpy.Metadata MainWindow.Instance.JumpToReference(new EntityReference(module, typeDef.GetFields().FirstOrDefault(), protocol: "metadata")); } + string fieldListTooltip; public string FieldListTooltip { get { var field = typeDef.GetFields().FirstOrDefault(); if (field.IsNil) return null; - ITextOutput output = new PlainTextOutput(); - var context = new Decompiler.Metadata.MetadataGenericContext(default(TypeDefinitionHandle), module); - ((EntityHandle)field).WriteTo(module, output, context); - return output.ToString(); + return GenerateTooltip(ref fieldListTooltip, module, field); } } @@ -172,15 +170,13 @@ namespace ICSharpCode.ILSpy.Metadata MainWindow.Instance.JumpToReference(new EntityReference(module, typeDef.GetMethods().FirstOrDefault(), protocol: "metadata")); } + string methodListTooltip; public string MethodListTooltip { get { var method = typeDef.GetMethods().FirstOrDefault(); if (method.IsNil) return null; - ITextOutput output = new PlainTextOutput(); - var context = new Decompiler.Metadata.MetadataGenericContext(default(TypeDefinitionHandle), module); - ((EntityHandle)method).WriteTo(module, output, context); - return output.ToString(); + return GenerateTooltip(ref methodListTooltip, module, method); } } @@ -193,6 +189,8 @@ namespace ICSharpCode.ILSpy.Metadata this.metadata = module.Metadata; this.handle = handle; this.typeDef = metadata.GetTypeDefinition(handle); + this.methodListTooltip = null; + this.fieldListTooltip = null; } } diff --git a/ILSpy/Metadata/CorTables/TypeRefTableTreeNode.cs b/ILSpy/Metadata/CorTables/TypeRefTableTreeNode.cs index 6e34da4da..f0a773dc3 100644 --- a/ILSpy/Metadata/CorTables/TypeRefTableTreeNode.cs +++ b/ILSpy/Metadata/CorTables/TypeRefTableTreeNode.cs @@ -94,31 +94,8 @@ namespace ICSharpCode.ILSpy.Metadata MainWindow.Instance.JumpToReference(new EntityReference(module, typeRef.ResolutionScope, protocol: "metadata")); } - public string ResolutionScopeTooltip { - 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, default); - break; - } - return output.ToString(); - } - } + string resolutionScopeTooltip; + public string ResolutionScopeTooltip => GenerateTooltip(ref resolutionScopeTooltip, module, typeRef.ResolutionScope); public string NameTooltip => $"{MetadataTokens.GetHeapOffset(typeRef.Name):X} \"{Name}\""; @@ -135,6 +112,7 @@ namespace ICSharpCode.ILSpy.Metadata this.metadata = module.Metadata; this.handle = handle; this.typeRef = metadata.GetTypeReference(handle); + this.resolutionScopeTooltip = null; } } diff --git a/ILSpy/Metadata/DebugTables/CustomDebugInformationTableTreeNode.cs b/ILSpy/Metadata/DebugTables/CustomDebugInformationTableTreeNode.cs index 329cc86b6..9e9d46c61 100644 --- a/ILSpy/Metadata/DebugTables/CustomDebugInformationTableTreeNode.cs +++ b/ILSpy/Metadata/DebugTables/CustomDebugInformationTableTreeNode.cs @@ -205,14 +205,8 @@ namespace ICSharpCode.ILSpy.Metadata MainWindow.Instance.JumpToReference(new EntityReference(module, debugInfo.Parent, protocol: "metadata")); } - public string ParentTooltip { - get { - ITextOutput output = new PlainTextOutput(); - var context = new MetadataGenericContext(default(TypeDefinitionHandle), module); - debugInfo.Parent.WriteTo(module, output, context); - return $"{debugInfo.Parent.Kind}:\n{output}"; - } - } + string parentTooltip; + public string ParentTooltip => GenerateTooltip(ref parentTooltip, module, debugInfo.Parent); string kindString; public string Kind { diff --git a/ILSpy/Metadata/DebugTables/LocalScopeTableTreeNode.cs b/ILSpy/Metadata/DebugTables/LocalScopeTableTreeNode.cs index 6854b64e0..8b8ac8b1a 100644 --- a/ILSpy/Metadata/DebugTables/LocalScopeTableTreeNode.cs +++ b/ILSpy/Metadata/DebugTables/LocalScopeTableTreeNode.cs @@ -98,13 +98,8 @@ namespace ICSharpCode.ILSpy.Metadata MainWindow.Instance.JumpToReference(new EntityReference(module, localScope.Method, protocol: "metadata")); } - public string MethodTooltip { - get { - ITextOutput output = new PlainTextOutput(); - ((EntityHandle)localScope.Method).WriteTo(module, output, default); - return output.ToString(); - } - } + string methodTooltip; + public string MethodTooltip => GenerateTooltip(ref methodTooltip, module, localScope.Method); [ColumnInfo("X8", Kind = ColumnKind.Token)] public int ImportScope => MetadataTokens.GetToken(localScope.ImportScope); @@ -142,6 +137,7 @@ namespace ICSharpCode.ILSpy.Metadata this.metadata = metadata; this.handle = handle; this.localScope = metadata.GetLocalScope(handle); + this.methodTooltip = null; } } diff --git a/ILSpy/Metadata/DebugTables/StateMachineMethodTableTreeNode.cs b/ILSpy/Metadata/DebugTables/StateMachineMethodTableTreeNode.cs index 4973f38d3..e93c0c3d9 100644 --- a/ILSpy/Metadata/DebugTables/StateMachineMethodTableTreeNode.cs +++ b/ILSpy/Metadata/DebugTables/StateMachineMethodTableTreeNode.cs @@ -100,14 +100,8 @@ namespace ICSharpCode.ILSpy.Metadata MainWindow.Instance.JumpToReference(new EntityReference(module, moveNextMethod, protocol: "metadata")); } - public string MoveNextMethodTooltip { - get { - ITextOutput output = new PlainTextOutput(); - var context = new MetadataGenericContext(default(TypeDefinitionHandle), module); - ((EntityHandle)moveNextMethod).WriteTo(module, output, context); - return output.ToString(); - } - } + string moveNextMethodTooltip; + public string MoveNextMethodTooltip => GenerateTooltip(ref moveNextMethodTooltip, module, moveNextMethod); [ColumnInfo("X8", Kind = ColumnKind.Token)] public int KickoffMethod => MetadataTokens.GetToken(kickoffMethod); @@ -117,14 +111,8 @@ namespace ICSharpCode.ILSpy.Metadata MainWindow.Instance.JumpToReference(new EntityReference(module, kickoffMethod, protocol: "metadata")); } - public string KickoffMethodTooltip { - get { - ITextOutput output = new PlainTextOutput(); - var context = new MetadataGenericContext(default(TypeDefinitionHandle), module); - ((EntityHandle)kickoffMethod).WriteTo(module, output, context); - return output.ToString(); - } - } + string kickoffMethodTooltip; + public string KickoffMethodTooltip => GenerateTooltip(ref kickoffMethodTooltip, module, kickoffMethod); public StateMachineMethodEntry(PEFile module, ref BlobReader reader, bool isEmbedded, int row) { @@ -138,6 +126,8 @@ namespace ICSharpCode.ILSpy.Metadata int methodDefSize = metadata.GetTableRowCount(TableIndex.MethodDef) < ushort.MaxValue ? 2 : 4; this.moveNextMethod = MetadataTokens.MethodDefinitionHandle(methodDefSize == 2 ? reader.ReadInt16() : reader.ReadInt32()); this.kickoffMethod = MetadataTokens.MethodDefinitionHandle(methodDefSize == 2 ? reader.ReadInt16() : reader.ReadInt32()); + this.kickoffMethodTooltip = null; + this.moveNextMethodTooltip = null; } } diff --git a/ILSpy/Metadata/MetadataTableTreeNode.cs b/ILSpy/Metadata/MetadataTableTreeNode.cs index dbd8a424c..204270dc3 100644 --- a/ILSpy/Metadata/MetadataTableTreeNode.cs +++ b/ILSpy/Metadata/MetadataTableTreeNode.cs @@ -22,11 +22,10 @@ using System.Reflection.Metadata.Ecma335; using System.Windows.Controls; using System.Windows.Threading; +using ICSharpCode.Decompiler; using ICSharpCode.Decompiler.Metadata; -using ICSharpCode.ILSpy.TextView; +using ICSharpCode.Decompiler.IL; using ICSharpCode.ILSpy.TreeNodes; -using ICSharpCode.ILSpy.ViewModels; -using ICSharpCode.TreeView; namespace ICSharpCode.ILSpy.Metadata { @@ -62,6 +61,73 @@ namespace ICSharpCode.ILSpy.Metadata view.Loaded -= View_Loaded; this.scrollTarget = default; } + + protected static string GenerateTooltip(ref string tooltip, PEFile module, EntityHandle handle) + { + if (tooltip == null) + { + if (handle.IsNil) + { + return null; + } + ITextOutput output = new PlainTextOutput(); + var context = new MetadataGenericContext(default(TypeDefinitionHandle), module); + var metadata = module.Metadata; + switch (handle.Kind) + { + case HandleKind.ModuleDefinition: + output.Write(metadata.GetString(metadata.GetModuleDefinition().Name)); + output.Write(" (this module)"); + break; + case HandleKind.ModuleReference: + ModuleReference moduleReference = metadata.GetModuleReference((ModuleReferenceHandle)handle); + output.Write(metadata.GetString(moduleReference.Name)); + break; + case HandleKind.AssemblyReference: + var asmRef = new Decompiler.Metadata.AssemblyReference(module, (AssemblyReferenceHandle)handle); + output.Write(asmRef.ToString()); + break; + case HandleKind.Parameter: + var param = metadata.GetParameter((ParameterHandle)handle); + output.Write(param.SequenceNumber + " - " + metadata.GetString(param.Name)); + break; + case HandleKind.EventDefinition: + var @event = metadata.GetEventDefinition((EventDefinitionHandle)handle); + output.Write(metadata.GetString(@event.Name)); + break; + case HandleKind.PropertyDefinition: + var prop = metadata.GetPropertyDefinition((PropertyDefinitionHandle)handle); + output.Write(metadata.GetString(prop.Name)); + break; + case HandleKind.AssemblyDefinition: + var ad = metadata.GetAssemblyDefinition(); + output.Write(metadata.GetString(ad.Name)); + output.Write(" (this assembly)"); + break; + case HandleKind.AssemblyFile: + var af = metadata.GetAssemblyFile((AssemblyFileHandle)handle); + output.Write(metadata.GetString(af.Name)); + break; + case HandleKind.GenericParameter: + var gp = metadata.GetGenericParameter((GenericParameterHandle)handle); + output.Write(metadata.GetString(gp.Name)); + break; + case HandleKind.ManifestResource: + var mfr = metadata.GetManifestResource((ManifestResourceHandle)handle); + output.Write(metadata.GetString(mfr.Name)); + break; + case HandleKind.Document: + var doc = metadata.GetDocument((DocumentHandle)handle); + output.Write(metadata.GetString(doc.Name)); + break; + default: + handle.WriteTo(module, output, context); + break; + } + tooltip = "(" + handle.Kind + ") " + output.ToString(); + } + return tooltip; + } } internal abstract class DebugMetadataTableTreeNode : MetadataTableTreeNode