<PackageReference Include="Nito.AsyncEx.Tasks" Version="5.1.1" />

Nito.AsyncEx.AwaitableDisposable<T>

public struct AwaitableDisposable<T> where T : IDisposable
An awaitable wrapper around a task whose result is disposable. The wrapper is not disposable, so this prevents usage errors like "using (MyAsync())" when the appropriate usage should be "using (await MyAsync())".
namespace Nito.AsyncEx { public readonly struct AwaitableDisposable<[System.Runtime.CompilerServices.Nullable(0)] T> where T : IDisposable { public AwaitableDisposable(Task<T> task); public Task<T> AsTask(); public static implicit operator Task<T>(AwaitableDisposable<T> source); public TaskAwaiter<T> GetAwaiter(); public ConfiguredTaskAwaitable<T> ConfigureAwait(bool continueOnCapturedContext); } }