Browse Source

use TopLevelTypeReference in DecompiledTypeReference; use ParserService in ILSpySymbolSource.GetSymbols

newNRILSpyDebugger
Siegfried Pammer 12 years ago
parent
commit
786e8f7741
  1. 20
      src/AddIns/DisplayBindings/ILSpyAddIn/ILSpyDecompilerService.cs
  2. 11
      src/AddIns/DisplayBindings/ILSpyAddIn/ILSpySymbolSource.cs
  3. 2
      src/AddIns/DisplayBindings/ILSpyAddIn/NavigateToDecompiledEntityService.cs
  4. 2
      src/AddIns/DisplayBindings/ILSpyAddIn/ViewContent/DecompiledViewContent.cs

20
src/AddIns/DisplayBindings/ILSpyAddIn/ILSpyDecompilerService.cs

@ -13,6 +13,7 @@ using ICSharpCode.Core; @@ -13,6 +13,7 @@ using ICSharpCode.Core;
using ICSharpCode.Decompiler;
using ICSharpCode.Decompiler.Ast;
using ICSharpCode.NRefactory.TypeSystem;
using ICSharpCode.SharpDevelop;
using ICSharpCode.SharpDevelop.Parser;
using Mono.Cecil;
@ -151,9 +152,9 @@ namespace ICSharpCode.ILSpyAddIn @@ -151,9 +152,9 @@ namespace ICSharpCode.ILSpyAddIn
public class DecompiledTypeReference : IEquatable<DecompiledTypeReference>
{
public FileName AssemblyFile { get; private set; }
public FullTypeName Type { get; private set; }
public TopLevelTypeName Type { get; private set; }
public DecompiledTypeReference(FileName assemblyFile, FullTypeName type)
public DecompiledTypeReference(FileName assemblyFile, TopLevelTypeName type)
{
this.AssemblyFile = assemblyFile;
this.Type = type;
@ -175,7 +176,16 @@ namespace ICSharpCode.ILSpyAddIn @@ -175,7 +176,16 @@ namespace ICSharpCode.ILSpyAddIn
asm = match.Groups[1].Value;
typeName = UnescapeTypeName(match.Groups[2].Value);
return new DecompiledTypeReference(new FileName(asm), new FullTypeName(typeName));
return new DecompiledTypeReference(new FileName(asm), new TopLevelTypeName(typeName));
}
public static DecompiledTypeReference FromTypeDefinition(ITypeDefinition definition)
{
FileName assemblyLocation = definition.ParentAssembly.GetRuntimeAssemblyLocation();
if (assemblyLocation != null && SD.FileSystem.FileExists(assemblyLocation)) {
return new DecompiledTypeReference(assemblyLocation, definition.FullTypeName.TopLevelTypeName);
}
return null;
}
public static string EscapeTypeName(string typeName)
@ -194,9 +204,7 @@ namespace ICSharpCode.ILSpyAddIn @@ -194,9 +204,7 @@ namespace ICSharpCode.ILSpyAddIn
{
if (typeName == null)
throw new ArgumentNullException("typeName");
foreach (var ch in Path.GetInvalidFileNameChars().Concat(new[] { '_' })) {
typeName = unescapeRegex.Replace(typeName, m => ((char)int.Parse(m.Groups[1].Value, System.Globalization.NumberStyles.HexNumber)).ToString());
}
typeName = unescapeRegex.Replace(typeName, m => ((char)int.Parse(m.Groups[1].Value, System.Globalization.NumberStyles.HexNumber)).ToString());
return typeName;
}

11
src/AddIns/DisplayBindings/ILSpyAddIn/ILSpySymbolSource.cs

@ -8,6 +8,7 @@ using ICSharpCode.Decompiler; @@ -8,6 +8,7 @@ using ICSharpCode.Decompiler;
using ICSharpCode.NRefactory;
using ICSharpCode.NRefactory.Documentation;
using ICSharpCode.NRefactory.TypeSystem;
using ICSharpCode.SharpDevelop;
namespace ICSharpCode.ILSpyAddIn
{
@ -25,11 +26,13 @@ namespace ICSharpCode.ILSpyAddIn @@ -25,11 +26,13 @@ namespace ICSharpCode.ILSpyAddIn
public static MethodDebugSymbols GetSymbols(IMethod method)
{
// Use the non-specialised method definition to look up decompiled symbols
var typeName = DecompiledTypeReference.FromTypeDefinition(method.DeclaringTypeDefinition);
var id = IdStringProvider.GetIdString(method.MemberDefinition);
var content = DecompiledViewContent.Get(method);
if (content != null && content.DebugSymbols.ContainsKey(id)) {
return content.DebugSymbols[id];
if (typeName == null) return null;
var file = SD.ParserService.ParseFile(typeName.ToFileName()) as ILSpyUnresolvedFile;
if (file != null && file.DebugSymbols.ContainsKey(id)) {
return file.DebugSymbols[id];
}
return null;
}

2
src/AddIns/DisplayBindings/ILSpyAddIn/NavigateToDecompiledEntityService.cs

@ -44,7 +44,7 @@ namespace ICSharpCode.ILSpyAddIn @@ -44,7 +44,7 @@ namespace ICSharpCode.ILSpyAddIn
if (string.IsNullOrEmpty(typeName))
throw new ArgumentException("typeName is null or empty");
var type = new FullTypeName(typeName);
var type = new TopLevelTypeName(typeName);
var target = new DecompiledTypeReference(assemblyFile, type);
foreach (var viewContent in SD.Workbench.ViewContentCollection.OfType<DecompiledViewContent>()) {

2
src/AddIns/DisplayBindings/ILSpyAddIn/ViewContent/DecompiledViewContent.cs

@ -104,7 +104,7 @@ namespace ICSharpCode.ILSpyAddIn @@ -104,7 +104,7 @@ namespace ICSharpCode.ILSpyAddIn
}
}
var newViewContent = new DecompiledViewContent(new DecompiledTypeReference(assemblyFile, new FullTypeName(typeName)), null);
var newViewContent = new DecompiledViewContent(new DecompiledTypeReference(assemblyFile, new TopLevelTypeName(typeName)), null);
SD.Workbench.ShowView(newViewContent);
return newViewContent;
}

Loading…
Cancel
Save