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

Add PolyTypeJsonFormatter as an experimental API#1344
Andrew Arnott (AArnott) merged 1 commit into
mainfrom
dev/andarno/stjNativeAotSafe

Conversation

@AArnott

@AArnottAndrew 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.

CopilotAI 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
FileDescription
src/StreamJsonRpc/PolyTypeJsonFormatter.csNew formatter implementation with PolyType support and experimental attribute
src/StreamJsonRpc/RequestIdSTJsonConverter.csExtracted RequestId converter for System.Text.Json reuse
src/StreamJsonRpc/SourceGenerationContext.csSource generation context for built-in types
src/StreamJsonRpc/IGenericTypeArgAssist.csHelper interfaces for generic type argument handling
src/StreamJsonRpc/RequestId.csAdded System.Text.Json converter attribute
src/StreamJsonRpc/SystemTextJsonFormatter.csRefactored to use shared RequestIdSTJsonConverter
src/StreamJsonRpc/StreamJsonRpc.csprojWhitespace formatting fixes
test filesTest classes for PolyTypeJsonFormatter covering various scenarios
Comments suppressed due to low confidence (2)

src/StreamJsonRpc/PolyTypeJsonFormatter.cs:1347

Comment threadsrc/StreamJsonRpc/IGenericTypeArgAssist.cs
Comment threadsrc/StreamJsonRpc/RequestIdSTJsonConverter.cs Outdated
Comment threadtest/StreamJsonRpc.Tests/PolyTypeJsonFormatterTests.cs
Comment threadtest/StreamJsonRpc.Tests/JsonRpcPolyTypeJsonHeadersTests.cs
Comment threadsrc/StreamJsonRpc/PolyTypeJsonFormatter.cs
Comment threadsrc/StreamJsonRpc/PolyTypeJsonFormatter.cs
Comment threadsrc/StreamJsonRpc/PolyTypeJsonFormatter.cs
Comment threadsrc/StreamJsonRpc/PolyTypeJsonFormatter.cs
Comment threadsrc/StreamJsonRpc/PolyTypeJsonFormatter.cs Outdated
Comment threadsrc/StreamJsonRpc/PolyTypeJsonFormatter.cs Outdated
Comment threadsrc/StreamJsonRpc/PolyTypeJsonFormatter.cs Outdated
Comment threadsrc/StreamJsonRpc/PolyTypeJsonFormatter.cs Outdated
Comment threadtest/StreamJsonRpc.Tests/PolyTypeJsonFormatterTests.cs Outdated

@etvorunET (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:

Sign up for freeto 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

@AArnott@etvorun