Skip to content

[release/11.0] Add incremental chunked reading to CborReader - #134374

Merged
artl93 merged 1 commit into
release/11.0from
backport/pr-133602-to-release/11.0
Sep 21, 2026
Merged

artl93 merged 1 commit into
release/11.0from
backport/pr-133602-to-release/11.0

Conversation

@github-actions

@github-actions github-actions Bot commented Sep 21, 2026 •

Copy link
Copy Markdown
Contributor

Backport of #133602 to release/11.0

/cc @bartonjs @muhammad-othman

Customer Impact

  • Customer reported
  • Found internally

New API for .NET 11 to support processing a CBOR payload without forcing the whole document into contiguous memory.

Regression

  • Yes
  • No

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.

- 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

Copy link
Copy Markdown
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.

@dotnet-policy-service

Copy link
Copy Markdown
Contributor

Tagging subscribers to this area: @dotnet/area-system-formats-cbor, @bartonjs, @vcsjones
See info in area-owners.md if you want to be subscribed.

@artl93
artl93 self-requested a review September 21, 2026 21:47
@artl93 artl93 closed this Sep 21, 2026
@artl93 artl93 reopened this Sep 21, 2026

@artl93 artl93 left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Approved

@artl93 artl93 added the Servicing-approved Approved for servicing release label Sep 21, 2026
@bartonjs

Copy link
Copy Markdown
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.

@bartonjs

Copy link
Copy Markdown
Member

/ba-g The tests have run on enough platforms that we're confident at this point.

@artl93
artl93 merged commit 059b84a into release/11.0 Sep 21, 2026
77 of 100 checks passed
@artl93
artl93 deleted the backport/pr-133602-to-release/11.0 branch September 21, 2026 22:55
@dotnet-milestone-bot dotnet-milestone-bot Bot added this to the 11.0-rc2 milestone Sep 22, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants