public async Task <DscBreakpointCapability> GetDscBreakpointCapabilityAsync( ILogger logger, PsesInternalHost psesHost, CancellationToken cancellationToken) { return(_dscBreakpointCapability ??= await DscBreakpointCapability.GetDscCapabilityAsync( logger, this, psesHost, cancellationToken) .ConfigureAwait(false)); }
/// <summary> /// Sets the list of line breakpoints for the current debugging session. /// </summary> /// <param name="scriptFile">The ScriptFile in which breakpoints will be set.</param> /// <param name="breakpoints">BreakpointDetails for each breakpoint that will be set.</param> /// <param name="clearExisting">If true, causes all existing breakpoints to be cleared before setting new ones.</param> /// <returns>An awaitable Task that will provide details about the breakpoints that were set.</returns> public async Task <BreakpointDetails[]> SetLineBreakpointsAsync( ScriptFile scriptFile, BreakpointDetails[] breakpoints, bool clearExisting = true) { DscBreakpointCapability dscBreakpoints = await _debugContext.GetDscBreakpointCapabilityAsync(CancellationToken.None).ConfigureAwait(false); string scriptPath = scriptFile.FilePath; // Make sure we're using the remote script path if (_psesHost.CurrentRunspace.IsOnRemoteMachine && _remoteFileManager is not null) { if (!_remoteFileManager.IsUnderRemoteTempPath(scriptPath)) { _logger.LogTrace($"Could not set breakpoints for local path '{scriptPath}' in a remote session."); return(Array.Empty <BreakpointDetails>()); } scriptPath = _remoteFileManager.GetMappedPath(scriptPath, _psesHost.CurrentRunspace); } else if (temporaryScriptListingPath?.Equals(scriptPath, StringComparison.CurrentCultureIgnoreCase) == true) { _logger.LogTrace($"Could not set breakpoint on temporary script listing path '{scriptPath}'."); return(Array.Empty <BreakpointDetails>()); } // Fix for issue #123 - file paths that contain wildcard chars [ and ] need to // quoted and have those wildcard chars escaped. string escapedScriptPath = PathUtils.WildcardEscapePath(scriptPath); if (dscBreakpoints?.IsDscResourcePath(escapedScriptPath) != true) { if (clearExisting) { await _breakpointService.RemoveAllBreakpointsAsync(scriptFile.FilePath).ConfigureAwait(false); } return((await _breakpointService.SetBreakpointsAsync(escapedScriptPath, breakpoints).ConfigureAwait(false)).ToArray()); } return(await dscBreakpoints .SetLineBreakpointsAsync(_executionService, escapedScriptPath, breakpoints) .ConfigureAwait(false)); }