diff --git a/src/Hyperbee.AsyncExpressions/StateMachineBuilder.cs b/src/Hyperbee.AsyncExpressions/StateMachineBuilder.cs index aa017be..6a2581b 100644 --- a/src/Hyperbee.AsyncExpressions/StateMachineBuilder.cs +++ b/src/Hyperbee.AsyncExpressions/StateMachineBuilder.cs @@ -250,9 +250,9 @@ private static bool TryGetAwaiterType( Expression expr, out Type awaiterType ) static Type GetAwaiterType( Type taskType ) { - var genericArgument = taskType.IsGenericType ? taskType.GetGenericArguments()[0] : typeof(void); + var genericArgument = taskType.IsGenericType ? taskType.GetGenericArguments()[0] : null; - if ( genericArgument == typeof(void) || genericArgument.FullName == "System.Threading.Tasks.VoidTaskResult" ) + if ( genericArgument == null || genericArgument.FullName == "System.Threading.Tasks.VoidTaskResult" ) { return typeof(ConfiguredTaskAwaitable.ConfiguredTaskAwaiter); }