diff --git a/src/SharpIDE.Application/Features/Debugging/Debugger.cs b/src/SharpIDE.Application/Features/Debugging/Debugger.cs index 66cc0bd..368a327 100644 --- a/src/SharpIDE.Application/Features/Debugging/Debugger.cs +++ b/src/SharpIDE.Application/Features/Debugging/Debugger.cs @@ -3,14 +3,15 @@ using SharpIDE.Application.Features.SolutionDiscovery.VsPersistence; namespace SharpIDE.Application.Features.Debugging; +// TODO: Why does this exist separate from DebuggingService? public class Debugger { public required SharpIdeProjectModel Project { get; init; } public required int ProcessId { get; init; } private DebuggingService _debuggingService = new DebuggingService(); - public async Task Attach(CancellationToken cancellationToken, Dictionary> breakpointsByFile) + public async Task Attach(string? debuggerExecutablePath, Dictionary> breakpointsByFile, CancellationToken cancellationToken) { - await _debuggingService.Attach(ProcessId, breakpointsByFile, cancellationToken); + await _debuggingService.Attach(ProcessId, debuggerExecutablePath, breakpointsByFile, cancellationToken); } public async Task StepOver(int threadId, CancellationToken cancellationToken = default) => await _debuggingService.StepOver(threadId, cancellationToken); diff --git a/src/SharpIDE.Application/Features/Debugging/DebuggingService.cs b/src/SharpIDE.Application/Features/Debugging/DebuggingService.cs index ec6435e..9468db9 100644 --- a/src/SharpIDE.Application/Features/Debugging/DebuggingService.cs +++ b/src/SharpIDE.Application/Features/Debugging/DebuggingService.cs @@ -15,17 +15,22 @@ namespace SharpIDE.Application.Features.Debugging; public class DebuggingService { private DebugProtocolHost _debugProtocolHost = null!; - public async Task Attach(int debuggeeProcessId, Dictionary> breakpointsByFile, CancellationToken cancellationToken = default) + public async Task Attach(int debuggeeProcessId, string? debuggerExecutablePath, Dictionary> breakpointsByFile, CancellationToken cancellationToken = default) { Guard.Against.NegativeOrZero(debuggeeProcessId, nameof(debuggeeProcessId), "Process ID must be a positive integer."); await Task.CompletedTask.ConfigureAwait(ConfigureAwaitOptions.ForceYielding); + if (string.IsNullOrWhiteSpace(debuggerExecutablePath)) + { + throw new ArgumentNullException(nameof(debuggerExecutablePath), "Debugger executable path cannot be null or empty."); + } + var process = new Process { StartInfo = new ProcessStartInfo { //FileName = @"C:\Users\Matthew\Downloads\netcoredbg-win64\netcoredbg\netcoredbg.exe", - FileName = @"C:\Users\Matthew\.vscode-insiders\extensions\ms-dotnettools.csharp-2.90.51-win32-x64\.debugger\x86_64\vsdbg.exe", + FileName = debuggerExecutablePath, Arguments = "--interpreter=vscode", RedirectStandardInput = true, RedirectStandardOutput = true, diff --git a/src/SharpIDE.Application/Features/Run/RunService.cs b/src/SharpIDE.Application/Features/Run/RunService.cs index dc99619..2f66cc9 100644 --- a/src/SharpIDE.Application/Features/Run/RunService.cs +++ b/src/SharpIDE.Application/Features/Run/RunService.cs @@ -19,7 +19,7 @@ public class RunService(ILogger logger) private readonly ILogger _logger = logger; - public async Task RunProject(SharpIdeProjectModel project, bool isDebug = false) + public async Task RunProject(SharpIdeProjectModel project, bool isDebug = false, string? debuggerExecutablePath = null) { Guard.Against.Null(project, nameof(project)); Guard.Against.NullOrWhiteSpace(project.FilePath, nameof(project.FilePath), "Project file path cannot be null or empty."); @@ -90,7 +90,7 @@ public class RunService(ILogger logger) // Attach debugger (which internally uses a DiagnosticClient to resume startup) var debugger = new Debugger { Project = project, ProcessId = process.ProcessId }; _debugger = debugger; - await debugger.Attach(project.RunningCancellationTokenSource.Token, Breakpoints.ToDictionary()).ConfigureAwait(false); + await debugger.Attach(debuggerExecutablePath, Breakpoints.ToDictionary(), project.RunningCancellationTokenSource.Token).ConfigureAwait(false); } project.Running = true; diff --git a/src/SharpIDE.Godot/Features/IdeSettings/AppState.cs b/src/SharpIDE.Godot/Features/IdeSettings/AppState.cs index 00ae52d..13f70b8 100644 --- a/src/SharpIDE.Godot/Features/IdeSettings/AppState.cs +++ b/src/SharpIDE.Godot/Features/IdeSettings/AppState.cs @@ -10,6 +10,7 @@ public class AppState public class IdeSettings { public bool AutoOpenLastSolution { get; set; } + public string? DebuggerExecutablePath { get; set; } } public record RecentSln diff --git a/src/SharpIDE.Godot/Features/Run/RunMenuItem.cs b/src/SharpIDE.Godot/Features/Run/RunMenuItem.cs index 5e800df..507bc61 100644 --- a/src/SharpIDE.Godot/Features/Run/RunMenuItem.cs +++ b/src/SharpIDE.Godot/Features/Run/RunMenuItem.cs @@ -62,6 +62,6 @@ public partial class RunMenuItem : HBoxContainer private async void OnDebugButtonPressed() { GodotGlobalEvents.Instance.BottomPanelTabExternallySelected.InvokeParallelFireAndForget(BottomPanelType.Debug); - await _runService.RunProject(Project, true).ConfigureAwait(false); + await _runService.RunProject(Project, true, Singletons.AppState.IdeSettings.DebuggerExecutablePath).ConfigureAwait(false); } } \ No newline at end of file