@@ -19,8 +19,8 @@ namespace Microsoft.PowerShell.EditorServices.Services
19
19
internal class BreakpointService
20
20
{
21
21
private readonly ILogger < BreakpointService > _logger ;
22
- private readonly PowerShellExecutionService _executionService ;
23
- private readonly EditorServicesConsolePSHost _editorServicesHost ;
22
+ private readonly IInternalPowerShellExecutionService _executionService ;
23
+ private readonly PsesInternalHost _editorServicesHost ;
24
24
private readonly DebugStateService _debugStateService ;
25
25
26
26
// TODO: This needs to be managed per nested session
@@ -32,8 +32,8 @@ internal class BreakpointService
32
32
33
33
public BreakpointService (
34
34
ILoggerFactory factory ,
35
- PowerShellExecutionService executionService ,
36
- EditorServicesConsolePSHost editorServicesHost ,
35
+ IInternalPowerShellExecutionService executionService ,
36
+ PsesInternalHost editorServicesHost ,
37
37
DebugStateService debugStateService )
38
38
{
39
39
_logger = factory . CreateLogger < BreakpointService > ( ) ;
@@ -44,23 +44,23 @@ public BreakpointService(
44
44
45
45
public async Task < List < Breakpoint > > GetBreakpointsAsync ( )
46
46
{
47
- if ( BreakpointApiUtils . SupportsBreakpointApis )
47
+ if ( BreakpointApiUtils . SupportsBreakpointApis ( _editorServicesHost . CurrentRunspace ) )
48
48
{
49
49
return BreakpointApiUtils . GetBreakpoints (
50
50
_editorServicesHost . Runspace . Debugger ,
51
51
_debugStateService . RunspaceId ) ;
52
52
}
53
53
54
54
// Legacy behavior
55
- PSCommand psCommand = new PSCommand ( ) ;
56
- psCommand . AddCommand ( @"Microsoft.PowerShell.Utility\Get-PSBreakpoint" ) ;
57
- IEnumerable < Breakpoint > breakpoints = await _executionService . ExecutePSCommandAsync < Breakpoint > ( psCommand , new PowerShellExecutionOptions ( ) , CancellationToken . None ) ;
55
+ PSCommand psCommand = new PSCommand ( )
56
+ . AddCommand ( @"Microsoft.PowerShell.Utility\Get-PSBreakpoint" ) ;
57
+ IEnumerable < Breakpoint > breakpoints = await _executionService . ExecutePSCommandAsync < Breakpoint > ( psCommand , CancellationToken . None ) . ConfigureAwait ( false ) ;
58
58
return breakpoints . ToList ( ) ;
59
59
}
60
60
61
61
public async Task < IEnumerable < BreakpointDetails > > SetBreakpointsAsync ( string escapedScriptPath , IEnumerable < BreakpointDetails > breakpoints )
62
62
{
63
- if ( BreakpointApiUtils . SupportsBreakpointApis )
63
+ if ( BreakpointApiUtils . SupportsBreakpointApis ( _editorServicesHost . CurrentRunspace ) )
64
64
{
65
65
foreach ( BreakpointDetails breakpointDetails in breakpoints )
66
66
{
@@ -140,7 +140,7 @@ public async Task<IEnumerable<BreakpointDetails>> SetBreakpointsAsync(string esc
140
140
if ( psCommand != null )
141
141
{
142
142
IEnumerable < Breakpoint > setBreakpoints =
143
- await _executionService . ExecutePSCommandAsync < Breakpoint > ( psCommand , new PowerShellExecutionOptions ( ) , CancellationToken . None ) ;
143
+ await _executionService . ExecutePSCommandAsync < Breakpoint > ( psCommand , CancellationToken . None ) . ConfigureAwait ( false ) ;
144
144
configuredBreakpoints . AddRange (
145
145
setBreakpoints . Select ( BreakpointDetails . Create ) ) ;
146
146
}
@@ -150,7 +150,7 @@ public async Task<IEnumerable<BreakpointDetails>> SetBreakpointsAsync(string esc
150
150
151
151
public async Task < IEnumerable < CommandBreakpointDetails > > SetCommandBreakpoints ( IEnumerable < CommandBreakpointDetails > breakpoints )
152
152
{
153
- if ( BreakpointApiUtils . SupportsBreakpointApis )
153
+ if ( BreakpointApiUtils . SupportsBreakpointApis ( _editorServicesHost . CurrentRunspace ) )
154
154
{
155
155
foreach ( CommandBreakpointDetails commandBreakpointDetails in breakpoints )
156
156
{
@@ -217,7 +217,7 @@ public async Task<IEnumerable<CommandBreakpointDetails>> SetCommandBreakpoints(I
217
217
if ( psCommand != null )
218
218
{
219
219
IEnumerable < Breakpoint > setBreakpoints =
220
- await _executionService . ExecutePSCommandAsync < Breakpoint > ( psCommand , new PowerShellExecutionOptions ( ) , CancellationToken . None ) ;
220
+ await _executionService . ExecutePSCommandAsync < Breakpoint > ( psCommand , CancellationToken . None ) . ConfigureAwait ( false ) ;
221
221
configuredBreakpoints . AddRange (
222
222
setBreakpoints . Select ( CommandBreakpointDetails . Create ) ) ;
223
223
}
@@ -232,7 +232,7 @@ public async Task RemoveAllBreakpointsAsync(string scriptPath = null)
232
232
{
233
233
try
234
234
{
235
- if ( BreakpointApiUtils . SupportsBreakpointApis )
235
+ if ( BreakpointApiUtils . SupportsBreakpointApis ( _editorServicesHost . CurrentRunspace ) )
236
236
{
237
237
foreach ( Breakpoint breakpoint in BreakpointApiUtils . GetBreakpoints (
238
238
_editorServicesHost . Runspace . Debugger ,
@@ -262,7 +262,7 @@ public async Task RemoveAllBreakpointsAsync(string scriptPath = null)
262
262
263
263
psCommand . AddCommand ( @"Microsoft.PowerShell.Utility\Remove-PSBreakpoint" ) ;
264
264
265
- await _executionService . ExecutePSCommandAsync < object > ( psCommand , new PowerShellExecutionOptions ( ) , CancellationToken . None ) . ConfigureAwait ( false ) ;
265
+ await _executionService . ExecutePSCommandAsync < object > ( psCommand , CancellationToken . None ) . ConfigureAwait ( false ) ;
266
266
}
267
267
catch ( Exception e )
268
268
{
@@ -272,7 +272,7 @@ public async Task RemoveAllBreakpointsAsync(string scriptPath = null)
272
272
273
273
public async Task RemoveBreakpointsAsync ( IEnumerable < Breakpoint > breakpoints )
274
274
{
275
- if ( BreakpointApiUtils . SupportsBreakpointApis )
275
+ if ( BreakpointApiUtils . SupportsBreakpointApis ( _editorServicesHost . CurrentRunspace ) )
276
276
{
277
277
foreach ( Breakpoint breakpoint in breakpoints )
278
278
{
@@ -308,7 +308,7 @@ public async Task RemoveBreakpointsAsync(IEnumerable<Breakpoint> breakpoints)
308
308
psCommand . AddCommand ( @"Microsoft.PowerShell.Utility\Remove-PSBreakpoint" ) ;
309
309
psCommand . AddParameter ( "Id" , breakpoints . Select ( b => b . Id ) . ToArray ( ) ) ;
310
310
311
- await _executionService . ExecutePSCommandAsync < object > ( psCommand , new PowerShellExecutionOptions ( ) , CancellationToken . None ) ;
311
+ await _executionService . ExecutePSCommandAsync < object > ( psCommand , CancellationToken . None ) . ConfigureAwait ( false ) ;
312
312
}
313
313
}
314
314
0 commit comments