ionide / ionide/LanguageServerProtocol

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

Open
#71 6 comments 0 reactions 0 assignees View on GitHub
Dominant language
F#
Stars
58
Forks
21
PR merge metrics
No merged PRs in 30d

Description

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](https://github.com/razzmatazz/csharp-language-server/blob/main/src/CSharpLanguageServer/Runtime/JsonRpc.fs) 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):
- https://github.com/razzmatazz/csharp-language-server/blob/main/tests/CSharpLanguageServer.Tests/JsonRpcTests.fs

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.