Skip to content

Conversation

@gewarren
Copy link
Contributor

@gewarren gewarren commented Jan 12, 2026

@gewarren gewarren requested a review from a team as a code owner January 12, 2026 16:29
Copilot AI review requested due to automatic review settings January 12, 2026 16:29
@dotnetrepoman dotnetrepoman bot added this to the January 2026 milestone Jan 12, 2026
@gewarren gewarren enabled auto-merge (squash) January 12, 2026 16:30
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

This PR reverts a previous change (PR #50900) that incorrectly removed the Dispose(disposing: false) call from the DisposeAsync method. The original removal broke the dispose pattern by preventing unmanaged resources in derived classes from being properly disposed when using async disposal. This revert restores the correct implementation pattern.

Changes:

  • Restores Dispose(disposing: false) call in DisposeAsync() method in the code example
  • Adds documentation explaining why Dispose(false) must be called in the async dispose pattern
  • Adds a NOTE section clarifying the difference between calling Dispose(false) in DisposeAsync vs Dispose(true) in Dispose

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 1 comment.

File Description
docs/standard/garbage-collection/snippets/dispose-async/ExampleConjunctiveDisposable.cs Restores the Dispose(disposing: false) call in the DisposeAsync method to ensure unmanaged resources are properly disposed
docs/standard/garbage-collection/implementing-disposeasync.md Adds documentation explaining the correct async dispose pattern, including the rationale for calling Dispose(false) instead of Dispose(true)

{
// Perform async cleanup.
await DisposeAsyncCore().ConfigureAwait(false);
await DisposeAsyncCore();
Copy link

Copilot AI Jan 12, 2026

Choose a reason for hiding this comment

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

The example code in line 45 should use .ConfigureAwait(false) after DisposeAsyncCore(). The code snippet shows await DisposeAsyncCore(); but the correct pattern demonstrated throughout the rest of the document and in the actual implementation file uses await DisposeAsyncCore().ConfigureAwait(false); to avoid capturing the synchronization context unnecessarily.

Suggested change
await DisposeAsyncCore();
await DisposeAsyncCore().ConfigureAwait(false);

Copilot uses AI. Check for mistakes.
@gewarren gewarren requested a review from IEvangelist January 13, 2026 18:33
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Example does no longer implement dispose pattern correctly and unmanaged resources are no longer disposed

2 participants