public CancellationToken Start(IServiceContainer services, JsonRpc rpc)
        {
            _server   = new Server(services);
            _services = services;
            _rpc      = rpc;

            _jsonSerializer  = services.GetService <JsonSerializer>();
            _idleTimeTracker = services.GetService <IIdleTimeTracker>();
            _logger          = services.GetService <ILogger>();
            _telemetry       = services.GetService <ITelemetryService>();

            var rpcTraceListener = new TelemetryRpcTraceListener(_telemetry);

            _rpc.TraceSource.Listeners.Add(rpcTraceListener);

            _diagnosticsPublisher                     = new DiagnosticsPublisher(_server, services);
            _server.OnApplyWorkspaceEdit             += OnApplyWorkspaceEdit;
            _server.OnRegisterCapability             += OnRegisterCapability;
            _server.OnUnregisterCapability           += OnUnregisterCapability;
            _server.AnalysisQueue.UnhandledException += OnAnalysisQueueUnhandledException;

            _disposables
            .Add(() => _server.OnApplyWorkspaceEdit             -= OnApplyWorkspaceEdit)
            .Add(() => _server.OnRegisterCapability             -= OnRegisterCapability)
            .Add(() => _server.OnUnregisterCapability           -= OnUnregisterCapability)
            .Add(() => _server.AnalysisQueue.UnhandledException -= OnAnalysisQueueUnhandledException)
            .Add(() => _shutdownCts.Cancel())
            .Add(_prioritizer)
            .Add(() => _pathsWatcher?.Dispose())
            .Add(() => _rpc.TraceSource.Listeners.Remove(rpcTraceListener))
            .Add(_diagnosticsPublisher);

            return(_sessionTokenSource.Token);
        }
        public CancellationToken Start(IServiceContainer services, JsonRpc rpc)
        {
            _services       = services;
            _ui             = services.GetService <IUIService>();
            _rpc            = rpc;
            _jsonSerializer = services.GetService <JsonSerializer>();

            var progress = services.GetService <IProgressService>();

            var rpcTraceListener = new TelemetryRpcTraceListener(services.GetService <ITelemetryService2>());

            _rpc.TraceSource.Listeners.Add(rpcTraceListener);

            _server.OnLogMessage           += OnLogMessage;
            _server.OnShowMessage          += OnShowMessage;
            _server.OnPublishDiagnostics   += OnPublishDiagnostics;
            _server.OnApplyWorkspaceEdit   += OnApplyWorkspaceEdit;
            _server.OnRegisterCapability   += OnRegisterCapability;
            _server.OnUnregisterCapability += OnUnregisterCapability;

            _disposables
            .Add(() => _server.OnLogMessage           -= OnLogMessage)
            .Add(() => _server.OnShowMessage          -= OnShowMessage)
            .Add(() => _server.OnPublishDiagnostics   -= OnPublishDiagnostics)
            .Add(() => _server.OnApplyWorkspaceEdit   -= OnApplyWorkspaceEdit)
            .Add(() => _server.OnRegisterCapability   -= OnRegisterCapability)
            .Add(() => _server.OnUnregisterCapability -= OnUnregisterCapability)
            .Add(() => _shutdownCts.Cancel())
            .Add(_prioritizer)
            .Add(() => _pathsWatcher?.Dispose())
            .Add(() => _rpc.TraceSource.Listeners.Remove(rpcTraceListener));

            return(_sessionTokenSource.Token);
        }
        public CancellationToken Start(IServiceManager services, JsonRpc rpc)
        {
            _server   = new Server(services);
            _services = services;
            _rpc      = rpc;

            _jsonSerializer  = services.GetService <JsonSerializer>();
            _idleTimeTracker = services.GetService <IIdleTimeTracker>();
            _logger          = services.GetService <ILogger>();
            _telemetry       = services.GetService <ITelemetryService>();
            _requestTimer    = new RequestTimer(_telemetry);

            var rpcTraceListener = new TelemetryRpcTraceListener(_telemetry);

            _rpc.TraceSource.Listeners.Add(rpcTraceListener);

            _disposables
            .Add(() => _shutdownCts.Cancel())
            .Add(_prioritizer)
            .Add(() => _pathsWatcher?.Dispose())
            .Add(() => _rpc.TraceSource.Listeners.Remove(rpcTraceListener));

            services.AddService(_optionsProvider);
            return(_sessionTokenSource.Token);
        }