Browse Source

use TopLevelTypeReference in DecompiledTypeReference; use ParserService in ILSpySymbolSource.GetSymbols

newNRILSpyDebugger
Siegfried Pammer 12 years ago
parent
commit
786e8f7741
  1. 18
      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

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

@ -13,6 +13,7 @@ using ICSharpCode.Core;
using ICSharpCode.Decompiler; using ICSharpCode.Decompiler;
using ICSharpCode.Decompiler.Ast; using ICSharpCode.Decompiler.Ast;
using ICSharpCode.NRefactory.TypeSystem; using ICSharpCode.NRefactory.TypeSystem;
using ICSharpCode.SharpDevelop;
using ICSharpCode.SharpDevelop.Parser; using ICSharpCode.SharpDevelop.Parser;
using Mono.Cecil; using Mono.Cecil;
@ -151,9 +152,9 @@ namespace ICSharpCode.ILSpyAddIn
public class DecompiledTypeReference : IEquatable<DecompiledTypeReference> public class DecompiledTypeReference : IEquatable<DecompiledTypeReference>
{ {
public FileName AssemblyFile { get; private set; } 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.AssemblyFile = assemblyFile;
this.Type = type; this.Type = type;
@ -175,7 +176,16 @@ namespace ICSharpCode.ILSpyAddIn
asm = match.Groups[1].Value; asm = match.Groups[1].Value;
typeName = UnescapeTypeName(match.Groups[2].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) public static string EscapeTypeName(string typeName)
@ -194,9 +204,7 @@ namespace ICSharpCode.ILSpyAddIn
{ {
if (typeName == null) if (typeName == null)
throw new ArgumentNullException("typeName"); 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; return typeName;
} }

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

@ -8,6 +8,7 @@ using ICSharpCode.Decompiler;
using ICSharpCode.NRefactory; using ICSharpCode.NRefactory;
using ICSharpCode.NRefactory.Documentation; using ICSharpCode.NRefactory.Documentation;
using ICSharpCode.NRefactory.TypeSystem; using ICSharpCode.NRefactory.TypeSystem;
using ICSharpCode.SharpDevelop;
namespace ICSharpCode.ILSpyAddIn namespace ICSharpCode.ILSpyAddIn
{ {
@ -25,11 +26,13 @@ namespace ICSharpCode.ILSpyAddIn
public static MethodDebugSymbols GetSymbols(IMethod method) 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 id = IdStringProvider.GetIdString(method.MemberDefinition);
var content = DecompiledViewContent.Get(method);
if (content != null && content.DebugSymbols.ContainsKey(id)) { if (typeName == null) return null;
return content.DebugSymbols[id]; var file = SD.ParserService.ParseFile(typeName.ToFileName()) as ILSpyUnresolvedFile;
if (file != null && file.DebugSymbols.ContainsKey(id)) {
return file.DebugSymbols[id];
} }
return null; return null;
} }

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

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

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

@ -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); SD.Workbench.ShowView(newViewContent);
return newViewContent; return newViewContent;
} }

Loading…
Cancel
Save