refactor debugger executable path

This commit is contained in:
Matt Parker
2025-11-08 18:32:28 +10:00
parent 6f6fbcd26f
commit fe158f2cf9
5 changed files with 14 additions and 7 deletions

View File

@@ -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<SharpIdeFile, List<Breakpoint>> breakpointsByFile)
public async Task Attach(string? debuggerExecutablePath, Dictionary<SharpIdeFile, List<Breakpoint>> 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);

View File

@@ -15,17 +15,22 @@ namespace SharpIDE.Application.Features.Debugging;
public class DebuggingService
{
private DebugProtocolHost _debugProtocolHost = null!;
public async Task Attach(int debuggeeProcessId, Dictionary<SharpIdeFile, List<Breakpoint>> breakpointsByFile, CancellationToken cancellationToken = default)
public async Task Attach(int debuggeeProcessId, string? debuggerExecutablePath, Dictionary<SharpIdeFile, List<Breakpoint>> 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,

View File

@@ -19,7 +19,7 @@ public class RunService(ILogger<RunService> logger)
private readonly ILogger<RunService> _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<RunService> 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;

View File

@@ -10,6 +10,7 @@ public class AppState
public class IdeSettings
{
public bool AutoOpenLastSolution { get; set; }
public string? DebuggerExecutablePath { get; set; }
}
public record RecentSln

View File

@@ -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);
}
}