Browse Source

Use MemberReference instead of TypeDefinition.

pull/191/merge
Eusebiu Marcu 14 years ago
parent
commit
bccf5e72e1
  1. 12
      Debugger/ILSpy.Debugger/Bookmarks/BookmarkManager.cs
  2. 6
      Debugger/ILSpy.Debugger/Bookmarks/CurrentLineBookmark.cs
  3. 4
      Debugger/ILSpy.Debugger/Services/Debugger/DebuggerService.cs
  4. 12
      Debugger/ILSpy.Debugger/Services/Debugger/WindowsDebugger.cs
  5. 6
      ICSharpCode.Decompiler/CodeMappings.cs
  6. 4
      ILSpy/TextView/DecompilerTextView.cs

12
Debugger/ILSpy.Debugger/Bookmarks/BookmarkManager.cs

@ -161,11 +161,11 @@ namespace ICSharpCode.ILSpy.Debugger.Bookmarks
if (instruction == null) if (instruction == null)
return; return;
TypeDefinition type; MemberReference memberReference;
int newline; int newline;
if (newMappings.GetSourceCodeFromMetadataTokenAndOffset(markerType.FullName, token, instruction.ILInstructionOffset.From, out type, out newline)) { if (newMappings.GetSourceCodeFromMetadataTokenAndOffset(markerType.FullName, token, instruction.ILInstructionOffset.From, out memberReference, out newline)) {
// 4. create breakpoint for new languages // 4. create breakpoint for new languages
CurrentLineBookmark.SetPosition(type, newline, 0, newline, 0); CurrentLineBookmark.SetPosition(memberReference, newline, 0, newline, 0);
} }
} }
@ -195,11 +195,11 @@ namespace ICSharpCode.ILSpy.Debugger.Bookmarks
if (instruction == null) if (instruction == null)
continue; continue;
TypeDefinition type; MemberReference memberReference;
int line; int line;
if (newMappings.GetSourceCodeFromMetadataTokenAndOffset(bp.Member.FullName, token, instruction.ILInstructionOffset.From, out type, out line)) { if (newMappings.GetSourceCodeFromMetadataTokenAndOffset(bp.Member.FullName, token, instruction.ILInstructionOffset.From, out memberReference, out line)) {
// 2. create breakpoint for new languages // 2. create breakpoint for new languages
var bookmark = new BreakpointBookmark(type, new AstLocation(line, 0), BreakpointAction.Break, newLanguage); var bookmark = new BreakpointBookmark(memberReference, new AstLocation(line, 0), BreakpointAction.Break, newLanguage);
AddMark(bookmark); AddMark(bookmark);
} }
} }

6
Debugger/ILSpy.Debugger/Bookmarks/CurrentLineBookmark.cs

@ -24,7 +24,7 @@ namespace ICSharpCode.ILSpy.Debugger.Bookmarks
static int endLine; static int endLine;
static int endColumn; static int endColumn;
public static void SetPosition(TypeDefinition type, int makerStartLine, int makerStartColumn, int makerEndLine, int makerEndColumn) public static void SetPosition(MemberReference memberReference, int makerStartLine, int makerStartColumn, int makerEndLine, int makerEndColumn)
{ {
Remove(); Remove();
@ -33,7 +33,7 @@ namespace ICSharpCode.ILSpy.Debugger.Bookmarks
endLine = makerEndLine; endLine = makerEndLine;
endColumn = makerEndColumn; endColumn = makerEndColumn;
instance = new CurrentLineBookmark(type, new AstLocation(startLine, startColumn)); instance = new CurrentLineBookmark(memberReference, new AstLocation(startLine, startColumn));
BookmarkManager.AddMark(instance); BookmarkManager.AddMark(instance);
} }
@ -53,7 +53,7 @@ namespace ICSharpCode.ILSpy.Debugger.Bookmarks
get { return 100; } get { return 100; }
} }
public CurrentLineBookmark(TypeDefinition type, AstLocation location) : base(type, location) public CurrentLineBookmark(MemberReference member, AstLocation location) : base(member, location)
{ {
} }

4
Debugger/ILSpy.Debugger/Services/Debugger/DebuggerService.cs

@ -184,9 +184,9 @@ namespace ICSharpCode.ILSpy.Debugger.Services
CurrentLineBookmark.Remove(); CurrentLineBookmark.Remove();
} }
public static void JumpToCurrentLine(TypeDefinition type, int startLine, int startColumn, int endLine, int endColumn) public static void JumpToCurrentLine(MemberReference memberReference, int startLine, int startColumn, int endLine, int endColumn)
{ {
CurrentLineBookmark.SetPosition(type, startLine, startColumn, endLine, endColumn); CurrentLineBookmark.SetPosition(memberReference, startLine, startColumn, endLine, endColumn);
} }
#region Tool tips #region Tool tips

12
Debugger/ILSpy.Debugger/Services/Debugger/WindowsDebugger.cs

@ -823,12 +823,12 @@ namespace ICSharpCode.ILSpy.Debugger.Services
uint token = (uint)frame.MethodInfo.MetadataToken; uint token = (uint)frame.MethodInfo.MetadataToken;
int ilOffset = frame.IP; int ilOffset = frame.IP;
int line; int line;
TypeDefinition type; MemberReference memberReference;
if (CodeMappingsStorage.GetSourceCodeFromMetadataTokenAndOffset(frame.MethodInfo.DeclaringType.FullName, token, ilOffset, out type, out line) if (CodeMappingsStorage.GetSourceCodeFromMetadataTokenAndOffset(frame.MethodInfo.DeclaringType.FullName, token, ilOffset, out memberReference, out line)
&& type.DeclaringType == null) { && memberReference.DeclaringType == null) {
DebuggerService.RemoveCurrentLineMarker(); DebuggerService.RemoveCurrentLineMarker();
DebuggerService.JumpToCurrentLine(type, line, 0, line, 0); DebuggerService.JumpToCurrentLine(memberReference, line, 0, line, 0);
} else { } else {
// is possible that the type is not decompiled yet, so we must do a decompilation on demand // is possible that the type is not decompiled yet, so we must do a decompilation on demand
DecompileOnDemand(frame); DecompileOnDemand(frame);
@ -885,8 +885,8 @@ namespace ICSharpCode.ILSpy.Debugger.Services
} }
// try jump // try jump
int line; int line;
TypeDefinition type; MemberReference memberReference;
if (CodeMappingsStorage.GetSourceCodeFromMetadataTokenAndOffset((nestedTypeDef ?? typeDef).FullName, token, ilOffset, out type, out line)) { if (CodeMappingsStorage.GetSourceCodeFromMetadataTokenAndOffset((nestedTypeDef ?? typeDef).FullName, token, ilOffset, out memberReference, out line)) {
DebuggerService.RemoveCurrentLineMarker(); DebuggerService.RemoveCurrentLineMarker();
DebuggerService.JumpToCurrentLine(typeDef, line, 0, line, 0); DebuggerService.JumpToCurrentLine(typeDef, line, 0, line, 0);
} else { } else {

6
ICSharpCode.Decompiler/CodeMappings.cs

@ -22,7 +22,7 @@ namespace ICSharpCode.Decompiler
/// <summary> /// <summary>
/// Maps the source code to IL. /// Maps the source code to IL.
/// </summary> /// </summary>
public class SourceCodeMapping public sealed class SourceCodeMapping
{ {
/// <summary> /// <summary>
/// Gets or sets the source code line number in the output. /// Gets or sets the source code line number in the output.
@ -83,7 +83,7 @@ namespace ICSharpCode.Decompiler
/// <summary> /// <summary>
/// Gets or sets the type of the mapping. /// Gets or sets the type of the mapping.
/// </summary> /// </summary>
public TypeDefinition Type { get; internal set; } public MemberReference Type { get; internal set; }
/// <summary> /// <summary>
/// Metadata token of the method. /// Metadata token of the method.
@ -283,7 +283,7 @@ namespace ICSharpCode.Decompiler
string typeName, string typeName,
uint token, uint token,
int ilOffset, int ilOffset,
out TypeDefinition type, out MemberReference type,
out int line) out int line)
{ {
type = null; type = null;

4
ILSpy/TextView/DecompilerTextView.cs

@ -415,7 +415,8 @@ namespace ICSharpCode.ILSpy.TextView
DebugData.Language = MainWindow.Instance.sessionSettings.FilterSettings.Language.Name.StartsWith("IL") ? DecompiledLanguages.IL : DecompiledLanguages.CSharp; DebugData.Language = MainWindow.Instance.sessionSettings.FilterSettings.Language.Name.StartsWith("IL") ? DecompiledLanguages.IL : DecompiledLanguages.CSharp;
if (DebugData.CurrentMember != null) { if (DebugData.CurrentMember != null) {
if (context.TreeNodes.Count() == 1) { // TODO: show margin for single methods and properties
if (context.TreeNodes.Count() == 1 && DebugData.IsCurrentMemberType) {
iconMargin.Visibility = Visibility.Visible; iconMargin.Visibility = Visibility.Visible;
// repaint bookmarks // repaint bookmarks
iconMargin.InvalidateVisual(); iconMargin.InvalidateVisual();
@ -436,6 +437,7 @@ namespace ICSharpCode.ILSpy.TextView
} else { } else {
// remove currentline marker // remove currentline marker
CurrentLineBookmark.Remove(); CurrentLineBookmark.Remove();
iconMargin.Visibility = Visibility.Collapsed;
} }
} }
}); });

Loading…
Cancel
Save