Skip to content

[LanguageServerProtocol] Incorrect serialization behaviour on SemanticTokensOptions & SemanticTokensLegend classes #285

Open
@Blakintosh

Description

@Blakintosh

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

  1. Setup the SemanticTokensOptions property on ServerCapabilities in the Initialize JSON-RPC result, such as:
SemanticTokensOptions = new SemanticTokensOptions
{
    Full = true,
    Legend = new SemanticTokensLegend
    {
        TokenTypes = SemanticTokensBuilder.SemanticTokenTypes,
        TokenModifiers = SemanticTokensBuilder.SemanticTokenModifiers
    }
},
  1. Run server with a client such as Visual Studio Code.
  2. Observe that the initialize request calls back with PascalCase members on the semanticTokensOptions section.
    image

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions