Skip to content

Import Ionide.LSP, convert to STJ - #367

Merged
razzmatazz merged 7 commits into
mainfrom
use-system-text-json-v
Aug 18, 2026
Merged

Import Ionide.LSP, convert to STJ#367
razzmatazz merged 7 commits into
mainfrom
use-system-text-json-v

Conversation

@razzmatazz

Copy link
Copy Markdown
Owner

No description provided.

@razzmatazz
razzmatazz force-pushed the use-system-text-json-v branch 8 times, most recently from 3b27981 to 9037b13 Compare May 27, 2026 06:22
@razzmatazz
razzmatazz force-pushed the use-system-text-json-v branch 8 times, most recently from 5d54c8e to c6bd0e0 Compare June 4, 2026 07:32
@razzmatazz
razzmatazz force-pushed the use-system-text-json-v branch 2 times, most recently from 2a7203b to e0d8467 Compare August 16, 2026 13:25
razzmatazz and others added 3 commits August 18, 2026 09:41
…ext.Json

Rewrite OptionConverter.fs, JsonUtils.fs, and LanguageServerProtocol.fs to add
System.Text.Json-based converters (FSharpOptionConverter, ErasedUnionConverter,
SingleCaseUnionConverter, EnumMemberConverter, JTokenJsonConverter) alongside the
existing Newtonsoft.Json ones. Server.serialize/deserialize now go through a new
lspSerializerOptions (STJ) via LSPAny.JsonElement/LSPAny.fromJsonElement, while
defaultJsonRpcFormatter, Server.start*, and the Client module remain
Newtonsoft-based for the StreamJsonRpc wire path.

🤖 Generated with [ECA](https://eca.dev) (anthropic/claude-sonnet-5)

Co-Authored-By: eca-agent <git@eca.dev>
…chitecture

Rewrite the plan doc to describe what actually shipped: LSPAny stays a wrapper
class (from origin/main's existing Ionide.LSP import) rather than becoming a raw
JsonElement alias, with STJ converters (LSPAnyJsonConverter, JTokenJsonConverter,
and friends) added alongside the existing Newtonsoft ones. Server.serialize/
deserialize now use System.Text.Json via the LSPAny.JsonElement bridge, while
defaultJsonRpcFormatter/Server.start*/Client stay Newtonsoft-based and untouched.
Mark the originally-planned codegen/JsonRpc.fs/shim-removal phases as superseded
since they were already satisfied on origin/main via a different mechanism.

🤖 Generated with [ECA](https://eca.dev) (anthropic/claude-sonnet-5)

Co-Authored-By: eca-agent <git@eca.dev>
Replace remaining JToken/JObject usage in the CSharpLanguageServer project
and its tests with System.Text.Json equivalents (JsonElement/JsonNode),
and remove the Newtonsoft.Json PackageReference from the fsproj. Newtonsoft
remains a transitive dependency via Ionide.LanguageServerProtocol, which is
unaffected by this change.

🤖 Generated with [ECA](https://eca.dev) (anthropic/claude-sonnet-5)

Co-Authored-By: eca-agent <git@eca.dev>
@razzmatazz
razzmatazz force-pushed the use-system-text-json-v branch from e69c58b to 8a40c8d Compare August 18, 2026 06:41
razzmatazz and others added 4 commits August 18, 2026 10:29
csharp-ls's own code was already Newtonsoft-free. This adds a direct
Newtonsoft.Json PackageReference with ExcludeAssets="runtime" so the DLL
that flows in transitively via StreamJsonRpc (through
Ionide.LanguageServerProtocol) is no longer copied into the build/publish
output, matching the existing pattern used for Microsoft.Build/
NuGet.Frameworks. Verified via `dotnet publish` that Newtonsoft.Json.dll
and any mention of it in CSharpLanguageServer.deps.json are both gone.

Also:
- CodeLens.fs: use the existing STJ-based `deserialize` helper instead of
  `LSPAny.JToken.ToObject<...>` to resolve CodeLens data.
- Small comment fixes (Lsp/Client.fs, Handlers/Workspace.fs) that
  referenced Newtonsoft terminology no longer accurate once
  Ionide.LanguageServerProtocol's LSPAny becomes JsonElement-backed.
- DiagnosticTests.fs: replace direct `LSPAny.JToken`/`fromJToken` usage
  with `LSPAny.JsonElement`/`fromJsonElement` (STJ) equivalents.
- docs/plans updated to describe the new state.

🤖 Generated with [ECA](https://eca.dev) (anthropic/claude-sonnet-5)

Co-Authored-By: eca-agent <git@eca.dev>
…ship it

Stops shipping Newtonsoft.Json.dll with csharp-ls: the vendored
Ionide.LanguageServerProtocol.fsproj no longer references the package.
Its remaining consumers are disabled, not deleted — guarded behind
`#if NEWTONSOFT_LEGACY_UNUSED ... #endif` (a symbol that is never
defined), so the code stays in the tree and can be re-enabled by
defining that symbol and re-adding the package reference:

- Server.defaultJsonRpcFormatter / Server.start* (start/startWs/
  startWithSetup/startWithSetupWs) / Server.defaultRpc, and the
  hand-rolled Client module in LanguageServerProtocol.fs — confirmed
  unused anywhere in csharp-ls or its tests (csharp-ls uses its own
  Runtime/JsonRpc.fs transport instead).
- JsonRpc.Request/Notification/Response/MessageTypeTest — only used by
  the now-disabled Client module.
- The Newtonsoft-only converters in JsonUtils.fs/OptionConverter.fs that
  only fed the disabled formatter.

What had to change for real (not just guarded), since it's on the live
STJ path csharp-ls actually uses:

- LSPAny (Types.fs) is now backed directly by System.Text.Json.JsonElement
  instead of bridging through Newtonsoft.Json.Linq.JToken.
- JsonRpc.Error.Data is now JsonElement option instead of JToken option.
- Types.cg.fs (generated) and its generator
  (tools/MetaModelGenerator/GenerateTypes.fs) no longer emit JToken-typed
  fields or the inert Newtonsoft [<JsonProperty>]/
  [<JsonConverter(StringEnumConverter)>] attributes; [<JsonIgnore>] on
  generated DebuggerDisplay members now resolves to STJ's attribute
  instead of Newtonsoft's, so it's actually honoured.

`dotnet build`/`dotnet test` pass in full (282/282), and `dotnet publish`
confirms Newtonsoft.Json.dll is absent from the output.

🤖 Generated with [ECA](https://eca.dev) (anthropic/claude-sonnet-5)

Co-Authored-By: eca-agent <git@eca.dev>
…ip it

Extends the NEWTONSOFT_LEGACY_UNUSED guard (previously only covering the
Newtonsoft.Json wire path) over the remaining StreamJsonRpc-based
Server.startWithSetupCore/Server.start* transport and the generated
Mappings.routeMappings, then drops the StreamJsonRpc package reference
entirely. The code itself is left untouched behind the #if so it stays
easy to diff/merge against upstream; only the generator gained a small
post-processing step to keep re-guarding ClientServer.cg.fs on every
regeneration. csharp-ls no longer restores or ships StreamJsonRpc,
Newtonsoft.Json, MessagePack, Nerdbank.Streams, or
Microsoft.VisualStudio.Threading/Validation (and their resource
satellites), shrinking the published tool by ~3MB with no ExcludeAssets
workaround needed.

🤖 Generated with [ECA](https://eca.dev) (anthropic/claude-sonnet-5)

Co-Authored-By: eca-agent <git@eca.dev>
@razzmatazz
razzmatazz merged commit b096481 into main Aug 18, 2026
2 checks passed
@razzmatazz
razzmatazz deleted the use-system-text-json-v branch August 18, 2026 08:02
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant