csharp-language-server-protocol icon indicating copy to clipboard operation
csharp-language-server-protocol copied to clipboard

When the server sends a custom request, an exception occurs in the serialization of the'descriptor'

Open pengsongkun741 opened this issue 4 years ago • 0 comments

Client version:19.0.0 Server send request data: {"jsonrpc":"2.0","id":5,"method":"vscode/content","params":["https://json.schemastore.org/bower.json"]}

I added a response method to the request when I initialized the client

_client = LanguageClient.PreInit(options =>
                {
                    options.WithInput(_process.StandardOutput.BaseStream)
                    .WithOutput(_process.StandardInput.BaseStream)
                    .WithCapability(completionCapability)
                    .WithCapability(rangeFormattion)
                    .WithInitializationOptions(initializationOptions)
                    .OnRequest("vscode/content", this.OnVscodeContentRequest());
                });

But I found that when the server sent the request, this.OnVscodeContentRequest() was not triggered. So I debugged the client source code and found that there was a serialization conversion exception when receiving the request。

///  .\src\Shared\LspRequestRouter.cs  line:56-60
if (descriptor.IsDelegatingHandler)
            {
                var o = @params.ToObject(descriptor.Params.GetGenericArguments()[0], _serializer.JsonSerializer);
                paramsValue = Activator.CreateInstance(descriptor.Params, o);
            }

This is throw exception:

Error reading string. Unexpected token: StartArray. Path 'params', line 1, position 60.

Is this a problem handled by the client?

pengsongkun741 avatar Jun 28 '21 06:06 pengsongkun741