示例#1
0
        protected override void HandleLaunchRequestAsync(IRequestResponder <LaunchArguments> responder)
        {
            if (session != null)
            {
                var ex = new InvalidOperationException();
                Log(ex.Message, LogCategory.DebugAdapterOutput);
                responder.SetError(new ProtocolException(ex.Message, ex));
                return;
            }

            _ = LaunchConfigParser.CreateDebugSessionAsync(responder.Arguments, Protocol.SendEvent, defaultDebugView)
                .ContinueWith(t =>
            {
                if (t.IsCompletedSuccessfully)
                {
                    session = t.Result;
                    session.Start();
                    Protocol.SendEvent(new InitializedEvent());
                    responder.SetResponse(new LaunchResponse());
                }
                else
                {
                    if (t.Exception != null)
                    {
                        responder.SetError(new ProtocolException(t.Exception.Message, t.Exception));
                    }
                    else
                    {
                        responder.SetError(new ProtocolException($"Unknown error in {nameof(LaunchConfigParser.CreateDebugSessionAsync)}"));
                    }
                }
            }, TaskScheduler.Current);
        }
        public static Task <IDebugSession> CreateDebugSessionAsync(LaunchArguments launchArguments, Action <DebugEvent> sendEvent, DebugView defaultDebugView)
        {
            var launchParser = new LaunchConfigParser(launchArguments);

            return(launchParser.CreateDebugSessionAsync(sendEvent, defaultDebugView));
        }