microsoft / microsoft/vs-streamjsonrpc
Make RequestIdSTJsonConverter public for AOT/trimming compatibility
Nobody has claimed this yet.
- Dominant language
- C#
- Stars
- 937
- Forks
- 178
- Avg merge
- 3d 1h
- Merged PRs (30d)
- 28
Description
Problem
When using SystemTextJsonFormatter with custom JsonSerializerOptions that use TypeInfoResolverChain (the AOT-safe approach), RequestId serialization fails at runtime because:
RequestIdSTJsonConverterisinternal, so consumers cannot reference it[JsonSerializable(typeof(RequestId))]fails with SYSLIB1220 becauseRequestIdhas[JsonConverter(typeof(RequestIdSTJsonConverter))]and that converter is inaccessible (CS0122)MassageUserDataSerializerOptionsadds the converter viaoptions.Converters.Add(), but in AOT mode without a reflection-based fallback resolver,Convertersalone cannot produceJsonTypeInfo<RequestId>— the converter is unreachable
This surfaces as a NotSupportedException when StandardCancellationStrategy tries to serialize a $/cancelRequest notification containing a RequestId.
Suggested Fix
Make RequestIdSTJsonConverter public so consumers can either:
- Use
[JsonSerializable(typeof(RequestId))]in their source-generated contexts - Reference the converter directly when building custom
IJsonTypeInfoResolverimplementations
Additionally, MassageUserDataSerializerOptions could be updated to add entries to TypeInfoResolverChain (not just Converters), so the formatter is self-sufficient in AOT mode even when users provide custom options.
Workaround
We currently duplicate the converter logic and wire it via a custom IJsonTypeInfoResolver + JsonMetadataServices.CreateValueInfo<RequestId>(). See: https://github.com/github/copilot-sdk/pull/783
Related
- #840 — RequestId AOT crash (Newtonsoft-based, same class of problem)
- #1230 — AOT
NotSupportedExceptionwithIAsyncEnumerablestructs (same root cause pattern: internal converters + AOT)
cc @AArnott
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start by inspecting RequestIdSTJsonConverter and MassageUserDataSerializerOptions, then trace how StandardCancellationStrategy serializes RequestId with custom TypeInfoResolverChain options. Compare the proposed public-converter approach with the resolver workaround in copilot-sdk PR 783. Done means the selected AOT/trimming path is implemented and RequestId serialization works without a reflection-based fallback.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- csharp
- Domain
- api, backend-api-design
- Issue type
- Feature
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 45/100