set breakpoints while running
This commit is contained in:
@@ -14,10 +14,9 @@ using Breakpoint = SharpIDE.Application.Features.Debugging.Breakpoint;
|
||||
|
||||
namespace SharpIDE.Application.Features.Run;
|
||||
|
||||
public class RunService(ILogger<RunService> logger, RoslynAnalysis roslynAnalysis)
|
||||
public partial class RunService(ILogger<RunService> logger, RoslynAnalysis roslynAnalysis)
|
||||
{
|
||||
private readonly ConcurrentDictionary<SharpIdeProjectModel, SemaphoreSlim> _projectLocks = [];
|
||||
public ConcurrentDictionary<SharpIdeFile, List<Breakpoint>> Breakpoints { get; } = [];
|
||||
private Debugger? _debugger; // TODO: Support multiple debuggers for multiple running projects
|
||||
|
||||
private readonly ILogger<RunService> _logger = logger;
|
||||
|
||||
@@ -0,0 +1,35 @@
|
||||
using System.Collections.Concurrent;
|
||||
using Ardalis.GuardClauses;
|
||||
using SharpIDE.Application.Features.Debugging;
|
||||
using SharpIDE.Application.Features.SolutionDiscovery;
|
||||
|
||||
namespace SharpIDE.Application.Features.Run;
|
||||
|
||||
public partial class RunService
|
||||
{
|
||||
public ConcurrentDictionary<SharpIdeFile, List<Breakpoint>> Breakpoints { get; } = [];
|
||||
public async Task AddBreakpointForFile(SharpIdeFile file, int line)
|
||||
{
|
||||
Guard.Against.Null(file);
|
||||
|
||||
var breakpoints = Breakpoints.GetOrAdd(file, []);
|
||||
var breakpoint = new Breakpoint { Line = line };
|
||||
breakpoints.Add(breakpoint);
|
||||
if (_debugger is not null)
|
||||
{
|
||||
await _debugger.SetBreakpointsForFile(file, breakpoints);
|
||||
}
|
||||
}
|
||||
|
||||
public async Task RemoveBreakpointForFile(SharpIdeFile file, int line)
|
||||
{
|
||||
Guard.Against.Null(file);
|
||||
var breakpoints = Breakpoints.GetOrAdd(file, []);
|
||||
var breakpoint = breakpoints.Single(b => b.Line == line);
|
||||
breakpoints.Remove(breakpoint);
|
||||
if (_debugger is not null)
|
||||
{
|
||||
await _debugger.SetBreakpointsForFile(file, breakpoints);
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user