Browse Source

fix some bugs in the ILSpy debugger integration

pull/685/head
Siegfried Pammer 10 years ago
parent
commit
51481d9230
  1. 2
      src/AddIns/Debugger/Debugger.Core/PdbSymbolSource.cs
  2. 38
      src/AddIns/DisplayBindings/ILSpyAddIn/DecompiledViewContent.cs
  3. 3
      src/AddIns/DisplayBindings/ILSpyAddIn/ILSpyParser.cs
  4. 3
      src/AddIns/DisplayBindings/ILSpyAddIn/ILSpySymbolSource.cs

2
src/AddIns/Debugger/Debugger.Core/PdbSymbolSource.cs

@ -256,7 +256,7 @@ namespace Debugger
var s = seqPoints[i]; var s = seqPoints[i];
if (s.ContainsLocation(line, column)) if (s.ContainsLocation(line, column))
return s; return s;
if (s.StartLine > line) if (s.StartLine > line || (s.StartLine == line && s.StartColumn > column))
return s; return s;
} }
return null; return null;

38
src/AddIns/DisplayBindings/ILSpyAddIn/DecompiledViewContent.cs

@ -27,6 +27,7 @@ using ICSharpCode.AvalonEdit.AddIn;
using ICSharpCode.AvalonEdit.Highlighting; using ICSharpCode.AvalonEdit.Highlighting;
using ICSharpCode.Core; using ICSharpCode.Core;
using ICSharpCode.Decompiler; using ICSharpCode.Decompiler;
using ICSharpCode.SharpDevelop.Gui;
using ICSharpCode.ILSpyAddIn; using ICSharpCode.ILSpyAddIn;
using ICSharpCode.NRefactory; using ICSharpCode.NRefactory;
using ICSharpCode.NRefactory.TypeSystem; using ICSharpCode.NRefactory.TypeSystem;
@ -39,12 +40,13 @@ namespace ICSharpCode.ILSpyAddIn
/// <summary> /// <summary>
/// Hosts a decompiled type. /// Hosts a decompiled type.
/// </summary> /// </summary>
class DecompiledViewContent : AbstractViewContentWithoutFile class DecompiledViewContent : AbstractViewContentWithoutFile, IPositionable
{ {
/// <summary> /// <summary>
/// Entity to jump to once decompilation has finished. /// Entity to jump to once decompilation has finished.
/// </summary> /// </summary>
string jumpToEntityIdStringWhenDecompilationFinished; string jumpToEntityIdStringWhenDecompilationFinished;
int jumpToLineWhenDecompilationFinished, jumpToColumnWhenDecompilationFinished;
bool decompilationFinished; bool decompilationFinished;
@ -72,6 +74,9 @@ namespace ICSharpCode.ILSpyAddIn
this.codeEditor.FileName = this.DecompiledTypeName.ToFileName(); this.codeEditor.FileName = this.DecompiledTypeName.ToFileName();
this.codeEditor.ActiveTextEditor.IsReadOnly = true; this.codeEditor.ActiveTextEditor.IsReadOnly = true;
this.codeEditor.ActiveTextEditor.SyntaxHighlighting = HighlightingManager.Instance.GetDefinition("C#"); this.codeEditor.ActiveTextEditor.SyntaxHighlighting = HighlightingManager.Instance.GetDefinition("C#");
this.Services.RemoveService(typeof(IPositionable));
this.Services.AddService(typeof(IPositionable), this);
} }
#endregion #endregion
@ -169,7 +174,10 @@ namespace ICSharpCode.ILSpyAddIn
codeEditor.Document.UndoStack.ClearAll(); codeEditor.Document.UndoStack.ClearAll();
this.decompilationFinished = true; this.decompilationFinished = true;
JumpToEntity(this.jumpToEntityIdStringWhenDecompilationFinished); if (!string.IsNullOrEmpty(jumpToEntityIdStringWhenDecompilationFinished))
JumpToEntity(this.jumpToEntityIdStringWhenDecompilationFinished);
else
JumpTo(jumpToLineWhenDecompilationFinished, jumpToColumnWhenDecompilationFinished);
// update UI // update UI
//UpdateIconMargin(); //UpdateIconMargin();
@ -228,5 +236,31 @@ namespace ICSharpCode.ILSpyAddIn
} }
#endregion #endregion
#region IPositionable implementation
public void JumpTo(int line, int column)
{
if (decompilationFinished) {
codeEditor.ActiveTextEditorAdapter.JumpTo(line, column);
} else {
jumpToLineWhenDecompilationFinished = line;
jumpToColumnWhenDecompilationFinished = column;
}
}
public int Line {
get {
return codeEditor.ActiveTextEditor.TextArea.Caret.Line;
}
}
public int Column {
get {
return codeEditor.ActiveTextEditor.TextArea.Caret.Column;
}
}
#endregion
} }
} }

3
src/AddIns/DisplayBindings/ILSpyAddIn/ILSpyParser.cs

@ -31,6 +31,7 @@ using ICSharpCode.NRefactory.Semantics;
using ICSharpCode.NRefactory.TypeSystem; using ICSharpCode.NRefactory.TypeSystem;
using ICSharpCode.SharpDevelop; using ICSharpCode.SharpDevelop;
using ICSharpCode.SharpDevelop.Dom.ClassBrowser; using ICSharpCode.SharpDevelop.Dom.ClassBrowser;
using ICSharpCode.SharpDevelop.Editor;
using ICSharpCode.SharpDevelop.Editor.Search; using ICSharpCode.SharpDevelop.Editor.Search;
using ICSharpCode.SharpDevelop.Parser; using ICSharpCode.SharpDevelop.Parser;
using ICSharpCode.SharpDevelop.Project; using ICSharpCode.SharpDevelop.Project;
@ -48,7 +49,7 @@ namespace ICSharpCode.ILSpyAddIn
return fileName != null && fileName.StartsWith("ilspy://", StringComparison.OrdinalIgnoreCase); return fileName != null && fileName.StartsWith("ilspy://", StringComparison.OrdinalIgnoreCase);
} }
readonly static ITextSource EmptyFileContent = new StringTextSource(""); readonly ITextSource EmptyFileContent = new StringTextSource("", new OnDiskTextSourceVersion(DateTime.MinValue));
public ITextSource GetFileContent(FileName fileName) public ITextSource GetFileContent(FileName fileName)
{ {

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

@ -29,7 +29,8 @@ namespace ICSharpCode.ILSpyAddIn
var typeName = DecompiledTypeReference.FromTypeDefinition(method.DeclaringTypeDefinition); var typeName = DecompiledTypeReference.FromTypeDefinition(method.DeclaringTypeDefinition);
if (typeName == null) return null; if (typeName == null) return null;
SD.Log.DebugFormatted("GetSymbols for: {0}", typeName.ToFileName()); SD.Log.DebugFormatted("GetSymbols for: {0}", typeName.ToFileName());
return SD.ParserService.ParseFile(typeName.ToFileName()) as ILSpyUnresolvedFile; // full parse info required to make ParserService caching possible...
return SD.ParserService.Parse(typeName.ToFileName()).UnresolvedFile as ILSpyUnresolvedFile;
} }
public Debugger.SequencePoint GetSequencePoint(IMethod method, int iloffset) public Debugger.SequencePoint GetSequencePoint(IMethod method, int iloffset)

Loading…
Cancel
Save