Skip to content

Commit 5e2681d

Browse files
committed
Use <DebugAction>HandlerBase ABCs instead of interfaces
1 parent 7ec969c commit 5e2681d

File tree

2 files changed

+41
-18
lines changed

2 files changed

+41
-18
lines changed

src/PowerShellEditorServices/Server/PsesDebugServer.cs

+5-1
Original file line numberDiff line numberDiff line change
@@ -81,7 +81,11 @@ public async Task StartAsync()
8181
.WithHandler<StackTraceHandler>()
8282
.WithHandler<ScopesHandler>()
8383
.WithHandler<VariablesHandler>()
84-
.WithHandler<DebuggerActionHandlers>()
84+
.WithHandler<ContinueHandler>()
85+
.WithHandler<NextHandler>()
86+
.WithHandler<PauseHandler>()
87+
.WithHandler<StepInHandler>()
88+
.WithHandler<StepOutHandler>()
8589
.WithHandler<SourceHandler>()
8690
.WithHandler<SetVariableHandler>()
8791
.WithHandler<DebugEvaluateHandler>()

src/PowerShellEditorServices/Services/DebugAdapter/Handlers/DebuggerActionHandlers.cs

+36-17
Original file line numberDiff line numberDiff line change
@@ -4,59 +4,78 @@
44
using System;
55
using System.Threading;
66
using System.Threading.Tasks;
7-
using Microsoft.Extensions.Logging;
87
using Microsoft.PowerShell.EditorServices.Services;
98
using OmniSharp.Extensions.DebugAdapter.Protocol.Requests;
109
using OmniSharp.Extensions.JsonRpc;
1110

1211
namespace Microsoft.PowerShell.EditorServices.Handlers
1312
{
14-
// TODO: Inherit from ABCs instead of satisfying interfaces.
15-
internal class DebuggerActionHandlers : IContinueHandler, INextHandler, IPauseHandler, IStepInHandler, IStepOutHandler
13+
internal class ContinueHandler : ContinueHandlerBase
1614
{
17-
private readonly ILogger _logger;
1815
private readonly DebugService _debugService;
1916

20-
public DebuggerActionHandlers(
21-
ILoggerFactory loggerFactory,
22-
DebugService debugService)
23-
{
24-
_logger = loggerFactory.CreateLogger<ContinueHandlerBase>();
25-
_debugService = debugService;
26-
}
17+
public ContinueHandler(DebugService debugService) => _debugService = debugService;
2718

28-
public Task<ContinueResponse> Handle(ContinueArguments request, CancellationToken cancellationToken)
19+
public override Task<ContinueResponse> Handle(ContinueArguments request, CancellationToken cancellationToken)
2920
{
3021
_debugService.Continue();
3122
return Task.FromResult(new ContinueResponse());
3223
}
24+
}
25+
26+
internal class NextHandler : NextHandlerBase
27+
{
28+
private readonly DebugService _debugService;
3329

34-
public Task<NextResponse> Handle(NextArguments request, CancellationToken cancellationToken)
30+
public NextHandler(DebugService debugService) => _debugService = debugService;
31+
32+
public override Task<NextResponse> Handle(NextArguments request, CancellationToken cancellationToken)
3533
{
3634
_debugService.StepOver();
3735
return Task.FromResult(new NextResponse());
3836
}
37+
}
38+
39+
internal class PauseHandler : PauseHandlerBase
40+
{
41+
private readonly DebugService _debugService;
3942

40-
public Task<PauseResponse> Handle(PauseArguments request, CancellationToken cancellationToken)
43+
public PauseHandler(DebugService debugService) => _debugService = debugService;
44+
45+
public override Task<PauseResponse> Handle(PauseArguments request, CancellationToken cancellationToken)
4146
{
4247
try
4348
{
4449
_debugService.Break();
4550
return Task.FromResult(new PauseResponse());
4651
}
47-
catch(NotSupportedException e)
52+
catch (NotSupportedException e)
4853
{
4954
throw new RpcErrorException(0, e.Message);
5055
}
5156
}
57+
}
58+
59+
internal class StepInHandler : StepInHandlerBase
60+
{
61+
private readonly DebugService _debugService;
62+
63+
public StepInHandler(DebugService debugService) => _debugService = debugService;
5264

53-
public Task<StepInResponse> Handle(StepInArguments request, CancellationToken cancellationToken)
65+
public override Task<StepInResponse> Handle(StepInArguments request, CancellationToken cancellationToken)
5466
{
5567
_debugService.StepIn();
5668
return Task.FromResult(new StepInResponse());
5769
}
70+
}
71+
72+
internal class StepOutHandler : StepOutHandlerBase
73+
{
74+
private readonly DebugService _debugService;
75+
76+
public StepOutHandler(DebugService debugService) => _debugService = debugService;
5877

59-
public Task<StepOutResponse> Handle(StepOutArguments request, CancellationToken cancellationToken)
78+
public override Task<StepOutResponse> Handle(StepOutArguments request, CancellationToken cancellationToken)
6079
{
6180
_debugService.StepOut();
6281
return Task.FromResult(new StepOutResponse());

0 commit comments

Comments
 (0)