Skip to content

Add AsyncDisposableExtensions#45

Merged
Tyrrrz merged 6 commits intoprimefrom
copilot/add-powerkit-package-and-remove-utils
Apr 17, 2026
Merged

Add AsyncDisposableExtensions#45
Tyrrrz merged 6 commits intoprimefrom
copilot/add-powerkit-package-and-remove-utils

Conversation

Copy link
Copy Markdown
Contributor

Copilot AI commented Apr 17, 2026

Ports AsyncDisposableExtensions from CliWrap into PowerKit as a general-purpose utility.

Changes

  • PowerKit/Extensions/AsyncDisposableExtensions.cs — adds ToAsyncDisposable() extension on IDisposable that wraps the target in an IAsyncDisposable adapter. Calls DisposeAsync() if the object also implements IAsyncDisposable, otherwise falls back to synchronous Dispose(). Useful for writing uniform await using disposal code regardless of the runtime's actual support.
  • PowerKit.Tests/AsyncDisposableExtensionsTests.cs — tests both dispatch paths.

Usage

// Works uniformly whether or not the object implements IAsyncDisposable
await using var _ = myDisposable.ToAsyncDisposable();

@Tyrrrz Tyrrrz added the enhancement New feature or request label Apr 17, 2026
@Tyrrrz Tyrrrz marked this pull request as ready for review April 17, 2026 12:20
Copilot AI review requested due to automatic review settings April 17, 2026 12:20
@codecov
Copy link
Copy Markdown

codecov Bot commented Apr 17, 2026

Codecov Report

❌ Patch coverage is 87.50000% with 3 lines in your changes missing coverage. Please review.
✅ Project coverage is 94.27%. Comparing base (e1aaff9) to head (36107b5).
⚠️ Report is 2 commits behind head on prime.

Files with missing lines Patch % Lines
PowerKit/Extensions/AsyncDisposableExtensions.cs 75.00% 1 Missing and 1 partial ⚠️
PowerKit.Tests/AsyncDisposableExtensionsTests.cs 93.75% 1 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##            prime      #45      +/-   ##
==========================================
- Coverage   94.36%   94.27%   -0.10%     
==========================================
  Files          82       84       +2     
  Lines        1740     1764      +24     
  Branches      141      143       +2     
==========================================
+ Hits         1642     1663      +21     
- Misses         72       74       +2     
- Partials       26       27       +1     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

Copy link
Copy Markdown
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

Ports an AsyncDisposableExtensions helper into PowerKit to allow uniform await using-style disposal by adapting an IDisposable into an async-disposable shape.

Changes:

  • Added ToAsyncDisposable() extension to wrap IDisposable into an async-disposable adapter that prefers IAsyncDisposable.DisposeAsync() when available.
  • Added tests intended to cover both the IAsyncDisposable and IDisposable disposal paths.

Reviewed changes

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

File Description
PowerKit/Extensions/AsyncDisposableExtensions.cs Introduces ToAsyncDisposable() and an adapter that conditionally calls DisposeAsync() vs Dispose().
PowerKit.Tests/AsyncDisposableExtensionsTests.cs Adds tests for async vs sync dispatch behavior of the adapter.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread PowerKit/Extensions/AsyncDisposableExtensions.cs Outdated
Comment thread PowerKit.Tests/AsyncDisposableExtensionsTests.cs
Tyrrrz and others added 2 commits April 17, 2026 15:24
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
@Tyrrrz
Copy link
Copy Markdown
Owner

Tyrrrz commented Apr 17, 2026

@copilot please apply formatting

Agent-Logs-Url: https://github.com/Tyrrrz/PowerKit/sessions/8a9fa2ec-9754-43d2-901f-59f99a271658

Co-authored-by: Tyrrrz <1935960+Tyrrrz@users.noreply.github.com>
Copy link
Copy Markdown
Contributor Author

Copilot AI commented Apr 17, 2026

@copilot please apply formatting

Done in 36107b5.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants