Class AsyncUtility
Utility class for dealing with asynchronous operations.
public static class AsyncUtility
- Inheritance
-
AsyncUtility
- Inherited Members
Methods
IsAsync(MethodInfo)
Determines if the given method is async, as matters to xUnit.net. This means it either (a) returns a Task or ValueTask; or, (b) it is an F# function which was declared as async. Note that this is not the same thing as an "awaitable" method, since xUnit.net does not recreate the compiler's await machinery at runtime.
public static bool IsAsync(MethodInfo method)
Parameters
methodMethodInfoThe method to test
Returns
- bool
Returns
trueif the method is async; returnsfalseotherwise.
IsAsyncVoid(MethodInfo)
Determines if the given method is async void by looking for the AsyncStateMachineAttribute and void return type on the method definition.
public static bool IsAsyncVoid(MethodInfo method)
Parameters
methodMethodInfoThe method to test
Returns
- bool
Returns
trueif the method is async void; returnsfalseotherwise.
TryConvertToValueTask(object?)
Given an object, will attempt to convert instances of Task or
Microsoft.FSharp.Control.FSharpAsync`1 into ValueTask
as appropriate. Will return null if the object is not a task of any supported type.
Note that this list of supported tasks is purposefully identical to the list used
by IsAsync(MethodInfo).
public static ValueTask? TryConvertToValueTask(object? obj)
Parameters
objobjectThe object to convert