Browse Source

Add hyperlinks to other metadata tables to make the "Go to Token" command more accessible.

pull/2585/head
Siegfried Pammer 3 years ago
parent
commit
1998bb2967
  1. 2
      ILSpy/Metadata/CorTables/AssemblyRefTableTreeNode.cs
  2. 6
      ILSpy/Metadata/CorTables/ClassLayoutTableTreeNode.cs
  3. 6
      ILSpy/Metadata/CorTables/ConstantTableTreeNode.cs
  4. 12
      ILSpy/Metadata/CorTables/CustomAttributeTableTreeNode.cs
  5. 6
      ILSpy/Metadata/CorTables/DeclSecurityTableTreeNode.cs
  6. 12
      ILSpy/Metadata/CorTables/EventMapTableTreeNode.cs
  7. 6
      ILSpy/Metadata/CorTables/EventTableTreeNode.cs
  8. 6
      ILSpy/Metadata/CorTables/ExportedTypeTableTreeNode.cs
  9. 6
      ILSpy/Metadata/CorTables/FieldLayoutTableTreeNode.cs
  10. 6
      ILSpy/Metadata/CorTables/FieldMarshalTableTreeNode.cs
  11. 6
      ILSpy/Metadata/CorTables/FieldRVATableTreeNode.cs
  12. 12
      ILSpy/Metadata/CorTables/GenericParamConstraintTableTreeNode.cs
  13. 6
      ILSpy/Metadata/CorTables/GenericParamTableTreeNode.cs
  14. 12
      ILSpy/Metadata/CorTables/ImplMapTableTreeNode.cs
  15. 12
      ILSpy/Metadata/CorTables/InterfaceImplTableTreeNode.cs
  16. 6
      ILSpy/Metadata/CorTables/ManifestResourceTableTreeNode.cs
  17. 6
      ILSpy/Metadata/CorTables/MemberRefTableTreeNode.cs
  18. 18
      ILSpy/Metadata/CorTables/MethodImplTableTreeNode.cs
  19. 12
      ILSpy/Metadata/CorTables/MethodSemanticsTableTreeNode.cs
  20. 6
      ILSpy/Metadata/CorTables/MethodSpecTableTreeNode.cs
  21. 2
      ILSpy/Metadata/CorTables/MethodTableTreeNode.cs
  22. 12
      ILSpy/Metadata/CorTables/NestedClassTableTreeNode.cs
  23. 12
      ILSpy/Metadata/CorTables/PropertyMapTableTreeNode.cs
  24. 18
      ILSpy/Metadata/CorTables/TypeDefTableTreeNode.cs
  25. 6
      ILSpy/Metadata/CorTables/TypeRefTableTreeNode.cs
  26. 8
      ILSpy/Metadata/DebugTables/CustomDebugInformationTableTreeNode.cs
  27. 2
      ILSpy/Metadata/DebugTables/DocumentTableTreeNode.cs
  28. 8
      ILSpy/Metadata/DebugTables/ImportScopeTableTreeNode.cs
  29. 2
      ILSpy/Metadata/DebugTables/LocalConstantTableTreeNode.cs
  30. 26
      ILSpy/Metadata/DebugTables/LocalScopeTableTreeNode.cs
  31. 2
      ILSpy/Metadata/DebugTables/LocalVariableTableTreeNode.cs
  32. 14
      ILSpy/Metadata/DebugTables/MethodDebugInformationTableTreeNode.cs
  33. 14
      ILSpy/Metadata/DebugTables/StateMachineMethodTableTreeNode.cs
  34. 6
      ILSpy/Metadata/GoToTokenCommand.cs
  35. 75
      ILSpy/Metadata/Helpers.cs

2
ILSpy/Metadata/CorTables/AssemblyRefTableTreeNode.cs

@ -61,7 +61,7 @@ namespace ICSharpCode.ILSpy.Metadata @@ -61,7 +61,7 @@ namespace ICSharpCode.ILSpy.Metadata
view.ItemsSource = list;
tabPage.Content = view;
if (scrollTargetEntry.RID > 1)
if (scrollTargetEntry.RID > 0)
{
ScrollItemIntoView(view, scrollTargetEntry);
}

6
ILSpy/Metadata/CorTables/ClassLayoutTableTreeNode.cs

@ -101,8 +101,14 @@ namespace ICSharpCode.ILSpy.Metadata @@ -101,8 +101,14 @@ namespace ICSharpCode.ILSpy.Metadata
public int Offset { get; }
[StringFormat("X8")]
[LinkToTable]
public int Parent => MetadataTokens.GetToken(classLayout.Parent);
public void OnParentClick()
{
MainWindow.Instance.JumpToReference(new EntityReference(module, classLayout.Parent, protocol: "metadata"));
}
public string ParentTooltip {
get {
ITextOutput output = new PlainTextOutput();

6
ILSpy/Metadata/CorTables/ConstantTableTreeNode.cs

@ -93,8 +93,14 @@ namespace ICSharpCode.ILSpy.Metadata @@ -93,8 +93,14 @@ namespace ICSharpCode.ILSpy.Metadata
public string TypeTooltip => constant.TypeCode.ToString();
[StringFormat("X8")]
[LinkToTable]
public int Parent => MetadataTokens.GetToken(constant.Parent);
public void OnParentClick()
{
MainWindow.Instance.JumpToReference(new EntityReference(module, constant.Parent, protocol: "metadata"));
}
public string ParentTooltip {
get {
ITextOutput output = new PlainTextOutput();

12
ILSpy/Metadata/CorTables/CustomAttributeTableTreeNode.cs

@ -88,8 +88,14 @@ namespace ICSharpCode.ILSpy.Metadata @@ -88,8 +88,14 @@ namespace ICSharpCode.ILSpy.Metadata
+ metadata.GetTableRowSize(TableIndex.CustomAttribute) * (RID - 1);
[StringFormat("X8")]
[LinkToTable]
public int Parent => MetadataTokens.GetToken(customAttr.Parent);
public void OnParentClick()
{
MainWindow.Instance.JumpToReference(new EntityReference(module, customAttr.Parent, protocol: "metadata"));
}
public string ParentTooltip {
get {
ITextOutput output = new PlainTextOutput();
@ -100,8 +106,14 @@ namespace ICSharpCode.ILSpy.Metadata @@ -100,8 +106,14 @@ namespace ICSharpCode.ILSpy.Metadata
}
[StringFormat("X8")]
[LinkToTable]
public int Constructor => MetadataTokens.GetToken(customAttr.Constructor);
public void OnConstructorClick()
{
MainWindow.Instance.JumpToReference(new EntityReference(module, customAttr.Constructor, protocol: "metadata"));
}
public string ConstructorTooltip {
get {
ITextOutput output = new PlainTextOutput();

6
ILSpy/Metadata/CorTables/DeclSecurityTableTreeNode.cs

@ -89,8 +89,14 @@ namespace ICSharpCode.ILSpy.Metadata @@ -89,8 +89,14 @@ namespace ICSharpCode.ILSpy.Metadata
+ metadata.GetTableRowSize(TableIndex.DeclSecurity) * (RID - 1);
[StringFormat("X8")]
[LinkToTable]
public int Parent => MetadataTokens.GetToken(declSecAttr.Parent);
public void OnParentClick()
{
MainWindow.Instance.JumpToReference(new EntityReference(module, declSecAttr.Parent, protocol: "metadata"));
}
public string ParentTooltip {
get {
ITextOutput output = new PlainTextOutput();

12
ILSpy/Metadata/CorTables/EventMapTableTreeNode.cs

@ -99,8 +99,14 @@ namespace ICSharpCode.ILSpy.Metadata @@ -99,8 +99,14 @@ namespace ICSharpCode.ILSpy.Metadata
public int Offset { get; }
[StringFormat("X8")]
[LinkToTable]
public int Parent => MetadataTokens.GetToken(eventMap.Parent);
public void OnParentClick()
{
MainWindow.Instance.JumpToReference(new EntityReference(module, eventMap.Parent, protocol: "metadata"));
}
public string ParentTooltip {
get {
ITextOutput output = new PlainTextOutput();
@ -111,8 +117,14 @@ namespace ICSharpCode.ILSpy.Metadata @@ -111,8 +117,14 @@ namespace ICSharpCode.ILSpy.Metadata
}
[StringFormat("X8")]
[LinkToTable]
public int EventList => MetadataTokens.GetToken(eventMap.EventList);
public void OnEventListClick()
{
MainWindow.Instance.JumpToReference(new EntityReference(module, eventMap.EventList, protocol: "metadata"));
}
public string EventListTooltip {
get {
ITextOutput output = new PlainTextOutput();

6
ILSpy/Metadata/CorTables/EventTableTreeNode.cs

@ -104,8 +104,14 @@ namespace ICSharpCode.ILSpy.Metadata @@ -104,8 +104,14 @@ namespace ICSharpCode.ILSpy.Metadata
IEntity IMemberTreeNode.Member => ((MetadataModule)module.GetTypeSystemWithCurrentOptionsOrNull()?.MainModule).GetDefinition(handle);
[StringFormat("X8")]
[LinkToTable]
public int Type => MetadataTokens.GetToken(eventDef.Type);
public void OnTypeClick()
{
MainWindow.Instance.JumpToReference(new EntityReference(module, eventDef.Type, protocol: "metadata"));
}
public string TypeTooltip {
get {
ITextOutput output = new PlainTextOutput();

6
ILSpy/Metadata/CorTables/ExportedTypeTableTreeNode.cs

@ -111,8 +111,14 @@ namespace ICSharpCode.ILSpy.Metadata @@ -111,8 +111,14 @@ namespace ICSharpCode.ILSpy.Metadata
public string TypeNamespace => metadata.GetString(type.Namespace);
[StringFormat("X8")]
[LinkToTable]
public int Implementation => MetadataTokens.GetToken(type.Implementation);
public void OnImplementationClick()
{
MainWindow.Instance.JumpToReference(new EntityReference(module, type.Implementation, protocol: "metadata"));
}
public string ImplementationTooltip {
get {
if (type.Implementation.IsNil)

6
ILSpy/Metadata/CorTables/FieldLayoutTableTreeNode.cs

@ -99,8 +99,14 @@ namespace ICSharpCode.ILSpy.Metadata @@ -99,8 +99,14 @@ namespace ICSharpCode.ILSpy.Metadata
public int Offset { get; }
[StringFormat("X8")]
[LinkToTable]
public int Field => MetadataTokens.GetToken(fieldLayout.Field);
public void OnFieldClick()
{
MainWindow.Instance.JumpToReference(new EntityReference(module, fieldLayout.Field, protocol: "metadata"));
}
public string FieldTooltip {
get {
ITextOutput output = new PlainTextOutput();

6
ILSpy/Metadata/CorTables/FieldMarshalTableTreeNode.cs

@ -99,8 +99,14 @@ namespace ICSharpCode.ILSpy.Metadata @@ -99,8 +99,14 @@ namespace ICSharpCode.ILSpy.Metadata
public int Offset { get; }
[StringFormat("X8")]
[LinkToTable]
public int Parent => MetadataTokens.GetToken(fieldMarshal.Parent);
public void OnParentClick()
{
MainWindow.Instance.JumpToReference(new EntityReference(module, fieldMarshal.Parent, protocol: "metadata"));
}
public string ParentTooltip {
get {
ITextOutput output = new PlainTextOutput();

6
ILSpy/Metadata/CorTables/FieldRVATableTreeNode.cs

@ -99,8 +99,14 @@ namespace ICSharpCode.ILSpy.Metadata @@ -99,8 +99,14 @@ namespace ICSharpCode.ILSpy.Metadata
public int Offset { get; }
[StringFormat("X8")]
[LinkToTable]
public int Field => MetadataTokens.GetToken(fieldLayout.Field);
public void OnFieldClick()
{
MainWindow.Instance.JumpToReference(new EntityReference(module, fieldLayout.Field, protocol: "metadata"));
}
public string FieldTooltip {
get {
ITextOutput output = new PlainTextOutput();

12
ILSpy/Metadata/CorTables/GenericParamConstraintTableTreeNode.cs

@ -87,8 +87,14 @@ namespace ICSharpCode.ILSpy.Metadata @@ -87,8 +87,14 @@ namespace ICSharpCode.ILSpy.Metadata
+ metadata.GetTableRowSize(TableIndex.GenericParamConstraint) * (RID - 1);
[StringFormat("X8")]
[LinkToTable]
public int Owner => MetadataTokens.GetToken(genericParamConstraint.Parameter);
public void OnOwnerClick()
{
MainWindow.Instance.JumpToReference(new EntityReference(module, genericParamConstraint.Parameter, protocol: "metadata"));
}
string ownerTooltip;
public string OwnerTooltip {
@ -106,8 +112,14 @@ namespace ICSharpCode.ILSpy.Metadata @@ -106,8 +112,14 @@ namespace ICSharpCode.ILSpy.Metadata
}
[StringFormat("X8")]
[LinkToTable]
public int Type => MetadataTokens.GetToken(genericParamConstraint.Type);
public void OnTypeClick()
{
MainWindow.Instance.JumpToReference(new EntityReference(module, genericParamConstraint.Type, protocol: "metadata"));
}
public string TypeTooltip {
get {
ITextOutput output = new PlainTextOutput();

6
ILSpy/Metadata/CorTables/GenericParamTableTreeNode.cs

@ -97,8 +97,14 @@ namespace ICSharpCode.ILSpy.Metadata @@ -97,8 +97,14 @@ namespace ICSharpCode.ILSpy.Metadata
};
[StringFormat("X8")]
[LinkToTable]
public int Owner => MetadataTokens.GetToken(genericParam.Parent);
public void OnParentClick()
{
MainWindow.Instance.JumpToReference(new EntityReference(module, genericParam.Parent, protocol: "metadata"));
}
public string OwnerTooltip {
get {
ITextOutput output = new PlainTextOutput();

12
ILSpy/Metadata/CorTables/ImplMapTableTreeNode.cs

@ -116,8 +116,14 @@ namespace ICSharpCode.ILSpy.Metadata @@ -116,8 +116,14 @@ namespace ICSharpCode.ILSpy.Metadata
};
[StringFormat("X8")]
[LinkToTable]
public int MemberForwarded => MetadataTokens.GetToken(implMap.MemberForwarded);
public void OnMemberForwardedClick()
{
MainWindow.Instance.JumpToReference(new EntityReference(module, implMap.MemberForwarded, protocol: "metadata"));
}
public string MemberForwardedTooltip {
get {
ITextOutput output = new PlainTextOutput();
@ -128,8 +134,14 @@ namespace ICSharpCode.ILSpy.Metadata @@ -128,8 +134,14 @@ namespace ICSharpCode.ILSpy.Metadata
}
[StringFormat("X8")]
[LinkToTable]
public int ImportScope => MetadataTokens.GetToken(implMap.ImportScope);
public void OnImportScopeClick()
{
MainWindow.Instance.JumpToReference(new EntityReference(module, implMap.ImportScope, protocol: "metadata"));
}
public string ImportScopeTooltip {
get {
ITextOutput output = new PlainTextOutput();

12
ILSpy/Metadata/CorTables/InterfaceImplTableTreeNode.cs

@ -99,8 +99,14 @@ namespace ICSharpCode.ILSpy.Metadata @@ -99,8 +99,14 @@ namespace ICSharpCode.ILSpy.Metadata
public int Offset { get; }
[StringFormat("X8")]
[LinkToTable]
public int Class => MetadataTokens.GetToken(interfaceImpl.Class);
public void OnClassClick()
{
MainWindow.Instance.JumpToReference(new EntityReference(module, interfaceImpl.Class, protocol: "metadata"));
}
public string ClassTooltip {
get {
ITextOutput output = new PlainTextOutput();
@ -111,8 +117,14 @@ namespace ICSharpCode.ILSpy.Metadata @@ -111,8 +117,14 @@ namespace ICSharpCode.ILSpy.Metadata
}
[StringFormat("X8")]
[LinkToTable]
public int Interface => MetadataTokens.GetToken(interfaceImpl.Interface);
public void OnInterfaceClick()
{
MainWindow.Instance.JumpToReference(new EntityReference(module, interfaceImpl.Interface, protocol: "metadata"));
}
public string InterfaceTooltip {
get {
ITextOutput output = new PlainTextOutput();

6
ILSpy/Metadata/CorTables/ManifestResourceTableTreeNode.cs

@ -98,8 +98,14 @@ namespace ICSharpCode.ILSpy.Metadata @@ -98,8 +98,14 @@ namespace ICSharpCode.ILSpy.Metadata
public string NameTooltip => $"{MetadataTokens.GetHeapOffset(manifestResource.Name):X} \"{Name}\"";
[StringFormat("X8")]
[LinkToTable]
public int Implementation => MetadataTokens.GetToken(manifestResource.Implementation);
public void OnImplementationClick()
{
MainWindow.Instance.JumpToReference(new EntityReference(module, manifestResource.Implementation, protocol: "metadata"));
}
public string ImplementationTooltip {
get {
if (manifestResource.Implementation.IsNil)

6
ILSpy/Metadata/CorTables/MemberRefTableTreeNode.cs

@ -88,8 +88,14 @@ namespace ICSharpCode.ILSpy.Metadata @@ -88,8 +88,14 @@ namespace ICSharpCode.ILSpy.Metadata
+ metadata.GetTableRowSize(TableIndex.MemberRef) * (RID - 1);
[StringFormat("X8")]
[LinkToTable]
public int Parent => MetadataTokens.GetToken(memberRef.Parent);
public void OnParentClick()
{
MainWindow.Instance.JumpToReference(new EntityReference(module, memberRef.Parent, protocol: "metadata"));
}
public string ParentTooltip {
get {
ITextOutput output = new PlainTextOutput();

18
ILSpy/Metadata/CorTables/MethodImplTableTreeNode.cs

@ -87,8 +87,14 @@ namespace ICSharpCode.ILSpy.Metadata @@ -87,8 +87,14 @@ namespace ICSharpCode.ILSpy.Metadata
+ metadata.GetTableRowSize(TableIndex.MethodDef) * (RID - 1);
[StringFormat("X8")]
[LinkToTable]
public int MethodDeclaration => MetadataTokens.GetToken(methodImpl.MethodDeclaration);
public void OnMethodDeclarationClick()
{
MainWindow.Instance.JumpToReference(new EntityReference(module, methodImpl.MethodDeclaration, protocol: "metadata"));
}
public string MethodDeclarationTooltip {
get {
ITextOutput output = new PlainTextOutput();
@ -98,8 +104,14 @@ namespace ICSharpCode.ILSpy.Metadata @@ -98,8 +104,14 @@ namespace ICSharpCode.ILSpy.Metadata
}
[StringFormat("X8")]
[LinkToTable]
public int MethodBody => MetadataTokens.GetToken(methodImpl.MethodBody);
public void OnMethodBodyClick()
{
MainWindow.Instance.JumpToReference(new EntityReference(module, methodImpl.MethodBody, protocol: "metadata"));
}
public string MethodBodyTooltip {
get {
ITextOutput output = new PlainTextOutput();
@ -109,8 +121,14 @@ namespace ICSharpCode.ILSpy.Metadata @@ -109,8 +121,14 @@ namespace ICSharpCode.ILSpy.Metadata
}
[StringFormat("X8")]
[LinkToTable]
public int Type => MetadataTokens.GetToken(methodImpl.Type);
public void OnTypeClick()
{
MainWindow.Instance.JumpToReference(new EntityReference(module, methodImpl.Type, protocol: "metadata"));
}
public string TypeTooltip {
get {
ITextOutput output = new PlainTextOutput();

12
ILSpy/Metadata/CorTables/MethodSemanticsTableTreeNode.cs

@ -96,8 +96,14 @@ namespace ICSharpCode.ILSpy.Metadata @@ -96,8 +96,14 @@ namespace ICSharpCode.ILSpy.Metadata
public string SemanticsTooltip => semantics.ToString();
[StringFormat("X8")]
[LinkToTable]
public int Method => MetadataTokens.GetToken(method);
public void OnMethodClick()
{
MainWindow.Instance.JumpToReference(new EntityReference(module, method, protocol: "metadata"));
}
public string MethodTooltip {
get {
ITextOutput output = new PlainTextOutput();
@ -107,8 +113,14 @@ namespace ICSharpCode.ILSpy.Metadata @@ -107,8 +113,14 @@ namespace ICSharpCode.ILSpy.Metadata
}
[StringFormat("X8")]
[LinkToTable]
public int Association => MetadataTokens.GetToken(association);
public void OnAssociationClick()
{
MainWindow.Instance.JumpToReference(new EntityReference(module, association, protocol: "metadata"));
}
public string AssociationTooltip {
get {
ITextOutput output = new PlainTextOutput();

6
ILSpy/Metadata/CorTables/MethodSpecTableTreeNode.cs

@ -88,8 +88,14 @@ namespace ICSharpCode.ILSpy.Metadata @@ -88,8 +88,14 @@ namespace ICSharpCode.ILSpy.Metadata
+ metadata.GetTableRowSize(TableIndex.MethodSpec) * (RID - 1);
[StringFormat("X8")]
[LinkToTable]
public int Method => MetadataTokens.GetToken(methodSpec.Method);
public void OnMethodClick()
{
MainWindow.Instance.JumpToReference(new EntityReference(module, methodSpec.Method, protocol: "metadata"));
}
public string MethodTooltip {
get {
ITextOutput output = new PlainTextOutput();

2
ILSpy/Metadata/CorTables/MethodTableTreeNode.cs

@ -68,7 +68,7 @@ namespace ICSharpCode.ILSpy.Metadata @@ -68,7 +68,7 @@ namespace ICSharpCode.ILSpy.Metadata
tabPage.Content = view;
if (scrollTargetEntry.RID > 1)
if (scrollTargetEntry.RID > 0)
{
ScrollItemIntoView(view, scrollTargetEntry);
}

12
ILSpy/Metadata/CorTables/NestedClassTableTreeNode.cs

@ -99,8 +99,14 @@ namespace ICSharpCode.ILSpy.Metadata @@ -99,8 +99,14 @@ namespace ICSharpCode.ILSpy.Metadata
public int Offset { get; }
[StringFormat("X8")]
[LinkToTable]
public int NestedClass => MetadataTokens.GetToken(nestedClass.Nested);
public void OnNestedClassClick()
{
MainWindow.Instance.JumpToReference(new EntityReference(module, nestedClass.Nested, protocol: "metadata"));
}
public string NestedClassTooltip {
get {
ITextOutput output = new PlainTextOutput();
@ -111,8 +117,14 @@ namespace ICSharpCode.ILSpy.Metadata @@ -111,8 +117,14 @@ namespace ICSharpCode.ILSpy.Metadata
}
[StringFormat("X8")]
[LinkToTable]
public int EnclosingClass => MetadataTokens.GetToken(nestedClass.Enclosing);
public void OnEnclosingClassClick()
{
MainWindow.Instance.JumpToReference(new EntityReference(module, nestedClass.Enclosing, protocol: "metadata"));
}
public string EnclosingClassTooltip {
get {
ITextOutput output = new PlainTextOutput();

12
ILSpy/Metadata/CorTables/PropertyMapTableTreeNode.cs

@ -99,8 +99,14 @@ namespace ICSharpCode.ILSpy.Metadata @@ -99,8 +99,14 @@ namespace ICSharpCode.ILSpy.Metadata
public int Offset { get; }
[StringFormat("X8")]
[LinkToTable]
public int Parent => MetadataTokens.GetToken(propertyMap.Parent);
public void OnParentClick()
{
MainWindow.Instance.JumpToReference(new EntityReference(module, propertyMap.Parent, protocol: "metadata"));
}
public string ParentTooltip {
get {
ITextOutput output = new PlainTextOutput();
@ -111,8 +117,14 @@ namespace ICSharpCode.ILSpy.Metadata @@ -111,8 +117,14 @@ namespace ICSharpCode.ILSpy.Metadata
}
[StringFormat("X8")]
[LinkToTable]
public int PropertyList => MetadataTokens.GetToken(propertyMap.PropertyList);
public void OnPropertyListClick()
{
MainWindow.Instance.JumpToReference(new EntityReference(module, propertyMap.PropertyList, protocol: "metadata"));
}
public string PropertyListTooltip {
get {
ITextOutput output = new PlainTextOutput();

18
ILSpy/Metadata/CorTables/TypeDefTableTreeNode.cs

@ -114,8 +114,14 @@ namespace ICSharpCode.ILSpy.Metadata @@ -114,8 +114,14 @@ namespace ICSharpCode.ILSpy.Metadata
public string Namespace => metadata.GetString(typeDef.Namespace);
[StringFormat("X8")]
[LinkToTable]
public int BaseType => MetadataTokens.GetToken(typeDef.BaseType);
public void OnBaseTypeClick()
{
MainWindow.Instance.JumpToReference(new EntityReference(module, typeDef.BaseType, protocol: "metadata"));
}
public string BaseTypeTooltip {
get {
var output = new PlainTextOutput();
@ -140,8 +146,14 @@ namespace ICSharpCode.ILSpy.Metadata @@ -140,8 +146,14 @@ namespace ICSharpCode.ILSpy.Metadata
}
[StringFormat("X8")]
[LinkToTable]
public int FieldList => MetadataTokens.GetToken(typeDef.GetFields().FirstOrDefault());
public void OnFieldListClick()
{
MainWindow.Instance.JumpToReference(new EntityReference(module, typeDef.GetFields().FirstOrDefault(), protocol: "metadata"));
}
public string FieldListTooltip {
get {
var field = typeDef.GetFields().FirstOrDefault();
@ -155,8 +167,14 @@ namespace ICSharpCode.ILSpy.Metadata @@ -155,8 +167,14 @@ namespace ICSharpCode.ILSpy.Metadata
}
[StringFormat("X8")]
[LinkToTable]
public int MethodList => MetadataTokens.GetToken(typeDef.GetMethods().FirstOrDefault());
public void OnMethodListClick()
{
MainWindow.Instance.JumpToReference(new EntityReference(module, typeDef.GetMethods().FirstOrDefault(), protocol: "metadata"));
}
public string MethodListTooltip {
get {
var method = typeDef.GetMethods().FirstOrDefault();

6
ILSpy/Metadata/CorTables/TypeRefTableTreeNode.cs

@ -87,8 +87,14 @@ namespace ICSharpCode.ILSpy.Metadata @@ -87,8 +87,14 @@ namespace ICSharpCode.ILSpy.Metadata
+ metadata.GetTableRowSize(TableIndex.TypeRef) * (RID - 1);
[StringFormat("X8")]
[LinkToTable]
public int ResolutionScope => MetadataTokens.GetToken(typeRef.ResolutionScope);
public void OnResolutionScopeClick()
{
MainWindow.Instance.JumpToReference(new EntityReference(module, typeRef.ResolutionScope, protocol: "metadata"));
}
public string ResolutionScopeTooltip {
get {
if (typeRef.ResolutionScope.IsNil)

8
ILSpy/Metadata/DebugTables/CustomDebugInformationTableTreeNode.cs

@ -76,7 +76,7 @@ namespace ICSharpCode.ILSpy.Metadata @@ -76,7 +76,7 @@ namespace ICSharpCode.ILSpy.Metadata
tabPage.Content = view;
if (scrollTargetEntry?.RID > 1)
if (scrollTargetEntry?.RID > 0)
{
ScrollItemIntoView(view, scrollTargetEntry);
}
@ -186,8 +186,14 @@ namespace ICSharpCode.ILSpy.Metadata @@ -186,8 +186,14 @@ namespace ICSharpCode.ILSpy.Metadata
public object Offset => offset == null ? null : offset;
[StringFormat("X8")]
[LinkToTable]
public int Parent => MetadataTokens.GetToken(debugInfo.Parent);
public void OnParentClick()
{
MainWindow.Instance.JumpToReference(new EntityReference(module, debugInfo.Parent, protocol: "metadata"));
}
public string ParentTooltip {
get {
ITextOutput output = new PlainTextOutput();

2
ILSpy/Metadata/DebugTables/DocumentTableTreeNode.cs

@ -65,7 +65,7 @@ namespace ICSharpCode.ILSpy.Metadata @@ -65,7 +65,7 @@ namespace ICSharpCode.ILSpy.Metadata
tabPage.Content = view;
if (scrollTargetEntry.RID > 1)
if (scrollTargetEntry.RID > 0)
{
ScrollItemIntoView(view, scrollTargetEntry);
}

8
ILSpy/Metadata/DebugTables/ImportScopeTableTreeNode.cs

@ -68,7 +68,7 @@ namespace ICSharpCode.ILSpy.Metadata @@ -68,7 +68,7 @@ namespace ICSharpCode.ILSpy.Metadata
tabPage.Content = view;
if (scrollTargetEntry.RID > 1)
if (scrollTargetEntry.RID > 0)
{
ScrollItemIntoView(view, scrollTargetEntry);
}
@ -89,8 +89,14 @@ namespace ICSharpCode.ILSpy.Metadata @@ -89,8 +89,14 @@ namespace ICSharpCode.ILSpy.Metadata
public object Offset => offset == null ? "n/a" : (object)offset;
[StringFormat("X8")]
[LinkToTable]
public int Parent => MetadataTokens.GetToken(localScope.Parent);
public void OnParentClick()
{
MainWindow.Instance.JumpToReference(new EntityReference(module, localScope.Parent, protocol: "metadata"));
}
[StringFormat("X")]
public int Imports => MetadataTokens.GetHeapOffset(localScope.ImportsBlob);

2
ILSpy/Metadata/DebugTables/LocalConstantTableTreeNode.cs

@ -66,7 +66,7 @@ namespace ICSharpCode.ILSpy.Metadata @@ -66,7 +66,7 @@ namespace ICSharpCode.ILSpy.Metadata
tabPage.Content = view;
if (scrollTargetEntry.RID > 1)
if (scrollTargetEntry.RID > 0)
{
ScrollItemIntoView(view, scrollTargetEntry);
}

26
ILSpy/Metadata/DebugTables/LocalScopeTableTreeNode.cs

@ -68,7 +68,7 @@ namespace ICSharpCode.ILSpy.Metadata @@ -68,7 +68,7 @@ namespace ICSharpCode.ILSpy.Metadata
tabPage.Content = view;
if (scrollTargetEntry.RID > 1)
if (scrollTargetEntry.RID > 0)
{
ScrollItemIntoView(view, scrollTargetEntry);
}
@ -89,8 +89,14 @@ namespace ICSharpCode.ILSpy.Metadata @@ -89,8 +89,14 @@ namespace ICSharpCode.ILSpy.Metadata
public object Offset => offset == null ? "n/a" : (object)offset;
[StringFormat("X8")]
[LinkToTable]
public int Method => MetadataTokens.GetToken(localScope.Method);
public void OnMethodClick()
{
MainWindow.Instance.JumpToReference(new EntityReference(module, localScope.Method, protocol: "metadata"));
}
public string MethodTooltip {
get {
ITextOutput output = new PlainTextOutput();
@ -100,14 +106,32 @@ namespace ICSharpCode.ILSpy.Metadata @@ -100,14 +106,32 @@ namespace ICSharpCode.ILSpy.Metadata
}
[StringFormat("X8")]
[LinkToTable]
public int ImportScope => MetadataTokens.GetToken(localScope.ImportScope);
public void OnImportScopeClick()
{
MainWindow.Instance.JumpToReference(new EntityReference(module, localScope.ImportScope, protocol: "metadata"));
}
[StringFormat("X8")]
[LinkToTable]
public int VariableList => MetadataTokens.GetToken(localScope.GetLocalVariables().FirstOrDefault());
public void OnVariableListClick()
{
MainWindow.Instance.JumpToReference(new EntityReference(module, localScope.GetLocalVariables().FirstOrDefault(), protocol: "metadata"));
}
[StringFormat("X8")]
[LinkToTable]
public int ConstantList => MetadataTokens.GetToken(localScope.GetLocalConstants().FirstOrDefault());
public void OnConstantListClick()
{
MainWindow.Instance.JumpToReference(new EntityReference(module, localScope.GetLocalConstants().FirstOrDefault(), protocol: "metadata"));
}
public int StartOffset => localScope.StartOffset;
public int Length => localScope.Length;

2
ILSpy/Metadata/DebugTables/LocalVariableTableTreeNode.cs

@ -62,7 +62,7 @@ namespace ICSharpCode.ILSpy.Metadata @@ -62,7 +62,7 @@ namespace ICSharpCode.ILSpy.Metadata
tabPage.Content = view;
if (scrollTargetEntry.RID > 1)
if (scrollTargetEntry.RID > 0)
{
ScrollItemIntoView(view, scrollTargetEntry);
}

14
ILSpy/Metadata/DebugTables/MethodDebugInformationTableTreeNode.cs

@ -66,7 +66,7 @@ namespace ICSharpCode.ILSpy.Metadata @@ -66,7 +66,7 @@ namespace ICSharpCode.ILSpy.Metadata
tabPage.Content = view;
if (scrollTargetEntry.RID > 1)
if (scrollTargetEntry.RID > 0)
{
ScrollItemIntoView(view, scrollTargetEntry);
}
@ -87,8 +87,14 @@ namespace ICSharpCode.ILSpy.Metadata @@ -87,8 +87,14 @@ namespace ICSharpCode.ILSpy.Metadata
public object Offset => offset == null ? "n/a" : (object)offset;
[StringFormat("X8")]
[LinkToTable]
public int Document => MetadataTokens.GetToken(debugInfo.Document);
public void OnDocumentClick()
{
MainWindow.Instance.JumpToReference(new EntityReference(module, debugInfo.Document, protocol: "metadata"));
}
public string DocumentTooltip {
get {
if (debugInfo.Document.IsNil)
@ -115,8 +121,14 @@ namespace ICSharpCode.ILSpy.Metadata @@ -115,8 +121,14 @@ namespace ICSharpCode.ILSpy.Metadata
}
[StringFormat("X")]
[LinkToTable]
public int LocalSignature => MetadataTokens.GetToken(debugInfo.LocalSignature);
public void OnLocalSignatureClick()
{
MainWindow.Instance.JumpToReference(new EntityReference(module, debugInfo.LocalSignature, protocol: "metadata"));
}
public string LocalSignatureTooltip {
get {
if (debugInfo.LocalSignature.IsNil)

14
ILSpy/Metadata/DebugTables/StateMachineMethodTableTreeNode.cs

@ -70,7 +70,7 @@ namespace ICSharpCode.ILSpy.Metadata @@ -70,7 +70,7 @@ namespace ICSharpCode.ILSpy.Metadata
tabPage.Content = view;
if (scrollTargetEntry.RID > 1)
if (scrollTargetEntry.RID > 0)
{
ScrollItemIntoView(view, scrollTargetEntry);
}
@ -91,8 +91,14 @@ namespace ICSharpCode.ILSpy.Metadata @@ -91,8 +91,14 @@ namespace ICSharpCode.ILSpy.Metadata
public object Offset => offset == null ? "n/a" : (object)offset;
[StringFormat("X8")]
[LinkToTable]
public int MoveNextMethod => MetadataTokens.GetToken(moveNextMethod);
public void OnMoveNextMethodClick()
{
MainWindow.Instance.JumpToReference(new EntityReference(module, moveNextMethod, protocol: "metadata"));
}
public string MoveNextMethodTooltip {
get {
ITextOutput output = new PlainTextOutput();
@ -103,8 +109,14 @@ namespace ICSharpCode.ILSpy.Metadata @@ -103,8 +109,14 @@ namespace ICSharpCode.ILSpy.Metadata
}
[StringFormat("X8")]
[LinkToTable]
public int KickoffMethod => MetadataTokens.GetToken(kickoffMethod);
public void OnKickofMethodClick()
{
MainWindow.Instance.JumpToReference(new EntityReference(module, kickoffMethod, protocol: "metadata"));
}
public string KickoffMethodTooltip {
get {
ITextOutput output = new PlainTextOutput();

6
ILSpy/Metadata/GoToTokenCommand.cs

@ -94,7 +94,11 @@ namespace ICSharpCode.ILSpy.Commands @@ -94,7 +94,11 @@ namespace ICSharpCode.ILSpy.Commands
if (hit == null)
return null;
var cell = hit.VisualHit.GetParent<DataGridCell>();
return (cell?.Content as TextBlock)?.Text;
if (cell == null)
return null;
return cell.DataContext.GetType()
.GetProperty(cell.Column.Header.ToString(), BindingFlags.Instance | BindingFlags.Public)
.GetValue(cell.DataContext).ToString();
}
}
}

75
ILSpy/Metadata/Helpers.cs

@ -30,7 +30,9 @@ using System.Threading.Tasks; @@ -30,7 +30,9 @@ using System.Threading.Tasks;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Media;
using System.Windows.Navigation;
using DataGridExtensions;
@ -93,16 +95,7 @@ namespace ICSharpCode.ILSpy.Metadata @@ -93,16 +95,7 @@ namespace ICSharpCode.ILSpy.Metadata
internal static void View_AutoGeneratingColumn(object sender, DataGridAutoGeneratingColumnEventArgs e)
{
var binding = new Binding(e.PropertyName) { Mode = BindingMode.OneWay };
e.Column = e.PropertyType.FullName switch {
"System.Boolean" => new DataGridCheckBoxColumn() {
Header = e.PropertyName,
Binding = binding
},
_ => new DataGridTextColumn() {
Header = e.PropertyName,
Binding = binding
}
};
e.Column = GetColumn();
switch (e.PropertyName)
{
case "RID":
@ -136,6 +129,64 @@ namespace ICSharpCode.ILSpy.Metadata @@ -136,6 +129,64 @@ namespace ICSharpCode.ILSpy.Metadata
{
ApplyAttributes((PropertyDescriptor)e.PropertyDescriptor, binding, e.Column);
}
DataGridColumn GetColumn()
{
if (e.PropertyType == typeof(bool))
{
return new DataGridCheckBoxColumn() {
Header = e.PropertyName,
Binding = binding
};
}
var descriptor = (PropertyDescriptor)e.PropertyDescriptor;
if (descriptor.Attributes.OfType<LinkToTableAttribute>().Any())
{
return new DataGridTemplateColumn() {
Header = e.PropertyName,
CellTemplate = GetOrCreateLinkCellTemplate(e.PropertyName, descriptor, binding)
};
}
return new DataGridTextColumn() {
Header = e.PropertyName,
Binding = binding
};
}
}
static readonly Dictionary<string, DataTemplate> linkCellTemplates = new Dictionary<string, DataTemplate>();
private static DataTemplate GetOrCreateLinkCellTemplate(string name, PropertyDescriptor descriptor, Binding binding)
{
if (linkCellTemplates.TryGetValue(name, out var template))
{
return template;
}
var tb = new FrameworkElementFactory(typeof(TextBlock));
var hyper = new FrameworkElementFactory(typeof(Hyperlink));
tb.AppendChild(hyper);
hyper.AddHandler(Hyperlink.ClickEvent, new RoutedEventHandler(Hyperlink_Click));
var run = new FrameworkElementFactory(typeof(Run));
hyper.AppendChild(run);
run.SetBinding(Run.TextProperty, binding);
DataTemplate dataTemplate = new DataTemplate() { VisualTree = tb };
linkCellTemplates.Add(name, dataTemplate);
return dataTemplate;
void Hyperlink_Click(object sender, RoutedEventArgs e)
{
var hyperlink = (Hyperlink)sender;
var onClickMethod = descriptor.ComponentType.GetMethod("On" + name + "Click", BindingFlags.Instance | BindingFlags.Public);
if (onClickMethod != null)
{
onClickMethod.Invoke(hyperlink.DataContext, Array.Empty<object>());
}
}
}
static void ApplyAttributes(PropertyDescriptor descriptor, Binding binding, DataGridColumn column)
@ -253,6 +304,10 @@ namespace ICSharpCode.ILSpy.Metadata @@ -253,6 +304,10 @@ namespace ICSharpCode.ILSpy.Metadata
}
}
class LinkToTableAttribute : Attribute
{
}
[Flags]
internal enum TableMask : ulong
{

Loading…
Cancel
Save