diff --git a/UIX/Microsoft/Iris/Debug/Breakpoint.cs b/UIX/Microsoft/Iris/Debug/Breakpoint.cs index a61dc37..6323347 100644 --- a/UIX/Microsoft/Iris/Debug/Breakpoint.cs +++ b/UIX/Microsoft/Iris/Debug/Breakpoint.cs @@ -4,11 +4,12 @@ namespace Microsoft.Iris.Debug; public struct Breakpoint : IEquatable { - public Breakpoint(string uri, int line, int column) + public Breakpoint(string uri, int line, int column, bool enabled = true) { Uri = uri; Line = line; Column = column; + Enabled = enabled; } public string Uri { get; set; } @@ -17,6 +18,8 @@ public struct Breakpoint : IEquatable 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(Breakpoint other) => Equals(other.Uri, other.Line, other.Column); diff --git a/UIX/Microsoft/Iris/Markup/Interpreter.cs b/UIX/Microsoft/Iris/Markup/Interpreter.cs index e110a50..638f09b 100644 --- a/UIX/Microsoft/Iris/Markup/Interpreter.cs +++ b/UIX/Microsoft/Iris/Markup/Interpreter.cs @@ -76,10 +76,14 @@ namespace Microsoft.Iris.Markup // Fetch line and column numbers from the table 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 - bool shouldBreak = Application.DebugSettings.Breakpoints - .Any(b => b.Line == line && b.Column == column && b.Uri.Equals(loadResult.Uri, StringComparison.OrdinalIgnoreCase)); - if (shouldBreak) + bool shouldBreakHere = Application.DebugSettings.Breakpoints.Any(ShouldBreak); + if (shouldBreakHere) System.Diagnostics.Debugger.Break(); }