Browse Source

Fix #2356: Can't navigate if switch language in Analyze panel.

pull/2350/head
Siegfried Pammer 5 years ago
parent
commit
0284337a01
  1. 2
      ILSpy/Analyzers/AnalyzerEntityTreeNode.cs
  2. 16
      ILSpy/EntityReference.cs
  3. 6
      ILSpy/MainWindow.xaml.cs
  4. 2
      ILSpy/Metadata/GoToTokenCommand.cs
  5. 2
      ILSpy/TextView/AvalonEditTextOutput.cs
  6. 5
      ILSpy/TextView/DecompilerTextView.cs

2
ILSpy/Analyzers/AnalyzerEntityTreeNode.cs

@ -41,7 +41,7 @@ namespace ICSharpCode.ILSpy.Analyzers @@ -41,7 +41,7 @@ namespace ICSharpCode.ILSpy.Analyzers
MessageBox.Show(Properties.Resources.CannotAnalyzeMissingRef, "ILSpy");
return;
}
MainWindow.Instance.JumpToReference(this.Member);
MainWindow.Instance.JumpToReference(new EntityReference(this.Member.ParentModule.PEFile.FileName, this.Member.MetadataToken));
}
public override bool HandleAssemblyListChanged(ICollection<LoadedAssembly> removedAssemblies, ICollection<LoadedAssembly> addedAssemblies)

16
ILSpy/EntityReference.cs

@ -27,20 +27,26 @@ namespace ICSharpCode.ILSpy @@ -27,20 +27,26 @@ namespace ICSharpCode.ILSpy
[DebuggerDisplay("EntityReference Module={Module}, Handle={Handle}, Protocol={Protocol}")]
public class EntityReference
{
public PEFile Module { get; }
public string Module { get; }
public Handle Handle { get; }
public string Protocol { get; }
public EntityReference(PEFile module, Handle handle)
public EntityReference(string moduleFileName, Handle handle)
{
this.Module = module ?? throw new ArgumentNullException(nameof(module));
this.Module = moduleFileName;
this.Handle = handle;
this.Protocol = "decompile";
}
public EntityReference(string protocol, PEFile module, Handle handle)
: this(module, handle)
public EntityReference(string protocol, string moduleFileName, Handle handle)
: this(moduleFileName, handle)
{
this.Protocol = protocol ?? "decompile";
}
public PEFile ResolveAssembly(AssemblyList context)
{
return context.FindAssembly(Module)?.GetPEFileOrNull();
}
}
}

6
ILSpy/MainWindow.xaml.cs

@ -1046,7 +1046,11 @@ namespace ICSharpCode.ILSpy @@ -1046,7 +1046,11 @@ namespace ICSharpCode.ILSpy
break;
case EntityReference unresolvedEntity:
string protocol = unresolvedEntity.Protocol ?? "decompile";
PEFile file = unresolvedEntity.Module;
PEFile file = unresolvedEntity.ResolveAssembly(assemblyList);
if (file == null)
{
break;
}
if (protocol != "decompile")
{
var protocolHandlers = App.ExportProvider.GetExports<IProtocolHandler>();

2
ILSpy/Metadata/GoToTokenCommand.cs

@ -37,7 +37,7 @@ namespace ICSharpCode.ILSpy.Commands @@ -37,7 +37,7 @@ namespace ICSharpCode.ILSpy.Commands
public void Execute(TextViewContext context)
{
int token = GetSelectedToken(context.DataGrid, out PEFile module).Value;
MainWindow.Instance.JumpToReference(new EntityReference("metadata", module, MetadataTokens.Handle(token)));
MainWindow.Instance.JumpToReference(new EntityReference("metadata", module.FileName, MetadataTokens.Handle(token)));
}
public bool IsEnabled(TextViewContext context)

2
ILSpy/TextView/AvalonEditTextOutput.cs

@ -270,7 +270,7 @@ namespace ICSharpCode.ILSpy.TextView @@ -270,7 +270,7 @@ namespace ICSharpCode.ILSpy.TextView
{
this.DefinitionLookup.AddDefinition((module, handle), this.TextLength);
}
references.Add(new ReferenceSegment { StartOffset = start, EndOffset = end, Reference = new EntityReference(protocol, module, handle), IsDefinition = isDefinition });
references.Add(new ReferenceSegment { StartOffset = start, EndOffset = end, Reference = new EntityReference(protocol, module.FileName, handle), IsDefinition = isDefinition });
}
public void WriteReference(IType type, string text, bool isDefinition = false)

5
ILSpy/TextView/DecompilerTextView.cs

@ -404,8 +404,9 @@ namespace ICSharpCode.ILSpy.TextView @@ -404,8 +404,9 @@ namespace ICSharpCode.ILSpy.TextView
}
else if (segment.Reference is EntityReference unresolvedEntity)
{
var typeSystem = new DecompilerTypeSystem(unresolvedEntity.Module,
unresolvedEntity.Module.GetAssemblyResolver(),
var module = unresolvedEntity.ResolveAssembly(MainWindow.Instance.CurrentAssemblyList);
var typeSystem = new DecompilerTypeSystem(module,
module.GetAssemblyResolver(),
TypeSystemOptions.Default | TypeSystemOptions.Uncached);
try
{

Loading…
Cancel
Save