Skip to content

Fix dispose methods to always set _isDisposed and call base.Dispose() when LeaveOpen is true#1152

Merged
adamhathcock merged 3 commits intoadam/async-creationfrom
copilot/sub-pr-1132
Jan 22, 2026
Merged

Fix dispose methods to always set _isDisposed and call base.Dispose() when LeaveOpen is true#1152
adamhathcock merged 3 commits intoadam/async-creationfrom
copilot/sub-pr-1132

Conversation

Copy link
Contributor

Copilot AI commented Jan 22, 2026

The dispose logic in SharpCompressStream returned early when LeaveOpen was true without setting _isDisposed or calling base.Dispose(), allowing subsequent dispose calls to re-execute disposal code.

Changes:

  • Restructured Dispose() and DisposeAsync() to always set _isDisposed and call base disposal methods
  • LeaveOpen check now only guards wrapped stream disposal and buffer cleanup
  • Verified no other dispose methods in codebase have this pattern

Before:

protected override void Dispose(bool disposing)
{
    if (_isDisposed || this.LeaveOpen)
    {
        return;  // Never sets _isDisposed or calls base.Dispose() when LeaveOpen=true
    }
    _isDisposed = true;
    base.Dispose(disposing);
    // ...
}

After:

protected override void Dispose(bool disposing)
{
    if (_isDisposed)
    {
        return;
    }
    _isDisposed = true;
    base.Dispose(disposing);
    if (this.LeaveOpen)
    {
        return;  // Skip only stream disposal and buffer cleanup
    }
    // ...
}

✨ Let Copilot coding agent set things up for you — coding agent works faster and does higher quality work when set up for your repo.

Copilot AI and others added 2 commits January 22, 2026 15:50
…ase.Dispose even when LeaveOpen is true

Co-authored-by: adamhathcock <527620+adamhathcock@users.noreply.github.com>
…stent property access

Co-authored-by: adamhathcock <527620+adamhathcock@users.noreply.github.com>
Copilot AI changed the title [WIP] Address feedback on async creation cleanup and Dispose checks Fix dispose methods to always set _isDisposed and call base.Dispose() when LeaveOpen is true Jan 22, 2026
Copilot AI requested a review from adamhathcock January 22, 2026 15:54
@adamhathcock adamhathcock marked this pull request as ready for review January 22, 2026 16:39
@adamhathcock adamhathcock merged commit 16831e1 into adam/async-creation Jan 22, 2026
@adamhathcock adamhathcock deleted the copilot/sub-pr-1132 branch January 22, 2026 16:39
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.

2 participants