Make ReadOnlySequenceStream non-seekable to match net11 - #580
Merged
Conversation
ReadOnlySequenceStream shipped seekable in dotnet/runtime#126669, which is what the polyfill was written against. dotnet/runtime#132023 then made it intentionally non-seekable and removed its seek state and traversal logic, so all ten tests failed on the net11 leg while passing everywhere else. Upstream rationale: backward positioning requires re-walking segments from the start, and ReadOnlySequence<T> segment boundaries can be indirectly controlled by an untrusted network client through packet framing, so repeated seeks are worst case O(N) under adversarial fragmentation. CanSeek now returns false, and Length, Position and Seek throw NotSupportedException. The long position field and the MoveTo rewind logic are gone; the SequencePosition cursor is the only state and only moves forward. ReadByte, CopyTo and CopyToAsync test remaining.IsEmpty instead of comparing against the sequence length. Tests replace the six seek based cases with SeekingThrows (all six seek entry points) and ReadsAreForwardOnly (a failed seek must not disturb the cursor); position assertions elsewhere become drain checks. Verified against the real net11 type with a reflection and behaviour probe. StringStream, ReadOnlyMemoryStream and WritableMemoryStream were checked the same way and already match: StringStream was never seekable, and the two memory streams stay seekable.
This was referenced Sep 10, 2026
This was referenced Sep 11, 2026
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.
ReadOnlySequenceStream shipped seekable in dotnet/runtime#126669, which is what the polyfill was written against. dotnet/runtime#132023 then made it intentionally non-seekable and removed its seek state and traversal logic, so all ten tests failed on the net11 leg while passing everywhere else.
Upstream rationale: backward positioning requires re-walking segments from the start, and ReadOnlySequence segment boundaries can be indirectly controlled by an untrusted network client through packet framing, so repeated seeks are worst case O(N) under adversarial fragmentation.
CanSeek now returns false, and Length, Position and Seek throw NotSupportedException. The long position field and the MoveTo rewind logic are gone; the SequencePosition cursor is the only state and only moves forward. ReadByte, CopyTo and CopyToAsync test remaining.IsEmpty instead of comparing against the sequence length.
Tests replace the six seek based cases with SeekingThrows (all six seek entry points) and ReadsAreForwardOnly (a failed seek must not disturb the cursor); position assertions elsewhere become drain checks.
Verified against the real net11 type with a reflection and behaviour probe. StringStream, ReadOnlyMemoryStream and WritableMemoryStream were checked the same way and already match: StringStream was never seekable, and the two memory streams stay seekable.