public async ValueTask <RemoteDebuggingSessionProxy?> StartDebuggingSessionAsync(
            Solution solution,
            IManagedEditAndContinueDebuggerService debuggerService,
            bool captureMatchingDocuments,
            bool reportDiagnostics,
            CancellationToken cancellationToken)
        {
            var client = await RemoteHostClient.TryGetClientAsync(Workspace, cancellationToken).ConfigureAwait(false);

            if (client == null)
            {
                var sessionId = await GetLocalService().StartDebuggingSessionAsync(solution, debuggerService, captureMatchingDocuments, reportDiagnostics, cancellationToken).ConfigureAwait(false);

                return(new RemoteDebuggingSessionProxy(Workspace, LocalConnection.Instance, sessionId));
            }

            // need to keep the providers alive until the edit session ends:
            var connection = client.CreateConnection <IRemoteEditAndContinueService>(
                callbackTarget: new EditSessionCallback(debuggerService));

            var sessionIdOpt = await connection.TryInvokeAsync(
                solution,
                async (service, solutionInfo, callbackId, cancellationToken) => await service.StartDebuggingSessionAsync(solutionInfo, callbackId, captureMatchingDocuments, reportDiagnostics, cancellationToken).ConfigureAwait(false),
                cancellationToken).ConfigureAwait(false);

            if (sessionIdOpt.HasValue)
            {
                return(new RemoteDebuggingSessionProxy(Workspace, connection, sessionIdOpt.Value));
            }

            connection.Dispose();
            return(null);
        }
 public ManagedEditAndContinueLanguageService(
     VisualStudioWorkspace workspace,
     IManagedEditAndContinueDebuggerService debuggerService,
     IDiagnosticAnalyzerService diagnosticService,
     EditAndContinueDiagnosticUpdateSource diagnosticUpdateSource)
 {
     _proxy            = new RemoteEditAndContinueServiceProxy(workspace);
     _debuggingService = workspace.Services.GetRequiredService <IDebuggingWorkspaceService>();
     _activeStatementTrackingService = workspace.Services.GetRequiredService <IActiveStatementTrackingService>();
     _debuggerService        = debuggerService;
     _diagnosticService      = diagnosticService;
     _diagnosticUpdateSource = diagnosticUpdateSource;
 }
 public EditSessionCallback(IManagedEditAndContinueDebuggerService debuggerService)
 {
     _debuggerService = debuggerService;
 }
 /// <summary>
 /// This will be removed when IManagedEditAndContinueDebuggerService gets the method for real
 /// </summary>
 public static ValueTask <ImmutableArray <string> > GetCapabilitiesAsync(this IManagedEditAndContinueDebuggerService _1, CancellationToken _2)
 {
     return(new(ImmutableArray.Create("Baseline", "AddDefinitionToExistingType", "NewTypeDefinition")));
 }