Add PolyTypeJsonFormatter as an experimental API#1344
Merged
Conversation
f58d409 to
e31485b
Compare
There was a problem hiding this comment.
Pull Request Overview
This PR adds a new PolyTypeJsonFormatter class that provides NativeAOT-compatible JSON serialization for StreamJsonRpc using PolyType. The formatter is marked as experimental and enables AOT scenarios where dynamic code generation isn't available.
Key changes:
- Introduces
PolyTypeJsonFormatteras a new formatter option with PolyType-based serialization - Refactors
RequestIdJsonConverterinto a sharedRequestIdSTJsonConverterfor use across formatters - Creates supporting infrastructure classes (
IGenericTypeArgAssist,SourceGenerationContext) - Adds comprehensive test coverage with multiple test classes for different scenarios
Reviewed Changes
Copilot reviewed 15 out of 16 changed files in this pull request and generated 26 comments.
Show a summary per file
| File | Description |
|---|---|
| src/StreamJsonRpc/PolyTypeJsonFormatter.cs | New formatter implementation with PolyType support and experimental attribute |
| src/StreamJsonRpc/RequestIdSTJsonConverter.cs | Extracted RequestId converter for System.Text.Json reuse |
| src/StreamJsonRpc/SourceGenerationContext.cs | Source generation context for built-in types |
| src/StreamJsonRpc/IGenericTypeArgAssist.cs | Helper interfaces for generic type argument handling |
| src/StreamJsonRpc/RequestId.cs | Added System.Text.Json converter attribute |
| src/StreamJsonRpc/SystemTextJsonFormatter.cs | Refactored to use shared RequestIdSTJsonConverter |
| src/StreamJsonRpc/StreamJsonRpc.csproj | Whitespace formatting fixes |
| test files | Test classes for PolyTypeJsonFormatter covering various scenarios |
Comments suppressed due to low confidence (2)
src/StreamJsonRpc/PolyTypeJsonFormatter.cs:1347
- This foreach loop implicitly filters its target sequence - consider filtering the sequence explicitly using '.Where(...)'.
src/StreamJsonRpc/PolyTypeJsonFormatter.cs:1359 - This foreach loop implicitly filters its target sequence - consider filtering the sequence explicitly using '.Where(...)'.
etvorun
reviewed
Nov 7, 2025
etvorun
reviewed
Nov 7, 2025
etvorun
reviewed
Nov 7, 2025
etvorun
reviewed
Nov 7, 2025
e31485b to
9254613
Compare
etvorun
approved these changes
Nov 7, 2025
This was referenced Jan 22, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This is a formatter intended for use in the vs-servicehub repo to support FrameworkServices so that we can have a full stack brokered service system that is NativeAOT safe.
The formatter is hard to use, and will likely evolve into a fully PolyType-based JSON serializer. In the meantime, I have
[Experimental]slapped onto it to avoid having to maintain the public API for any user outside of vs-servicehub.