Repository navigation
Prepend built-in metadata for SystemTextJsonFormatter - #1558
Eric Erhardt (eerhardt) wants to merge 3 commits into
Conversation
Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
|
Azure Pipelines: There may be pipelines that require an authorized user to comment /azp run to run. |
There was a problem hiding this comment.
Copilot review overview
🟢 Approval recommended
The implementation is focused, documented, and comprehensively covers the relevant resolver, cancellation, and NativeAOT scenarios.
Review effort: Balanced
Findings: None
What changed in this PR
Adds deferred built-in System.Text.Json metadata fallback, enabling cancellation serialization with application-defined source-generation contexts while preserving resolver precedence.
Changes:
- Lazily appends built-in metadata and freezes serializer options on first use.
- Adds formatter, cancellation, and NativeAOT regression coverage.
- Documents resolver-chain and reflection-fallback behavior.
| File | Description |
|---|---|
src/StreamJsonRpc/SystemTextJsonFormatter.cs |
Implements deferred built-in metadata fallback. |
test/StreamJsonRpc.Tests/SystemTextJsonFormatterTests.cs |
Tests resolver precedence and options behavior. |
test/StreamJsonRpc.Tests/JsonRpcSystemTextJsonHeadersTests.cs |
Tests remote cancellation with generated metadata. |
test/NativeAOTCompatibility.Test/SystemTextJson.cs |
Adds NativeAOT RequestId coverage. |
docfx/docs/nativeAOT.md |
Documents metadata resolver requirements. |
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
Remove lazy serializer options preparation and allow subsequent resolver changes to override registration. Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
|
/azp run |
|
Azure Pipelines: Successfully started running 1 pipeline(s). |
Andrew Arnott (AArnott)
left a comment
There was a problem hiding this comment.
Recalling my prior approval because I now see that my concern about a breaking change is proven by your having to change the tests and sample so they keep working.
I'm still evaluating.
Andrew Arnott (AArnott)
left a comment
There was a problem hiding this comment.
Approved. I was mistaken about the breaking change, as I thought the change was in the library when it was only in a sample.
Can you resolve the merge conflict though?
Summary
MassageUserDataSerializerOptionswhen the formatter is constructed or assigned options. Cancellation parameters work even when the application's context omitsRequestId.TypeInfoResolverremoves the built-in registration. NoLazy, custom locking, or deferred options preparation.JsonSerializerOptions = new() { TypeInfoResolver = MyContext.Default }.Related to #1407. This PR contains only automatic metadata registration. Making
RequestIdSTJsonConverterpublic and testing direct consumer source generation is isolated in #1557. The converter remains internal here; both changes targetmainindependently.Validation
TestCategory=FailsInCloudTest).RequestId.