Browse Source

Introduce GenerateTooltip: Add more information to tooltips; display token kind and "Name" if available

pull/2799/head
Siegfried Pammer 3 years ago
parent
commit
a0d3dc87c4
  1. 11
      ILSpy/Metadata/CorTables/ClassLayoutTableTreeNode.cs
  2. 11
      ILSpy/Metadata/CorTables/ConstantTableTreeNode.cs
  3. 22
      ILSpy/Metadata/CorTables/CustomAttributeTableTreeNode.cs
  4. 11
      ILSpy/Metadata/CorTables/DeclSecurityTableTreeNode.cs
  5. 22
      ILSpy/Metadata/CorTables/EventMapTableTreeNode.cs
  6. 10
      ILSpy/Metadata/CorTables/EventTableTreeNode.cs
  7. 13
      ILSpy/Metadata/CorTables/ExportedTypeTableTreeNode.cs
  8. 11
      ILSpy/Metadata/CorTables/FieldLayoutTableTreeNode.cs
  9. 11
      ILSpy/Metadata/CorTables/FieldMarshalTableTreeNode.cs
  10. 13
      ILSpy/Metadata/CorTables/FieldRVATableTreeNode.cs
  11. 11
      ILSpy/Metadata/CorTables/FieldTableTreeNode.cs
  12. 10
      ILSpy/Metadata/CorTables/GenericParamConstraintTableTreeNode.cs
  13. 12
      ILSpy/Metadata/CorTables/GenericParamTableTreeNode.cs
  14. 22
      ILSpy/Metadata/CorTables/ImplMapTableTreeNode.cs
  15. 22
      ILSpy/Metadata/CorTables/InterfaceImplTableTreeNode.cs
  16. 13
      ILSpy/Metadata/CorTables/ManifestResourceTableTreeNode.cs
  17. 21
      ILSpy/Metadata/CorTables/MemberRefTableTreeNode.cs
  18. 30
      ILSpy/Metadata/CorTables/MethodImplTableTreeNode.cs
  19. 20
      ILSpy/Metadata/CorTables/MethodSemanticsTableTreeNode.cs
  20. 10
      ILSpy/Metadata/CorTables/MethodSpecTableTreeNode.cs
  21. 13
      ILSpy/Metadata/CorTables/MethodTableTreeNode.cs
  22. 22
      ILSpy/Metadata/CorTables/NestedClassTableTreeNode.cs
  23. 22
      ILSpy/Metadata/CorTables/PropertyMapTableTreeNode.cs
  24. 10
      ILSpy/Metadata/CorTables/PropertyTableTreeNode.cs
  25. 11
      ILSpy/Metadata/CorTables/StandAloneSigTableTreeNode.cs
  26. 14
      ILSpy/Metadata/CorTables/TypeDefTableTreeNode.cs
  27. 28
      ILSpy/Metadata/CorTables/TypeRefTableTreeNode.cs
  28. 10
      ILSpy/Metadata/DebugTables/CustomDebugInformationTableTreeNode.cs
  29. 10
      ILSpy/Metadata/DebugTables/LocalScopeTableTreeNode.cs
  30. 22
      ILSpy/Metadata/DebugTables/StateMachineMethodTableTreeNode.cs
  31. 72
      ILSpy/Metadata/MetadataTableTreeNode.cs

11
ILSpy/Metadata/CorTables/ClassLayoutTableTreeNode.cs

@ -108,14 +108,8 @@ namespace ICSharpCode.ILSpy.Metadata @@ -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 @@ -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;
}
}

11
ILSpy/Metadata/CorTables/ConstantTableTreeNode.cs

@ -100,14 +100,8 @@ namespace ICSharpCode.ILSpy.Metadata @@ -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 @@ -125,6 +119,7 @@ namespace ICSharpCode.ILSpy.Metadata
this.metadata = module.Metadata;
this.handle = handle;
this.constant = metadata.GetConstant(handle);
this.parentTooltip = null;
}
}

22
ILSpy/Metadata/CorTables/CustomAttributeTableTreeNode.cs

@ -95,14 +95,8 @@ namespace ICSharpCode.ILSpy.Metadata @@ -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 @@ -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 @@ -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;
}
}

11
ILSpy/Metadata/CorTables/DeclSecurityTableTreeNode.cs

@ -96,14 +96,8 @@ namespace ICSharpCode.ILSpy.Metadata @@ -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 @@ -130,6 +124,7 @@ namespace ICSharpCode.ILSpy.Metadata
this.metadata = module.Metadata;
this.handle = handle;
this.declSecAttr = metadata.GetDeclarativeSecurityAttribute(handle);
this.parentTooltip = null;
}
}

22
ILSpy/Metadata/CorTables/EventMapTableTreeNode.cs

@ -106,14 +106,8 @@ namespace ICSharpCode.ILSpy.Metadata @@ -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 @@ -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 @@ -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;
}
}

10
ILSpy/Metadata/CorTables/EventTableTreeNode.cs

@ -111,13 +111,8 @@ namespace ICSharpCode.ILSpy.Metadata @@ -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 @@ -126,6 +121,7 @@ namespace ICSharpCode.ILSpy.Metadata
this.metadata = module.Metadata;
this.handle = handle;
this.eventDef = metadata.GetEventDefinition(handle);
this.typeTooltip = null;
}
}

13
ILSpy/Metadata/CorTables/ExportedTypeTableTreeNode.cs

@ -118,16 +118,8 @@ namespace ICSharpCode.ILSpy.Metadata @@ -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 @@ -136,6 +128,7 @@ namespace ICSharpCode.ILSpy.Metadata
this.metadata = module.Metadata;
this.handle = handle;
this.type = type;
this.implementationTooltip = null;
}
}

11
ILSpy/Metadata/CorTables/FieldLayoutTableTreeNode.cs

@ -106,14 +106,8 @@ namespace ICSharpCode.ILSpy.Metadata @@ -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 @@ -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;
}
}

11
ILSpy/Metadata/CorTables/FieldMarshalTableTreeNode.cs

@ -106,14 +106,8 @@ namespace ICSharpCode.ILSpy.Metadata @@ -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 @@ -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;
}
}

13
ILSpy/Metadata/CorTables/FieldRVATableTreeNode.cs

@ -106,14 +106,8 @@ namespace ICSharpCode.ILSpy.Metadata @@ -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 @@ -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;
}
}

11
ILSpy/Metadata/CorTables/FieldTableTreeNode.cs

@ -113,14 +113,8 @@ namespace ICSharpCode.ILSpy.Metadata @@ -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 @@ -129,6 +123,7 @@ namespace ICSharpCode.ILSpy.Metadata
this.metadata = module.Metadata;
this.handle = handle;
this.fieldDef = metadata.GetFieldDefinition(handle);
this.signatureTooltip = null;
}
}

10
ILSpy/Metadata/CorTables/GenericParamConstraintTableTreeNode.cs

@ -118,13 +118,8 @@ namespace ICSharpCode.ILSpy.Metadata @@ -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 @@ -134,6 +129,7 @@ namespace ICSharpCode.ILSpy.Metadata
this.handle = handle;
this.genericParamConstraint = metadata.GetGenericParameterConstraint(handle);
this.ownerTooltip = null;
this.typeTooltip = null;
}
}

12
ILSpy/Metadata/CorTables/GenericParamTableTreeNode.cs

@ -99,18 +99,13 @@ namespace ICSharpCode.ILSpy.Metadata @@ -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 @@ -123,6 +118,7 @@ namespace ICSharpCode.ILSpy.Metadata
this.metadata = module.Metadata;
this.handle = handle;
this.genericParam = metadata.GetGenericParameter(handle);
this.ownerTooltip = null;
}
}

22
ILSpy/Metadata/CorTables/ImplMapTableTreeNode.cs

@ -123,14 +123,8 @@ namespace ICSharpCode.ILSpy.Metadata @@ -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 @@ -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 @@ -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;
}
}

22
ILSpy/Metadata/CorTables/InterfaceImplTableTreeNode.cs

@ -106,14 +106,8 @@ namespace ICSharpCode.ILSpy.Metadata @@ -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 @@ -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 @@ -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;
}
}

13
ILSpy/Metadata/CorTables/ManifestResourceTableTreeNode.cs

@ -105,16 +105,8 @@ namespace ICSharpCode.ILSpy.Metadata @@ -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 @@ -123,6 +115,7 @@ namespace ICSharpCode.ILSpy.Metadata
this.metadata = module.Metadata;
this.handle = handle;
this.manifestResource = metadata.GetManifestResource(handle);
this.implementationTooltip = null;
}
}

21
ILSpy/Metadata/CorTables/MemberRefTableTreeNode.cs

@ -95,13 +95,8 @@ namespace ICSharpCode.ILSpy.Metadata @@ -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 @@ -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 @@ -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;
}
}

30
ILSpy/Metadata/CorTables/MethodImplTableTreeNode.cs

@ -94,13 +94,8 @@ namespace ICSharpCode.ILSpy.Metadata @@ -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 @@ -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 @@ -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 @@ -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;
}
}

20
ILSpy/Metadata/CorTables/MethodSemanticsTableTreeNode.cs

@ -103,13 +103,8 @@ namespace ICSharpCode.ILSpy.Metadata @@ -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 @@ -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 @@ -136,6 +126,8 @@ namespace ICSharpCode.ILSpy.Metadata
this.semantics = semantics;
this.method = method;
this.association = association;
this.methodTooltip = null;
this.associationTooltip = null;
}
}

10
ILSpy/Metadata/CorTables/MethodSpecTableTreeNode.cs

@ -95,13 +95,8 @@ namespace ICSharpCode.ILSpy.Metadata @@ -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 @@ -130,6 +125,7 @@ namespace ICSharpCode.ILSpy.Metadata
this.metadata = module.Metadata;
this.handle = handle;
this.methodSpec = metadata.GetMethodSpecification(handle);
this.methodTooltip = null;
}
}

13
ILSpy/Metadata/CorTables/MethodTableTreeNode.cs

@ -122,18 +122,7 @@ namespace ICSharpCode.ILSpy.Metadata @@ -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);

22
ILSpy/Metadata/CorTables/NestedClassTableTreeNode.cs

@ -106,14 +106,8 @@ namespace ICSharpCode.ILSpy.Metadata @@ -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 @@ -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 @@ -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;
}
}

22
ILSpy/Metadata/CorTables/PropertyMapTableTreeNode.cs

@ -106,14 +106,8 @@ namespace ICSharpCode.ILSpy.Metadata @@ -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 @@ -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 @@ -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;
}
}

10
ILSpy/Metadata/CorTables/PropertyTableTreeNode.cs

@ -106,13 +106,8 @@ namespace ICSharpCode.ILSpy.Metadata @@ -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 @@ -121,6 +116,7 @@ namespace ICSharpCode.ILSpy.Metadata
this.metadata = module.Metadata;
this.handle = handle;
this.propertyDef = metadata.GetPropertyDefinition(handle);
this.signatureTooltip = null;
}
}

11
ILSpy/Metadata/CorTables/StandAloneSigTableTreeNode.cs

@ -89,14 +89,8 @@ namespace ICSharpCode.ILSpy.Metadata @@ -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 @@ -105,6 +99,7 @@ namespace ICSharpCode.ILSpy.Metadata
this.metadata = module.Metadata;
this.handle = handle;
this.standaloneSig = metadata.GetStandaloneSignature(handle);
this.signatureTooltip = null;
}
}

14
ILSpy/Metadata/CorTables/TypeDefTableTreeNode.cs

@ -152,15 +152,13 @@ namespace ICSharpCode.ILSpy.Metadata @@ -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 @@ -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 @@ -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;
}
}

28
ILSpy/Metadata/CorTables/TypeRefTableTreeNode.cs

@ -94,31 +94,8 @@ namespace ICSharpCode.ILSpy.Metadata @@ -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 @@ -135,6 +112,7 @@ namespace ICSharpCode.ILSpy.Metadata
this.metadata = module.Metadata;
this.handle = handle;
this.typeRef = metadata.GetTypeReference(handle);
this.resolutionScopeTooltip = null;
}
}

10
ILSpy/Metadata/DebugTables/CustomDebugInformationTableTreeNode.cs

@ -205,14 +205,8 @@ namespace ICSharpCode.ILSpy.Metadata @@ -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 {

10
ILSpy/Metadata/DebugTables/LocalScopeTableTreeNode.cs

@ -98,13 +98,8 @@ namespace ICSharpCode.ILSpy.Metadata @@ -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 @@ -142,6 +137,7 @@ namespace ICSharpCode.ILSpy.Metadata
this.metadata = metadata;
this.handle = handle;
this.localScope = metadata.GetLocalScope(handle);
this.methodTooltip = null;
}
}

22
ILSpy/Metadata/DebugTables/StateMachineMethodTableTreeNode.cs

@ -100,14 +100,8 @@ namespace ICSharpCode.ILSpy.Metadata @@ -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 @@ -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 @@ -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;
}
}

72
ILSpy/Metadata/MetadataTableTreeNode.cs

@ -22,11 +22,10 @@ using System.Reflection.Metadata.Ecma335; @@ -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 @@ -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

Loading…
Cancel
Save