public async Task InitializeAsync()
        {
            var factory = new LoggerFactory();

            _psesProcess = new PsesStdioProcess(factory, true);
            await _psesProcess.Start();

            var initialized = new TaskCompletionSource <bool>();

            PsesDebugAdapterClient = DebugAdapterClient.Create(options =>
            {
                options
                .WithInput(_psesProcess.OutputStream)
                .WithOutput(_psesProcess.InputStream)
                // The OnStarted delegate gets run when we receive the _Initialized_ event from the server:
                // https://microsoft.github.io/debug-adapter-protocol/specification#Events_Initialized
                .OnStarted((client, token) => {
                    Started.SetResult(true);
                    return(Task.CompletedTask);
                })
                // The OnInitialized delegate gets run when we first receive the _Initialize_ response:
                // https://microsoft.github.io/debug-adapter-protocol/specification#Requests_Initialize
                .OnInitialized((client, request, response, token) => {
                    initialized.SetResult(true);
                    return(Task.CompletedTask);
                });
            });

            // PSES follows the following flow:
            // Receive a Initialize request
            // Run Initialize handler and send response back
            // Receive a Launch/Attach request
            // Run Launch/Attach handler and send response back
            // PSES sends the initialized event at the end of the Launch/Attach handler

            // The way that the Omnisharp client works is that this Initialize method doesn't return until
            // after OnStarted is run... which only happens when Initialized is received from the server.
            // so if we would await this task, it would deadlock.
            // To get around this, we run the Initialize() without await but use a `TaskCompletionSource<bool>`
            // that gets completed when we receive the response to Initialize
            // This tells us that we are ready to send messages to PSES... but are not stuck waiting for
            // Initialized.
            PsesDebugAdapterClient.Initialize(CancellationToken.None).ConfigureAwait(false);
            await initialized.Task.ConfigureAwait(false);
        }
            public ActionDelegateData()
            {
                {
                    var baseOptions = new DebugAdapterServerOptions().WithPipe(new Pipe());

                    void BaseDelegate(DebugAdapterServerOptions o)
                    {
                        o.WithPipe(new Pipe());
                    }

                    var serviceProvider = new ServiceCollection().BuildServiceProvider();
                    Add(new ActionDelegate("create (server): options", () => DebugAdapterServer.Create(baseOptions)));
                    Add(new ActionDelegate("create (server): options, serviceProvider", () => DebugAdapterServer.Create(baseOptions, serviceProvider)));
                    Add(new ActionDelegate("create (server): action", () => DebugAdapterServer.Create(BaseDelegate)));
                    Add(new ActionDelegate("create (server): action, serviceProvider", () => DebugAdapterServer.Create(BaseDelegate, serviceProvider)));

                    Add(new ActionDelegate("from (server): options", () => DebugAdapterServer.From(baseOptions)));
                    Add(new ActionDelegate("from (server): options, cancellationToken", () => DebugAdapterServer.From(baseOptions, CancellationToken.None)));
                    Add(
                        new ActionDelegate(
                            "from (server): options, serviceProvider, cancellationToken", () => DebugAdapterServer.From(baseOptions, serviceProvider, CancellationToken.None)
                            )
                        );
                    Add(new ActionDelegate("from (server): options, serviceProvider", () => DebugAdapterServer.From(baseOptions, serviceProvider)));
                    Add(new ActionDelegate("from (server): action", () => DebugAdapterServer.From(BaseDelegate)));
                    Add(new ActionDelegate("from (server): action, cancellationToken", () => DebugAdapterServer.From(BaseDelegate, CancellationToken.None)));
                    Add(
                        new ActionDelegate(
                            "from (server): action, serviceProvider, cancellationToken", () => DebugAdapterServer.From(BaseDelegate, serviceProvider, CancellationToken.None)
                            )
                        );
                    Add(new ActionDelegate("from (server): action, serviceProvider", () => DebugAdapterServer.From(BaseDelegate, serviceProvider)));
                }
                {
                    var baseOptions = new DebugAdapterClientOptions().WithPipe(new Pipe());

                    void BaseDelegate(DebugAdapterClientOptions o)
                    {
                        o.WithPipe(new Pipe());
                    }

                    var serviceProvider = new ServiceCollection().BuildServiceProvider();
                    Add(new ActionDelegate("create (client): options", () => DebugAdapterClient.Create(baseOptions)));
                    Add(new ActionDelegate("create (client): options, serviceProvider", () => DebugAdapterClient.Create(baseOptions, serviceProvider)));
                    Add(new ActionDelegate("create (client): action", () => DebugAdapterClient.Create(BaseDelegate)));
                    Add(new ActionDelegate("create (client): action, serviceProvider", () => DebugAdapterClient.Create(BaseDelegate, serviceProvider)));

                    Add(new ActionDelegate("from (client): options", () => DebugAdapterClient.From(baseOptions)));
                    Add(new ActionDelegate("from (client): options, cancellationToken", () => DebugAdapterClient.From(baseOptions, CancellationToken.None)));
                    Add(
                        new ActionDelegate(
                            "from (client): options, serviceProvider, cancellationToken", () => DebugAdapterClient.From(baseOptions, serviceProvider, CancellationToken.None)
                            )
                        );
                    Add(new ActionDelegate("from (client): options, serviceProvider", () => DebugAdapterClient.From(baseOptions, serviceProvider)));
                    Add(new ActionDelegate("from (client): action", () => DebugAdapterClient.From(BaseDelegate)));
                    Add(new ActionDelegate("from (client): action, cancellationToken", () => DebugAdapterClient.From(BaseDelegate, CancellationToken.None)));
                    Add(
                        new ActionDelegate(
                            "from (client): action, serviceProvider, cancellationToken", () => DebugAdapterClient.From(BaseDelegate, serviceProvider, CancellationToken.None)
                            )
                        );
                    Add(new ActionDelegate("from (client): action, serviceProvider", () => DebugAdapterClient.From(BaseDelegate, serviceProvider)));
                }
            }