|
|
|
@ -2,6 +2,7 @@
@@ -2,6 +2,7 @@
|
|
|
|
|
using System.Collections.Generic; |
|
|
|
|
using System.Diagnostics; |
|
|
|
|
using System.Linq; |
|
|
|
|
using System.Reflection; |
|
|
|
|
using System.Reflection.Metadata; |
|
|
|
|
using System.Reflection.Metadata.Ecma335; |
|
|
|
|
using System.Text; |
|
|
|
@ -10,6 +11,7 @@ using System.Windows;
@@ -10,6 +11,7 @@ using System.Windows;
|
|
|
|
|
using System.Windows.Controls; |
|
|
|
|
using System.Windows.Input; |
|
|
|
|
using System.Windows.Media; |
|
|
|
|
using ICSharpCode.Decompiler.Metadata; |
|
|
|
|
using ICSharpCode.Decompiler.TypeSystem; |
|
|
|
|
using ICSharpCode.ILSpy.Analyzers; |
|
|
|
|
using ICSharpCode.ILSpy.Controls; |
|
|
|
@ -23,7 +25,6 @@ namespace ICSharpCode.ILSpy.Commands
@@ -23,7 +25,6 @@ namespace ICSharpCode.ILSpy.Commands
|
|
|
|
|
{ |
|
|
|
|
public bool IsVisible(TextViewContext context) |
|
|
|
|
{ |
|
|
|
|
var (c, selectedItem) = context.GetColumnAndRowFromMousePosition(); |
|
|
|
|
if (context.SelectedTreeNodes == null) |
|
|
|
|
return context.Reference?.Reference is IEntity; |
|
|
|
|
return context.SelectedTreeNodes.Length == 1 && context.SelectedTreeNodes.All(n => n is IMemberTreeNode); |
|
|
|
@ -31,7 +32,6 @@ namespace ICSharpCode.ILSpy.Commands
@@ -31,7 +32,6 @@ namespace ICSharpCode.ILSpy.Commands
|
|
|
|
|
|
|
|
|
|
public bool IsEnabled(TextViewContext context) |
|
|
|
|
{ |
|
|
|
|
var (c, selectedItem) = context.GetColumnAndRowFromMousePosition(); |
|
|
|
|
if (context.SelectedTreeNodes == null) |
|
|
|
|
return context.Reference?.Reference is IEntity; |
|
|
|
|
foreach (IMemberTreeNode node in context.SelectedTreeNodes) { |
|
|
|
@ -59,4 +59,41 @@ namespace ICSharpCode.ILSpy.Commands
@@ -59,4 +59,41 @@ namespace ICSharpCode.ILSpy.Commands
|
|
|
|
|
MainWindow.Instance.JumpToReference(selection); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
[ExportContextMenuEntry(Header = "Go to token", Order = 10)] |
|
|
|
|
class GoToToken : IContextMenuEntry |
|
|
|
|
{ |
|
|
|
|
public void Execute(TextViewContext context) |
|
|
|
|
{ |
|
|
|
|
int token = GetSelectedToken(context.DataGrid, out PEFile module).Value; |
|
|
|
|
MainWindow.Instance.JumpToReference(("metadata", module, MetadataTokens.Handle(token))); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
public bool IsEnabled(TextViewContext context) |
|
|
|
|
{ |
|
|
|
|
return true; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
public bool IsVisible(TextViewContext context) |
|
|
|
|
{ |
|
|
|
|
return context.DataGrid?.Name == "MetadataView" && GetSelectedToken(context.DataGrid, out _) != null; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
private int? GetSelectedToken(DataGrid grid, out PEFile module) |
|
|
|
|
{ |
|
|
|
|
module = null; |
|
|
|
|
if (grid == null) |
|
|
|
|
return null; |
|
|
|
|
var cell = grid.CurrentCell; |
|
|
|
|
if (!cell.IsValid) |
|
|
|
|
return null; |
|
|
|
|
Type type = cell.Item.GetType(); |
|
|
|
|
var property = type.GetProperty(cell.Column.Header.ToString()); |
|
|
|
|
var moduleField = type.GetField("module", BindingFlags.NonPublic | BindingFlags.Instance); |
|
|
|
|
if (property == null || property.PropertyType != typeof(int) || !property.GetCustomAttributes(false).Any(a => a is StringFormatAttribute sf && sf.Format == "X8")) |
|
|
|
|
return null; |
|
|
|
|
module = (PEFile)moduleField.GetValue(cell.Item); |
|
|
|
|
return (int)property.GetValue(cell.Item); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|