Skip to content

Fix FileStream.FlushAsync documentation to correctly describe its behavior #11471

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 2 commits into
base: main
Choose a base branch
from

Conversation

Copilot
Copy link
Contributor

@Copilot Copilot AI commented Jun 19, 2025

The documentation for FileStream.FlushAsync(CancellationToken) incorrectly stated that it "causes any buffered data to be written to the underlying device". This is inaccurate based on the behavior change implemented in dotnet/coreclr#24902.

Issue

The current documentation was misleading because:

  • FlushAsync() behaves like Flush()/Flush(false) - it only flushes .NET stream buffers to the file
  • It does not flush intermediate OS file buffers to the underlying storage device
  • Only Flush(true) actually performs the expensive operation of flushing OS buffers to disk

Changes

  • Updated the summary to remove "underlying device" and clarify it writes "to the file"
  • Added explicit documentation in the remarks section explaining that this method only flushes .NET stream buffers
  • Added guidance to use Flush(true) when flushing to the underlying storage device is required

This ensures developers have accurate expectations about the performance and behavior of FlushAsync() versus Flush(true).

Fixes #11433.


💬 Share your feedback on Copilot coding agent for the chance to win a $200 gift card! Click here to start the survey.

…o underlying device

Co-authored-by: jeffhandley <1031940+jeffhandley@users.noreply.github.com>
@Copilot Copilot AI changed the title [WIP] FileStream.FlushAsync(CancellationToken) doesn't actually flush to the underlying device Fix FileStream.FlushAsync documentation to correctly describe its behavior Jun 19, 2025
@Copilot Copilot AI requested a review from jeffhandley June 19, 2025 05:38
Copilot finished work on behalf of jeffhandley June 19, 2025 05:38
@jeffhandley jeffhandley marked this pull request as ready for review June 19, 2025 05:54
@jeffhandley jeffhandley requested a review from a team as a code owner June 19, 2025 05:54
@jeffhandley jeffhandley requested review from stephentoub and removed request for a team June 19, 2025 05:55
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.

FileStream.FlushAsync(CancellationToken) doesn't actually flush to the underlying device
2 participants