From ae22e08d8b2be643a264f67dcd0135bd2741971e Mon Sep 17 00:00:00 2001 From: Matt Parker <61717342+MattParkerDev@users.noreply.github.com> Date: Sat, 8 Nov 2025 19:57:44 +1000 Subject: [PATCH] fix displaying breakpoints with netcoredbg --- .../Features/Debugging/DebuggingService.cs | 23 +++++++++++++++---- 1 file changed, 19 insertions(+), 4 deletions(-) diff --git a/src/SharpIDE.Application/Features/Debugging/DebuggingService.cs b/src/SharpIDE.Application/Features/Debugging/DebuggingService.cs index 3827139..b03f289 100644 --- a/src/SharpIDE.Application/Features/Debugging/DebuggingService.cs +++ b/src/SharpIDE.Application/Features/Debugging/DebuggingService.cs @@ -82,10 +82,25 @@ public class DebuggingService await Task.CompletedTask.ConfigureAwait(ConfigureAwaitOptions.ForceYielding); // The VS Code Debug Protocol throws if you try to send a request from the dispatcher thread var additionalProperties = @event.AdditionalProperties; // source, line, column - var filePath = additionalProperties?["source"]?["path"]!.Value()!; - var line = (additionalProperties?["line"]?.Value()!).Value; - var executionStopInfo = new ExecutionStopInfo { FilePath = filePath, Line = line, ThreadId = @event.ThreadId!.Value }; - GlobalEvents.Instance.DebuggerExecutionStopped.InvokeParallelFireAndForget(executionStopInfo); + if (additionalProperties.Count is not 0) + { + var filePath = additionalProperties?["source"]?["path"]!.Value()!; + var line = (additionalProperties?["line"]?.Value()!).Value; + var executionStopInfo = new ExecutionStopInfo { FilePath = filePath, Line = line, ThreadId = @event.ThreadId!.Value }; + GlobalEvents.Instance.DebuggerExecutionStopped.InvokeParallelFireAndForget(executionStopInfo); + } + else + { + // we need to get the top stack frame to find out where we are + var stackTraceRequest = new StackTraceRequest { ThreadId = @event.ThreadId!.Value, StartFrame = 0, Levels = 1 }; + var stackTraceResponse = debugProtocolHost.SendRequestSync(stackTraceRequest); + var topFrame = stackTraceResponse.StackFrames.Single(); + var filePath = topFrame.Source.Path; + var line = topFrame.Line; + var executionStopInfo = new ExecutionStopInfo { FilePath = filePath, Line = line, ThreadId = @event.ThreadId!.Value }; + GlobalEvents.Instance.DebuggerExecutionStopped.InvokeParallelFireAndForget(executionStopInfo); + } + if (@event.Reason is StoppedEvent.ReasonValue.Exception) { Console.WriteLine("Stopped due to exception, continuing");