[release/11.0] Use streaming serialization for JSONL entries - #134593
Merged
Merged
Conversation
The newly introduced JSONL serialization APIs weren't using streaming serialization when serializing individual elements. This changes fixes that issue. Should be backported to .NET 11. Copilot-Session: 2d9038d0-a532-4707-8446-e46cbbf53858
|
Azure Pipelines: Successfully started running 3 pipeline(s). 13 pipeline(s) were filtered out due to trigger conditions. There may be pipelines that require an authorized user to comment /azp run to run. |
Contributor
|
Tagging subscribers to this area: @dotnet/area-system-text-json |
eiriktsarpalis
requested review from
artl93 and
jozkee
and
a lite review from Copilot
September 24, 2026 15:51
Contributor
There was a problem hiding this comment.
Copilot review overview
🔵 Needs a closer look
The changes affect core serialization and streaming behavior across multiple APIs and warrant final human review.
Review effort: Lite
Findings: None
What changed in this PR
Backports streaming JSONL serialization improvements for large and asynchronously serialized elements.
Changes:
- Routes Stream and PipeWriter JSONL serialization through the streaming pipeline.
- Preserves flushing, cancellation, backpressure, and writer ownership.
- Adds coverage for nested async enumerables, failures, metadata, and source generation.
| File | Description |
|---|---|
src/libraries/System.Text.Json/tests/Common/AsyncEnumerableTests.cs |
Adds coverage for streaming JSONL scenarios. |
src/libraries/System.Text.Json/src/System/Text/Json/Serialization/Metadata/JsonTypeInfoOfT.WriteHelpers.cs |
Supports streaming JSONL element serialization. |
src/libraries/System.Text.Json/src/System/Text/Json/Serialization/Metadata/JsonTypeInfo.cs |
Updates the internal serialization contract. |
src/libraries/System.Text.Json/src/System/Text/Json/Serialization/JsonSerializer.Write.Stream.cs |
Routes stream JSONL serialization through the streaming path. |
src/libraries/System.Text.Json/src/System/Text/Json/Serialization/JsonSerializer.Write.Pipe.cs |
Applies streaming serialization to PipeWriter JSONL entries. |
jozkee
approved these changes
Sep 24, 2026
Member
|
Approved via email. |
Member
|
@eiriktsarpalis - can you check build analysis? |
Member
|
/ba-g test failure is unrelated |
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.
Backport of #134554 to release/11.0
/cc @eiriktsarpalis
Customer Impact
The newly introduced
JsonSerializer.SerializeAsyncEnumerablemethods were using non-streaming serialization instead of streaming serialization when handling individual JSONL elements. This resulted in the following issues:Regression
Testing
Added relevant testing covering the impacted scenaria.
Risk
Low. Makes a straightforward change to product code so that the streaming serialization is used instead.