diff --git a/Debugger/Debugger.Core/Breakpoint.cs b/Debugger/Debugger.Core/Breakpoint.cs index 0b5555538..68a9ea24f 100644 --- a/Debugger/Debugger.Core/Breakpoint.cs +++ b/Debugger/Debugger.Core/Breakpoint.cs @@ -45,11 +45,6 @@ namespace Debugger set { line = value; } } - public string TypeName { - get; - set; - } - public int Column { get { return column; } protected set { column = value; } @@ -75,6 +70,10 @@ namespace Debugger } } + public string TypeName { + get; protected set; + } + protected virtual void OnHit(BreakpointEventArgs e) { if (Hit != null) { @@ -176,12 +175,11 @@ namespace Debugger public class ILBreakpoint : Breakpoint { - public ILBreakpoint(NDebugger debugger, string typeName, string memberReferenceName, int line, int metadataToken, int offset, bool enabled) + public ILBreakpoint(NDebugger debugger, string typeName, int line, int metadataToken, int offset, bool enabled) { this.Debugger = debugger; this.Line = line; this.TypeName = typeName; - this.MemberReferenceName = memberReferenceName; this.MetadataToken = metadataToken; this.ILOffset = offset; this.Enabled = enabled; @@ -191,8 +189,6 @@ namespace Debugger public int ILOffset { get; private set; } - public string MemberReferenceName { get; private set; } - public override bool SetBreakpoint(Module module) { SourcecodeSegment segment = SourcecodeSegment.CreateForIL(module, this.Line, (int)MetadataToken, ILOffset); diff --git a/Debugger/ILSpy.Debugger/Commands/DebuggerCommands.cs b/Debugger/ILSpy.Debugger/Commands/DebuggerCommands.cs index 3a122360b..c3bbff34d 100644 --- a/Debugger/ILSpy.Debugger/Commands/DebuggerCommands.cs +++ b/Debugger/ILSpy.Debugger/Commands/DebuggerCommands.cs @@ -83,7 +83,7 @@ namespace ICSharpCode.ILSpy.Debugger.Commands public override void Execute(object parameter) { - DebugInformation.LoadedAssemblies = MainWindow.Instance.CurrentAssemblyList.GetAssemblies().Select(a => a.AssemblyDefinition); + } protected static IDebugger CurrentDebugger { diff --git a/Debugger/ILSpy.Debugger/Services/Debugger/WindowsDebugger.cs b/Debugger/ILSpy.Debugger/Services/Debugger/WindowsDebugger.cs index b5614aab5..8aa104bdd 100644 --- a/Debugger/ILSpy.Debugger/Services/Debugger/WindowsDebugger.cs +++ b/Debugger/ILSpy.Debugger/Services/Debugger/WindowsDebugger.cs @@ -549,7 +549,6 @@ namespace ICSharpCode.ILSpy.Debugger.Services breakpoint = new ILBreakpoint( debugger, bookmark.MemberReference.DeclaringType.FullName, - bookmark.MemberReference.FullName, bookmark.LineNumber, bookmark.MemberReference.MetadataToken.ToInt32(), bookmark.ILRange.From, @@ -817,6 +816,8 @@ namespace ICSharpCode.ILSpy.Debugger.Services int ilOffset = frame.IP; string fullName = debugType.FullNameWithoutGenericArguments; + DebugInformation.LoadedAssemblies = MainWindow.Instance.CurrentAssemblyList.GetAssemblies().Select(a => a.AssemblyDefinition); + if (DebugInformation.LoadedAssemblies == null) throw new NullReferenceException("No DebugData assemblies!"); else { diff --git a/ICSharpCode.Decompiler/Ast/TextOutputFormatter.cs b/ICSharpCode.Decompiler/Ast/TextOutputFormatter.cs index 98a5db66e..ec83e695c 100644 --- a/ICSharpCode.Decompiler/Ast/TextOutputFormatter.cs +++ b/ICSharpCode.Decompiler/Ast/TextOutputFormatter.cs @@ -163,7 +163,7 @@ namespace ICSharpCode.Decompiler.Ast foreach (var range in ranges) { mapping.MemberCodeMappings.Add(new SourceCodeMapping { ILInstructionOffset = range, - SourceCodeLine = output.CurrentLine, + SourceCodeLine = output.Location.Line, MemberMapping = mapping }); } @@ -176,10 +176,10 @@ namespace ICSharpCode.Decompiler.Ast if (predicate(node)) { var n = node as AttributedNode; - int c = 0; + int attributesCount = 0; if (n != null) - c = n.Attributes.Count; - node.AddAnnotation(Tuple.Create(output.CurrentLine + c, output.CurrentColumn)); + attributesCount = n.Attributes.Count; + node.AddAnnotation(new TextOutputLocation { Line = output.Location.Line + attributesCount, Column = output.Location.Column}); } nodeStack.Push(node); diff --git a/ICSharpCode.Decompiler/Disassembler/MethodBodyDisassembler.cs b/ICSharpCode.Decompiler/Disassembler/MethodBodyDisassembler.cs index 2fcde2335..0872cba16 100644 --- a/ICSharpCode.Decompiler/Disassembler/MethodBodyDisassembler.cs +++ b/ICSharpCode.Decompiler/Disassembler/MethodBodyDisassembler.cs @@ -91,7 +91,7 @@ namespace ICSharpCode.Decompiler.Disassembler // add IL code mappings - used in debugger methodMapping.MemberCodeMappings.Add( new SourceCodeMapping() { - SourceCodeLine = output.CurrentLine, + SourceCodeLine = output.Location.Line, ILInstructionOffset = new ILRange { From = inst.Offset, To = inst.Next == null ? method.Body.CodeSize : inst.Next.Offset }, MemberMapping = methodMapping }); @@ -194,7 +194,7 @@ namespace ICSharpCode.Decompiler.Disassembler if (currentMethodMapping != null) { currentMethodMapping.MemberCodeMappings.Add( new SourceCodeMapping() { - SourceCodeLine = output.CurrentLine, + SourceCodeLine = output.Location.Line, ILInstructionOffset = new ILRange { From = inst.Offset, To = inst.Next == null ? codeSize : inst.Next.Offset }, MemberMapping = currentMethodMapping }); diff --git a/ICSharpCode.Decompiler/ITextOutput.cs b/ICSharpCode.Decompiler/ITextOutput.cs index 608a45c64..cfbd5751a 100644 --- a/ICSharpCode.Decompiler/ITextOutput.cs +++ b/ICSharpCode.Decompiler/ITextOutput.cs @@ -23,8 +23,7 @@ namespace ICSharpCode.Decompiler { public interface ITextOutput { - int CurrentLine { get; } - int CurrentColumn { get; } + TextOutputLocation Location { get; } void Indent(); void Unindent(); @@ -38,6 +37,12 @@ namespace ICSharpCode.Decompiler void MarkFoldEnd(); } + public sealed class TextOutputLocation + { + public int Line { get; set; } + public int Column { get; set; } + } + public static class TextOutputExtensions { public static void Write(this ITextOutput output, string format, params object[] args) diff --git a/ICSharpCode.Decompiler/PlainTextOutput.cs b/ICSharpCode.Decompiler/PlainTextOutput.cs index 86a28a5c8..d8b001167 100644 --- a/ICSharpCode.Decompiler/PlainTextOutput.cs +++ b/ICSharpCode.Decompiler/PlainTextOutput.cs @@ -28,8 +28,7 @@ namespace ICSharpCode.Decompiler readonly TextWriter writer; int indent; bool needsIndent; - int lineNumber = 1; - int columnNumber = 1; + TextOutputLocation location = new TextOutputLocation { Line = 1, Column = 1}; public PlainTextOutput(TextWriter writer) { @@ -43,12 +42,8 @@ namespace ICSharpCode.Decompiler this.writer = new StringWriter(); } - public int CurrentLine { - get { return lineNumber; } - } - - public int CurrentColumn { - get { return columnNumber; } + public TextOutputLocation Location { + get { return location; } } public override string ToString() @@ -72,7 +67,7 @@ namespace ICSharpCode.Decompiler needsIndent = false; for (int i = 0; i < indent; i++) { writer.Write('\t'); - columnNumber += TAB_SIZE - 1; + location.Column += TAB_SIZE - 1; } } } @@ -81,22 +76,22 @@ namespace ICSharpCode.Decompiler { WriteIndent(); writer.Write(ch); - columnNumber++; + location.Column++; } public void Write(string text) { WriteIndent(); writer.Write(text); - columnNumber += text.Length; + location.Column += text.Length; } public void WriteLine() { - lineNumber++; + location.Line++; writer.WriteLine(); needsIndent = true; - columnNumber = TAB_SIZE * indent; + location.Column = TAB_SIZE * indent; } public void WriteDefinition(string text, object definition) diff --git a/ILSpy/Bookmarks/MemberBookmark.cs b/ILSpy/Bookmarks/MemberBookmark.cs index 46a52d3d2..7edd645e9 100644 --- a/ILSpy/Bookmarks/MemberBookmark.cs +++ b/ILSpy/Bookmarks/MemberBookmark.cs @@ -21,6 +21,7 @@ using System.Windows; using System.Windows.Input; using System.Windows.Media; +using ICSharpCode.Decompiler; using ICSharpCode.NRefactory.CSharp; using ICSharpCode.NRefactory.TypeSystem; using Mono.Cecil; @@ -91,9 +92,9 @@ namespace ICSharpCode.ILSpy.Bookmarks public int LineNumber { get { - var t = node.Annotation>(); + var t = node.Annotation(); if (t != null) - return t.Item1; + return t.Line; return 0; } } diff --git a/ILSpy/Languages/Language.cs b/ILSpy/Languages/Language.cs index 3275e54cd..708b0fd3c 100644 --- a/ILSpy/Languages/Language.cs +++ b/ILSpy/Languages/Language.cs @@ -207,7 +207,7 @@ namespace ICSharpCode.ILSpy var nodes = TreeTraversal .PreOrder((AstNode)builder.CompilationUnit, n => n.Children) - .Where(n => n is AttributedNode && n.Annotation>() != null); + .Where(n => n is AttributedNode && n.Annotation() != null); OnDecompilationFinished(new DecompileEventArgs { CodeMappings = builder.CodeMappings, diff --git a/ILSpy/SearchPane.cs b/ILSpy/SearchPane.cs index b4d6812c8..02d8024be 100644 --- a/ILSpy/SearchPane.cs +++ b/ILSpy/SearchPane.cs @@ -398,7 +398,7 @@ namespace ICSharpCode.ILSpy case TypeCode.Int64: TypeCode tc = Type.GetTypeCode(val.GetType()); if (tc >= TypeCode.SByte && tc <= TypeCode.UInt64) - return Convert.ToInt64(val) == (long)searchTermLiteralValue; + return CSharpPrimitiveCast.Cast(TypeCode.Int64, val, false).Equals(searchTermLiteralValue); else return false; case TypeCode.Single: diff --git a/ILSpy/TextView/AvalonEditTextOutput.cs b/ILSpy/TextView/AvalonEditTextOutput.cs index 7b247ddb9..996e182bc 100644 --- a/ILSpy/TextView/AvalonEditTextOutput.cs +++ b/ILSpy/TextView/AvalonEditTextOutput.cs @@ -65,7 +65,7 @@ namespace ICSharpCode.ILSpy.TextView /// public sealed class AvalonEditTextOutput : ISmartTextOutput { - int lineNumber = 1; + TextOutputLocation location = new TextOutputLocation { Line = 1, Column = 1 }; int lastLineStart = 0; readonly StringBuilder b = new StringBuilder(); @@ -117,6 +117,13 @@ namespace ICSharpCode.ILSpy.TextView get { return b.Length; } } + public TextOutputLocation Location { + get { + location.Column = b.Length - lastLineStart + 1; + return location; + } + } + #region Text Document TextDocument textDocument; @@ -188,7 +195,7 @@ namespace ICSharpCode.ILSpy.TextView b.AppendLine(); needsIndent = true; lastLineStart = b.Length; - lineNumber++; + location.Line++; if (this.TextLength > LengthLimit) { throw new OutputLengthExceededException(); } @@ -236,17 +243,5 @@ namespace ICSharpCode.ILSpy.TextView this.UIElements.Add(new KeyValuePair>(this.TextLength, new Lazy(element))); } } - - public int CurrentLine { - get { - return lineNumber; - } - } - - public int CurrentColumn { - get { - return b.Length - lastLineStart + 1; - } - } } } diff --git a/ILSpy/TextView/DecompilerTextView.cs b/ILSpy/TextView/DecompilerTextView.cs index db9e6dddc..0c16ac2ea 100644 --- a/ILSpy/TextView/DecompilerTextView.cs +++ b/ILSpy/TextView/DecompilerTextView.cs @@ -456,7 +456,7 @@ namespace ICSharpCode.ILSpy.TextView int ilOffset = DebugInformation.DebugStepInformation.Item2; int line; MemberReference member; - if (!DebugInformation.CodeMappings.ContainsKey(token)) + if (DebugInformation.CodeMappings == null || !DebugInformation.CodeMappings.ContainsKey(token)) return; DebugInformation.CodeMappings[token].GetInstructionByTokenAndOffset(token, ilOffset, out member, out line); diff --git a/ILSpy/TreeNodes/TypeTreeNode.cs b/ILSpy/TreeNodes/TypeTreeNode.cs index 653def410..15bb054d8 100644 --- a/ILSpy/TreeNodes/TypeTreeNode.cs +++ b/ILSpy/TreeNodes/TypeTreeNode.cs @@ -81,10 +81,10 @@ namespace ICSharpCode.ILSpy.TreeNodes if (!settings.ShowInternalApi && !IsPublicAPI) return FilterResult.Hidden; if (settings.SearchTermMatches(type.Name)) { - if (type.IsNested && !settings.Language.ShowMember(type)) - return FilterResult.Hidden; - else + if (settings.Language.ShowMember(type)) return FilterResult.Match; + else + return FilterResult.Hidden; } else { return FilterResult.Recurse; }