wire up debug panel

This commit is contained in:
Matt Parker
2025-08-29 19:01:06 +10:00
parent 850be02a52
commit 5f9439c9aa
9 changed files with 116 additions and 28 deletions

View File

@@ -12,6 +12,12 @@ public static class GlobalEvents
public static event Func<Task> StartedRunningProject = () => Task.CompletedTask;
public static void InvokeStartedRunningProject() => StartedRunningProject?.InvokeParallelFireAndForget();
public static event Func<SharpIdeProjectModel, Task> ProjectStartedDebugging = _ => Task.CompletedTask;
public static void InvokeProjectStartedDebugging(SharpIdeProjectModel project) => ProjectStartedDebugging?.InvokeParallelFireAndForget(project);
public static event Func<SharpIdeProjectModel, Task> ProjectStoppedDebugging = _ => Task.CompletedTask;
public static void InvokeProjectStoppedDebugging(SharpIdeProjectModel project) => ProjectStoppedDebugging?.InvokeParallelFireAndForget(project);
public static event Func<SharpIdeProjectModel, Task> ProjectStartedRunning = _ => Task.CompletedTask;
public static void InvokeProjectStartedRunning(SharpIdeProjectModel project) => ProjectStartedRunning?.InvokeParallelFireAndForget(project);

View File

@@ -15,9 +15,8 @@ public class RunService
private readonly ConcurrentDictionary<SharpIdeProjectModel, SemaphoreSlim> _projectLocks = [];
public ConcurrentDictionary<SharpIdeFile, List<Breakpoint>> Breakpoints { get; } = [];
private Debugger? _debugger; // TODO: Support multiple debuggers for multiple running projects
public async Task RunProject(SharpIdeProjectModel project)
public async Task RunProject(SharpIdeProjectModel project, bool isDebug = false)
{
var isDebug = true;
Guard.Against.Null(project, nameof(project));
Guard.Against.NullOrWhiteSpace(project.FilePath, nameof(project.FilePath), "Project file path cannot be null or empty.");
await Task.CompletedTask.ConfigureAwait(ConfigureAwaitOptions.ForceYielding);
@@ -92,9 +91,16 @@ public class RunService
project.Running = true;
project.OpenInRunPanel = true;
GlobalEvents.InvokeProjectsRunningChanged();
GlobalEvents.InvokeStartedRunningProject();
GlobalEvents.InvokeProjectStartedRunning(project);
if (isDebug)
{
GlobalEvents.InvokeProjectStartedDebugging(project);
}
else
{
GlobalEvents.InvokeProjectsRunningChanged();
GlobalEvents.InvokeStartedRunningProject();
GlobalEvents.InvokeProjectStartedRunning(project);
}
project.InvokeProjectStartedRunning();
await process.WaitForExitAsync().WaitAsync(project.RunningCancellationTokenSource.Token).ConfigureAwait(ConfigureAwaitOptions.SuppressThrowing);
if (project.RunningCancellationTokenSource.IsCancellationRequested)
@@ -107,8 +113,16 @@ public class RunService
project.RunningCancellationTokenSource.Dispose();
project.RunningCancellationTokenSource = null;
project.Running = false;
GlobalEvents.InvokeProjectsRunningChanged();
GlobalEvents.InvokeProjectStoppedRunning(project);
if (isDebug)
{
GlobalEvents.InvokeProjectStoppedDebugging(project);
}
else
{
GlobalEvents.InvokeProjectsRunningChanged();
GlobalEvents.InvokeProjectStoppedRunning(project);
}
project.InvokeProjectStoppedRunning();
Console.WriteLine("Project finished running");
@@ -133,6 +147,11 @@ public class RunService
await _debugger!.StepOver(threadId);
}
public async Task GetInfoAtStopPoint()
{
await _debugger!.GetInfoAtStopPoint();
}
private string GetRunArguments(SharpIdeProjectModel project)
{
var dllFullPath = ProjectEvaluation.GetOutputDllFullPath(project);