Description
Installed products
- Visual Studio: Community 2022
- Visual Studio Code
Description
Issue is not specific to the sample given but I could not find any more appropriate place to report this issue with the Microsoft.VisualStudio.LanguageServer.Protocol extension. The SemanticTokensOptions and SemanticTokensLegend classes are lacking [DataContract]
attributes on their class definitions, causing the [DataMember]
attributes that would camelCase their members getting ignored when serialized, which causes editors like VS Code to ignore the Semantic tokens capability.
Steps to recreate
- Setup the
SemanticTokensOptions
property onServerCapabilities
in the Initialize JSON-RPC result, such as:
SemanticTokensOptions = new SemanticTokensOptions
{
Full = true,
Legend = new SemanticTokensLegend
{
TokenTypes = SemanticTokensBuilder.SemanticTokenTypes,
TokenModifiers = SemanticTokensBuilder.SemanticTokenModifiers
}
},
- Run server with a client such as Visual Studio Code.
- Observe that the initialize request calls back with PascalCase members on the
semanticTokensOptions
section.
Current behavior
PascalCase behavior on the semanticTokenProvider
causes editors like Visual Studio Code to not issue JSON-RPC textDocument/semanticTokens
requests to the server as the object does not conform to the LSP specification.
Expected behavior
semanticTokenProvider
members (and legend) should be camelCase (through adding the necessary [DataContract]
attributes which will enable semantic token requests in VS Code. I have tested this through a workaround and can confirm that the requests work as expected when the data contract is added.