public async Task <List <Breakpoint> > GetBreakpointsAsync() { if (BreakpointApiUtils.SupportsBreakpointApis) { return(BreakpointApiUtils.GetBreakpoints( _powerShellContextService.CurrentRunspace.Runspace.Debugger, _debugStateService.RunspaceId)); } // Legacy behavior PSCommand psCommand = new PSCommand(); psCommand.AddCommand(@"Microsoft.PowerShell.Utility\Get-PSBreakpoint"); IEnumerable <Breakpoint> breakpoints = await _powerShellContextService.ExecuteCommandAsync <Breakpoint>(psCommand); return(breakpoints.ToList()); }
/// <summary> /// Clears all breakpoints in the current session. /// </summary> public async Task RemoveAllBreakpointsAsync(string scriptPath = null) { try { if (BreakpointApiUtils.SupportsBreakpointApis) { foreach (Breakpoint breakpoint in BreakpointApiUtils.GetBreakpoints( _powerShellContextService.CurrentRunspace.Runspace.Debugger, _debugStateService.RunspaceId)) { if (scriptPath == null || scriptPath == breakpoint.Script) { BreakpointApiUtils.RemoveBreakpoint( _powerShellContextService.CurrentRunspace.Runspace.Debugger, breakpoint, _debugStateService.RunspaceId); } } return; } // Legacy behavior PSCommand psCommand = new PSCommand(); psCommand.AddCommand(@"Microsoft.PowerShell.Utility\Get-PSBreakpoint"); if (!string.IsNullOrEmpty(scriptPath)) { psCommand.AddParameter("Script", scriptPath); } psCommand.AddCommand(@"Microsoft.PowerShell.Utility\Remove-PSBreakpoint"); await _powerShellContextService.ExecuteCommandAsync <object>(psCommand).ConfigureAwait(false); } catch (Exception e) { _logger.LogException("Caught exception while clearing breakpoints from session", e); } }