File: Internal\AsyncDisposableExtensions.cs
Web Access
Project: src\src\SignalR\server\Core\src\Microsoft.AspNetCore.SignalR.Core.csproj (Microsoft.AspNetCore.SignalR.Core)
// Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT license.
 
namespace Microsoft.AspNetCore.SignalR.Internal;
 
internal static class AsyncDisposableExtensions
{
    // Does a light up check to see if a type is IAsyncDisposable and calls DisposeAsync if it is
    public static ValueTask DisposeAsync(this IDisposable disposable)
    {
        if (disposable is IAsyncDisposable asyncDisposable)
        {
            return asyncDisposable.DisposeAsync();
        }
        disposable.Dispose();
        return default;
    }
}