Skip to content

Allow Flush as no-op on read-only streams - #919

Merged
AArnott merged 1 commit into
mainfrom
copilot/fix-read-only-stream-flush
Feb 9, 2026
Merged

AArnott merged 1 commit into
mainfrom
copilot/fix-read-only-stream-flush

Conversation

Copilot AI commented Feb 9, 2026 •

Copy link
Copy Markdown
Contributor

Read-only streams (SubstreamReader, NestedStream, ReadOnlySequenceStream) were throwing NotSupportedException on Flush operations. Per dotnet/runtime#105592 and #110899, they should allow Flush as a no-op.

Changes

  • Stream implementations: Modified Flush() and FlushAsync() to check disposal state and return immediately instead of throwing NotSupportedException
  • Tests: Updated to verify Flush succeeds on active streams while still throwing ObjectDisposedException when disposed

Example

Before:

var stream = underlyingStream.ReadSubstream();
stream.Flush(); // Throws NotSupportedException

After:

var stream = underlyingStream.ReadSubstream();
stream.Flush(); // No-op, succeeds

Implementation uses Task.CompletedTask (.NET 5+) or Task.FromResult(0) for async variants.

Original prompt

This section details on the original issue you should resolve

<issue_title>Read-Only streams should do nothing in Flush</issue_title>
<issue_description>Instead of throwing, streams should allow flush as a no-op.

See also dotnet/runtime#105592 and dotnet/runtime#110899.

Currently, SubstreamReader, NestedStream, ReadOnlySequenceStream explicitly throw NotSupportedException instead</issue_description>

Comments on the Issue (you are @copilot in this section)


💬 We'd love your input! Share your thoughts on Copilot coding agent in our 2 minute survey.

Copilot AI changed the title [WIP] Fix read-only streams to allow no-op flush Allow Flush as no-op on read-only streams Feb 9, 2026
Copilot AI requested a review from AArnott February 9, 2026 02:15
Changed SubstreamReader, NestedStream, and ReadOnlySequenceStream to allow Flush/FlushAsync as no-ops instead of throwing NotSupportedException. Updated corresponding tests.

Co-authored-by: AArnott <3548+AArnott@users.noreply.github.com>
@AArnott
AArnott force-pushed the copilot/fix-read-only-stream-flush branch from 17caf51 to 1ab45e0 Compare February 9, 2026 03:41
@AArnott
AArnott marked this pull request as ready for review February 9, 2026 03:41
@AArnott
AArnott enabled auto-merge February 9, 2026 03:41
@AArnott
AArnott added this pull request to the merge queue Feb 9, 2026
Merged via the queue into main with commit cc0d06f Feb 9, 2026
11 of 12 checks passed
@AArnott
AArnott deleted the copilot/fix-read-only-stream-flush branch February 9, 2026 05:15
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Read-Only streams should do nothing in Flush

2 participants