Skip to content

A proposal to import custom JsonRpc implementation based on System.Text.Json #71

@razzmatazz

Description

@razzmatazz

Currently Ionide.LanguageServerProtocol is using StreamJsonRpc which is somewhat cumbersome to use and has several deficiencies in the context of Ionide.LSP:

  • Uses Newtonsoft.Json (instead of STJ)
  • Request serialization is achieved by holding onto Task and not returning from handler until proper measures are taken (i.e. req # generated, pushed to request queue, etc)
  • Is a C# library and does not meld into F# Async contexts (e.g. ambient cancellation) nicely

I propose importing JsonRpc.fs from csharp-ls which has been actually tested in the field and provides Ordinal # in request context where the user of the library can implement custom scheduler to serialize read/write ops, for example.

Please note, that replacing StreamJsonRpc with JsonRpc.fs may not be trivial as it does not do Task-based serialization, like StreamJsonRpc does and may open servers using Ionide.LSP to more races unless we change some of the logic in Ionide.LSP to expose JsonRpcRequestContext.Ordinal and/or wrap JsonRpc.fs to enforce request handler serialization.

The alternatives are:

  • I keep it in csharp-ls
  • Ship it is as a separate nuget/library, outside of Ionide.LanguageServerProtocol

There are also tests, that could be included with the import (mostly Claude-written, may need restructuring):

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions