public async Task Initialize(CancellationToken token)
        {
            await DebugAdapterEventingHelper.Run(
                _initializeDelegates,
                (handler, ct) => handler(this, ClientSettings, ct),
                _initializeHandlers.Union(_collection.Select(z => z.Handler).OfType <IOnDebugAdapterClientInitialize>()),
                (handler, ct) => handler.OnInitialize(this, ClientSettings, ct),
                _concurrency,
                _scheduler,
                token
                ).ConfigureAwait(false);

            RegisterCapabilities(ClientSettings);

            _connection.Open();
            var serverParams = await this.RequestDebugAdapterInitialize(ClientSettings, token).ConfigureAwait(false);

            _receiver.Initialized();

            ServerSettings = serverParams;

            await DebugAdapterEventingHelper.Run(
                _initializedDelegates,
                (handler, ct) => handler(this, ClientSettings, ServerSettings, ct),
                _initializedHandlers.Union(_collection.Select(z => z.Handler).OfType <IOnDebugAdapterClientInitialized>()),
                (handler, ct) => handler.OnInitialized(this, ClientSettings, ServerSettings, ct),
                _concurrency,
                _scheduler,
                token
                ).ConfigureAwait(false);

            await _initializedComplete.ToTask(token, _scheduler).ConfigureAwait(false);

            await DebugAdapterEventingHelper.Run(
                _startedDelegates,
                (handler, ct) => handler(this, ct),
                _startedHandlers.Union(_collection.Select(z => z.Handler).OfType <IOnDebugAdapterClientStarted>()),
                (handler, ct) => handler.OnStarted(this, ct),
                _concurrency,
                _scheduler,
                token
                ).ConfigureAwait(false);

            _instanceHasStarted.Started = true;
        }
Beispiel #2
0
        async Task <InitializeResponse> IRequestHandler <InitializeRequestArguments, InitializeResponse> .Handle(
            InitializeRequestArguments request,
            CancellationToken cancellationToken
            )
        {
            _settingsBag.ClientSettings = request;

            await DebugAdapterEventingHelper.Run(
                _initializeDelegates,
                (handler, ct) => handler(this, request, ct),
                _initializeHandlers.Union(_collection.Select(z => z.Handler).OfType <IOnDebugAdapterServerInitialize>()),
                (handler, ct) => handler.OnInitialize(this, request, ct),
                _concurrency,
                cancellationToken
                ).ConfigureAwait(false);

            var response = new InitializeResponse {
                AdditionalModuleColumns        = _capabilities.AdditionalModuleColumns,
                ExceptionBreakpointFilters     = _capabilities.ExceptionBreakpointFilters,
                SupportedChecksumAlgorithms    = _capabilities.SupportedChecksumAlgorithms,
                SupportsCompletionsRequest     = _capabilities.SupportsCompletionsRequest || _collection.ContainsHandler(typeof(ICompletionsHandler)),
                SupportsConditionalBreakpoints = _capabilities.SupportsConditionalBreakpoints,
                SupportsDataBreakpoints        = _capabilities.SupportsDataBreakpoints ||
                                                 _collection.ContainsHandler(typeof(IDataBreakpointInfoHandler)) || _collection.ContainsHandler(typeof(ISetDataBreakpointsHandler)),
                SupportsDisassembleRequest  = _capabilities.SupportsDisassembleRequest || _collection.ContainsHandler(typeof(IDisassembleHandler)),
                SupportsExceptionOptions    = _capabilities.SupportsExceptionOptions,
                SupportsFunctionBreakpoints = _capabilities.SupportsFunctionBreakpoints || _collection.ContainsHandler(typeof(ISetFunctionBreakpointsHandler)),
                SupportsLogPoints           = _capabilities.SupportsLogPoints,
                SupportsModulesRequest      = _capabilities.SupportsModulesRequest || _collection.ContainsHandler(typeof(IModuleHandler)),
                SupportsRestartFrame        = _capabilities.SupportsRestartFrame || _collection.ContainsHandler(typeof(IRestartFrameHandler)),
                SupportsRestartRequest      = _capabilities.SupportsRestartRequest || _collection.ContainsHandler(typeof(IRestartHandler)),
                SupportsSetExpression       = _capabilities.SupportsSetExpression || _collection.ContainsHandler(typeof(ISetExpressionHandler)),
                SupportsSetVariable         = _capabilities.SupportsSetVariable || _collection.ContainsHandler(typeof(ISetVariableHandler)),
                SupportsStepBack            = _capabilities.SupportsStepBack ||
                                              _collection.ContainsHandler(typeof(IStepBackHandler)) && _collection.ContainsHandler(typeof(IReverseContinueHandler)),
                SupportsTerminateRequest           = _capabilities.SupportsTerminateRequest || _collection.ContainsHandler(typeof(ITerminateHandler)),
                SupportTerminateDebuggee           = _capabilities.SupportTerminateDebuggee,
                SupportsConfigurationDoneRequest   = _capabilities.SupportsConfigurationDoneRequest || _collection.ContainsHandler(typeof(IConfigurationDoneHandler)),
                SupportsEvaluateForHovers          = _capabilities.SupportsEvaluateForHovers,
                SupportsExceptionInfoRequest       = _capabilities.SupportsExceptionInfoRequest || _collection.ContainsHandler(typeof(IExceptionInfoHandler)),
                SupportsGotoTargetsRequest         = _capabilities.SupportsGotoTargetsRequest || _collection.ContainsHandler(typeof(IGotoTargetsHandler)),
                SupportsHitConditionalBreakpoints  = _capabilities.SupportsHitConditionalBreakpoints,
                SupportsLoadedSourcesRequest       = _capabilities.SupportsLoadedSourcesRequest || _collection.ContainsHandler(typeof(ILoadedSourcesHandler)),
                SupportsReadMemoryRequest          = _capabilities.SupportsReadMemoryRequest || _collection.ContainsHandler(typeof(IReadMemoryHandler)),
                SupportsTerminateThreadsRequest    = _capabilities.SupportsTerminateThreadsRequest || _collection.ContainsHandler(typeof(ITerminateThreadsHandler)),
                SupportsValueFormattingOptions     = _capabilities.SupportsValueFormattingOptions,
                SupportsDelayedStackTraceLoading   = _capabilities.SupportsDelayedStackTraceLoading,
                SupportsStepInTargetsRequest       = _capabilities.SupportsStepInTargetsRequest || _collection.ContainsHandler(typeof(IStepInTargetsHandler)),
                SupportsCancelRequest              = _capabilities.SupportsCancelRequest || _collection.ContainsHandler(typeof(ICancelHandler)),
                SupportsClipboardContext           = _capabilities.SupportsClipboardContext,
                SupportsInstructionBreakpoints     = _capabilities.SupportsInstructionBreakpoints || _collection.ContainsHandler(typeof(ISetInstructionBreakpointsHandler)),
                SupportsSteppingGranularity        = _capabilities.SupportsSteppingGranularity,
                SupportsBreakpointLocationsRequest = _capabilities.SupportsBreakpointLocationsRequest || _collection.ContainsHandler(typeof(IBreakpointLocationsHandler))
            };

            _settingsBag.ServerSettings = response;

            await DebugAdapterEventingHelper.Run(
                _initializedDelegates,
                (handler, ct) => handler(this, request, response, ct),
                _initializedHandlers.Union(_collection.Select(z => z.Handler).OfType <IOnDebugAdapterServerInitialized>()),
                (handler, ct) => handler.OnInitialized(this, request, response, ct),
                _concurrency,
                cancellationToken
                ).ConfigureAwait(false);

            _receiver.Initialized();

            _initializeComplete.OnNext(response);
            _initializeComplete.OnCompleted();

            return(response);
        }