-
Notifications
You must be signed in to change notification settings - Fork 171
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Use Microsoft.VisualStudio.Shared.VsCodeDebugProtocol for protocol #16
Comments
@DavidKarlas |
@andrewcrawley do you have some example of adapter? |
We haven't published any samples. The short version is:
You can also use the DebugProtocolClient class directly - the |
@andrewcrawley great, that is helpful, thanks a lot! |
@andrewcrawley @DavidKarlas @gregg-miskelly I did a first path of adopting the nuget package in mono-debug. I could remove a ton of obsolete code (which is great) and all of mono-debug's functionality is already working (see https://github.com/Microsoft/vscode-mono-debug/tree/aweinand/dap_nuget) Two things I noticed: Since the request handlers are expected to return the request response, it is difficult (impossible?) to create the correct sequence of responses and events: VS Code expects that a request has returned its respond before any events enabled or triggered by the request arrive. In the JavaScript/TypeScript debug adapter library handlers do not return the response but send them explicitly back with "SendResponse" (and the handlers return type is 'void'). This makes it possible to freely control the order of "SendEvent" and "SendResponse" calls in the handler. An example is protected override InitializeResponse HandleInitializeRequest(InitializeArguments args)
{
// ...
// Mono Debug is ready to accept breakpoints immediately
Protocol.SendEvent(new InitializedEvent());
return new InitializeResponse(
// This debug adapter does not need the configurationDoneRequest.
supportsConfigurationDoneRequest: false,
// ...
);
} The better order would be: protected override void HandleInitializeRequest(InitializeResponse response, InitializeArguments args)
{
// ...
response.capabilities.supportsConfigurationDoneRequest = true;
Protocol.SendResponse(response);
// Mono Debug is ready to accept breakpoints immediately
Protocol.SendEvent(new InitializedEvent());
} Another nice consequence of a 'void' return type is that handlers can be marked 'async' which makes it easy to use 'await' in the handler's body. I ran into this when trying to use 'await' to get the "runInTerminal" reverse request working. Are you using "runInTerminal" in any nuget based debug adapter? Do you have a code snippet that shows how to wait for the response of the "runInTerminal" request? |
@weinand - The behavior of the library should be that any calls to At the moment, the only consumer of the DebugProtocolClient is our internal SampleDebugAdapter that we use for testing the VS debug adapter host, and our host doesn't support the Also, rather than returning an ErrorResponse directly, you can just throw a ProtocolException with the right data set on it and we'll do the conversion. Right now, the library ignores the error id and some of the other fields while doing the conversion, but that's an easy fix. |
@andrewcrawley great to hear that the client library takes care of the ordering problem. Yes, I saw the ProtocolException but I tried to minimise the number of changes to my code. I will revisit when everything works again. RunInTerminalRequest: ok, then I will have to try a bit harder... :-) |
FYI, the code you have now for the error handling will crash - ErrorResponse can't be cast to any other response type. |
This NuGet is protocol library generated from protocol.json file.
https://www.nuget.org/packages/Microsoft.VisualStudio.Shared.VsCodeDebugProtocol/
This issue is just to raise awareness and no need for immediate switching.
The text was updated successfully, but these errors were encountered: