[release/11.0] Add incremental chunked reading to CborReader - #134374
Merged
Merged
Conversation
- In non-final mode, `PeekState()` returns `NeedsMoreData` when the next token is incomplete in the buffer; any other state guarantees the single-token read won't fail on end of data. Multi-token reads (indefinite-length strings, `ReadEncodedValue`, semantic tag readers) still throw on truncation and restore the reader state, so the caller can slide in more data and retry. - `SlideData` replaces the buffer and preserves nesting state; the caller must keep the unread bytes (`BytesRemaining`) at the start of the new buffer. Only the length is validated. - Non-final mode is Lax-only in this version (per the proposal): other conformance modes track map keys by buffer offset, which cannot survive a slide. The validation is centralized so a future all-modes implementation has one place to rebase that bookkeeping. - Final-block readers (all existing constructors and `Reset(data)`) are behaviorally unchanged. Notes for reviewers: - In non-final mode, reading at a root-value boundary throws `CborContentException` rather than `InvalidOperationException`, since the reader can't know the sequence ended until the final block arrives. - Found but not fixed here: a root sequence ending in a dangling tag reports `Finished`, though it isn't well-formed. This predates this change; incremental readers deliberately match it for consistency. I think we should track it separately and will create an issue for it.
|
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-formats-cbor, @bartonjs, @vcsjones |
bartonjs
approved these changes
Sep 21, 2026
Member
|
@artl93 As of 3:47pm (PDT), CI has already run the System.Formats.Cbor tests on the .NET Framework leg and the net11-linux-Debug-arm64-Mono leg, where it fully passed. Those platforms have also run System.Security.Cryptography.Cose (the only downstream library), which also passed. Since this library has no platform specific behaviors, including doing no inherent I/O, I don't see any way that it would fail from here. At this point /ba-g to mark it mergeable is pretty safe. |
Member
|
/ba-g The tests have run on enough platforms that we're confident at this point. |
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 #133602 to release/11.0
/cc @bartonjs @muhammad-othman
Customer Impact
New API for .NET 11 to support processing a CBOR payload without forcing the whole document into contiguous memory.
Regression
Testing
Existing tests show that the existing "non-streaming" model works exactly as before, and the new tests confirm the behavior of the new "streaming" model.
Risk
Low. The test coverage says existing callers are unaffected, and the new behaviors are only visible to callers who use the new API.