Allow UIX breakpoints to be disabled

This commit is contained in:
Yoshi Askharoun
2023-05-24 16:04:47 -05:00
parent 6c4c4ed591
commit 630e918a3d
2 changed files with 11 additions and 4 deletions
+4 -1
View File
@@ -4,11 +4,12 @@ namespace Microsoft.Iris.Debug;
public struct Breakpoint : IEquatable<Breakpoint> public struct Breakpoint : IEquatable<Breakpoint>
{ {
public Breakpoint(string uri, int line, int column) public Breakpoint(string uri, int line, int column, bool enabled = true)
{ {
Uri = uri; Uri = uri;
Line = line; Line = line;
Column = column; Column = column;
Enabled = enabled;
} }
public string Uri { get; set; } public string Uri { get; set; }
@@ -17,6 +18,8 @@ public struct Breakpoint : IEquatable<Breakpoint>
public int Column { get; set; } public int Column { get; set; }
public bool Enabled { get; set; }
public bool Equals(string uri, int line, int column) => uri == Uri && line == Line && column == Column; public bool Equals(string uri, int line, int column) => uri == Uri && line == Line && column == Column;
public bool Equals(Breakpoint other) => Equals(other.Uri, other.Line, other.Column); public bool Equals(Breakpoint other) => Equals(other.Uri, other.Line, other.Column);
+7 -3
View File
@@ -76,10 +76,14 @@ namespace Microsoft.Iris.Markup
// Fetch line and column numbers from the table // Fetch line and column numbers from the table
if (debugging && context.LoadResult.LineNumberTable.TryLookup(reader.CurrentOffset, out int line, out int column)) if (debugging && context.LoadResult.LineNumberTable.TryLookup(reader.CurrentOffset, out int line, out int column))
{ {
bool ShouldBreak(Breakpoint b)
=> b.Enabled
&& b.Line == line && b.Column == column
&& b.Uri.Equals(loadResult.Uri, StringComparison.OrdinalIgnoreCase);
// Check if a breakpoint has been set at this location // Check if a breakpoint has been set at this location
bool shouldBreak = Application.DebugSettings.Breakpoints bool shouldBreakHere = Application.DebugSettings.Breakpoints.Any(ShouldBreak);
.Any(b => b.Line == line && b.Column == column && b.Uri.Equals(loadResult.Uri, StringComparison.OrdinalIgnoreCase)); if (shouldBreakHere)
if (shouldBreak)
System.Diagnostics.Debugger.Break(); System.Diagnostics.Debugger.Break();
} }