Open sandboxFocus

Struct AsyncInfo

Provides information about the async characteristics of a method, returned by the GetAsyncInfo(IMethod) extension method of IMethod.

Namespace: Metalama.Framework.Code
Assembly: Metalama.Framework.dll
Syntax
[CompileTime]
public readonly struct AsyncInfo
Remarks

Use this struct to inspect async method properties at compile time, for example in BuildAspect.

The ResultType property is particularly useful when you need the actual result type instead of the task type. For example, for a method returning Task<string>, ResultType is string.

Properties

Name Description
HasMethodBuilder

Gets a value indicating whether the return type of the method has an AsyncMethodBuilderAttribute custom attribute.

IsAsync

Gets a value indicating whether the method has an async implementation, i.e., whether it has the async modifier.

IsAwaitable

Gets a value indicating whether the return type of the method is awaitable, i.e., whether it can be used with the await keyword.

IsAwaitableOrVoid

Gets a value indicating whether the return type of the method is either awaitable (see IsAwaitable) or void.

ResultType

Gets the unwrapped result type of the async method, i.e., the type of the await expression.

See Also