Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add ResultOf overloads for ValueTask #9

Merged
merged 1 commit into from
Dec 5, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
10 changes: 10 additions & 0 deletions MetaBrainz.Common/AsyncUtils.cs
Original file line number Diff line number Diff line change
Expand Up @@ -18,4 +18,14 @@ public static class AsyncUtils {
/// <returns>The value returned by the task when it completes.</returns>
public static T ResultOf<T>(Task<T> task) => task.ConfigureAwait(false).GetAwaiter().GetResult();

/// <summary>Synchronously awaits a task.</summary>
/// <param name="task">The task to await.</param>
public static void ResultOf(ValueTask task) => task.ConfigureAwait(false).GetAwaiter().GetResult();

/// <summary>Synchronously awaits a task.</summary>
/// <param name="task">The task to await.</param>
/// <typeparam name="T">The return type for the task.</typeparam>
/// <returns>The value returned by the task when it completes.</returns>
public static T ResultOf<T>(ValueTask<T> task) => task.ConfigureAwait(false).GetAwaiter().GetResult();

}
2 changes: 1 addition & 1 deletion MetaBrainz.Common/MetaBrainz.Common.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
<PackageCopyrightYears>2022, 2023</PackageCopyrightYears>
<PackageRepositoryName>MetaBrainz.Common</PackageRepositoryName>
<PackageTags>MetaBrainz</PackageTags>
<Version>1.0.1-pre</Version>
<Version>2.0.0-pre</Version>
</PropertyGroup>

<ItemGroup>
Expand Down