Conversation
…d TextWriter Co-authored-by: Tyrrrz <1935960+Tyrrrz@users.noreply.github.com>
Copilot
AI
changed the title
[WIP] Update DisposeAsync to call FlushAsync before Dispose
Call FlushAsync before Dispose in DisposeAsync polyfills for Stream and TextWriter
Feb 27, 2026
Tyrrrz
reviewed
Feb 27, 2026
… review feedback Co-authored-by: Tyrrrz <1935960+Tyrrrz@users.noreply.github.com>
Contributor
There was a problem hiding this comment.
Pull request overview
This PR updates the NetCore30 DisposeAsync polyfills for Stream and TextWriter to perform an async flush before synchronous disposal in the fallback path (when IAsyncDisposable isn’t available), and adds tests intended to validate the behavior.
Changes:
- Update
Stream.DisposeAsyncpolyfill toawait FlushAsync()and thenDispose()infinally. - Update
TextWriter.DisposeAsyncpolyfill similarly. - Add new unit tests for
DisposeAsynconStreamandTextWriter.
Reviewed changes
Copilot reviewed 3 out of 3 changed files in this pull request and generated 4 comments.
| File | Description |
|---|---|
| PolyShim/NetCore30/Stream.cs | Replace Task.Run(Dispose) fallback with FlushAsync + Dispose in finally. |
| PolyShim/NetCore30/TextWriter.cs | Replace Task.Run(Dispose) fallback with FlushAsync + Dispose in finally. |
| PolyShim.Tests/NetCore30/StreamTests.cs | Adds tests for DisposeAsync and “flushes data” scenario. |
| PolyShim.Tests/NetCore30/TextWriterTests.cs | Adds tests for DisposeAsync and “flushes data” scenario. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
FlushAsync before Dispose in DisposeAsync polyfills for Stream and TextWriter
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## master #84 +/- ##
============================
============================
☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
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.
PolyShim/NetCore30/Stream.cs– callFlushAsyncbeforeDisposein theDisposeAsyncfallback path (with try/finally to guarantee disposal)PolyShim/NetCore30/TextWriter.cs– callFlushAsyncbeforeDisposein theDisposeAsyncfallback path (with try/finally to guarantee disposal)PolyShim.Tests/NetCore30/StreamTests.cs– single focusedDisposeAsync_Testusing aBufferedStreamwithWriteAsync, verifying data is flushed before disposalPolyShim.Tests/NetCore30/TextWriterTests.csper review feedbackOriginal prompt
DisposeAsyncshould callFlushAsyncon types with asynchronous IO beforeDispose#83✨ Let Copilot coding agent set things up for you — coding agent works faster and does higher quality work when set up for your repo.