Skip to content
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

How to pack method parameters #1089

Open
georghinkel opened this issue Oct 25, 2024 · 1 comment
Open

How to pack method parameters #1089

georghinkel opened this issue Oct 25, 2024 · 1 comment

Comments

@georghinkel
Copy link

I am trying to create an LSP server in C#. I have come across the LspTypes package that defines all the types of LSP 3.16. Slightly strange that there is no more up to date package for this, but that's a side note, I suppose (suggestions welcome).

Now the issue is, when I define for instance the Initialize method as InitializeResult Initialize(InitializeParams @params), I get an error saying that the client provided eight arguments while the method can only accept a single. How can I specify that the parameter denotes the entire request and the library should instead bundle all of the eight parameters into a single InitializeParams?

I tried setting UseSingleObjectParameterDeserialization = true but it does not seem to work, I still get the error message that the method only accepts a single argument but 8 were provided.

I am using StreamJsonRPC version 2.19.27.

@AArnott
Copy link
Member

AArnott commented Oct 26, 2024

Good question.

The initial problem comes of the fact that LSP isn't actually JSON-RPC. JSON-RPC would mandate that the form of requests LSP uses actually be interpreted as 8 individual parameters rather than as one object. It's a shame, because LSP could have been designed as a proper JSON-RPC use by simply adding [ ] around the JSON object it currently sets to the params property. But oh well...

Your attempt to use UseSingleObjectParameterDeserialization = true on the RPC method should have worked. We added that to StreamJsonRpc specifically to allow for the LSP variant of JSON-RPC. Are you sure your method takes exactly 1 parameter (plus an optional CancellationToken parameter)? If it takes any more than that, the attribute property will be ignored.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants