Skip to content

Add PolyTypeJsonFormatter as an experimental API - #1344

Merged
Andrew Arnott (AArnott) merged 1 commit into
mainfrom
dev/andarno/stjNativeAotSafe
Nov 7, 2025
Merged

Andrew Arnott (AArnott) merged 1 commit into
mainfrom
dev/andarno/stjNativeAotSafe

Conversation

@AArnott

@AArnott Andrew Arnott (AArnott) commented Nov 7, 2025 •

Copy link
Copy Markdown
Member

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.

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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 PolyTypeJsonFormatter as a new formatter option with PolyType-based serialization
  • Refactors RequestIdJsonConverter into a shared RequestIdSTJsonConverter for 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

Comment thread src/StreamJsonRpc/IGenericTypeArgAssist.cs
Comment thread src/StreamJsonRpc/RequestIdSTJsonConverter.cs Outdated
Comment thread test/StreamJsonRpc.Tests/PolyTypeJsonFormatterTests.cs
Comment thread test/StreamJsonRpc.Tests/MarshalableProxyPolyTypeJsonTests.cs
Comment thread test/StreamJsonRpc.Tests/JsonRpcPolyTypeJsonHeadersTests.cs
Comment thread src/StreamJsonRpc/PolyTypeJsonFormatter.cs
Comment thread src/StreamJsonRpc/PolyTypeJsonFormatter.cs
Comment thread src/StreamJsonRpc/PolyTypeJsonFormatter.cs
Comment thread src/StreamJsonRpc/PolyTypeJsonFormatter.cs
Comment thread src/StreamJsonRpc/PolyTypeJsonFormatter.cs Outdated
Comment thread src/StreamJsonRpc/PolyTypeJsonFormatter.cs Outdated
Comment thread src/StreamJsonRpc/PolyTypeJsonFormatter.cs Outdated
Comment thread src/StreamJsonRpc/PolyTypeJsonFormatter.cs Outdated
Comment thread test/StreamJsonRpc.Tests/PolyTypeJsonFormatterTests.cs Outdated

@etvorun ET (etvorun) left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

:shipit:

@AArnott
Andrew Arnott (AArnott) merged commit 2e4520d into main Nov 7, 2025
9 checks passed
@AArnott
Andrew Arnott (AArnott) deleted the dev/andarno/stjNativeAotSafe branch November 7, 2025 19:07
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.

3 participants