protected virtual AdapterInvocationInformation PrepareAdapterInvocationInformation(MethodInfo adapterMethod, MethodInfo targetMethod, Type[] adapterMethodParameterTypes, Type[] targetMethodParmeterTypes) { Type targetMethodReturnType = targetMethod.ReturnType; // Task<> if (AdapterHelper.IsGenericTask(targetMethodReturnType)) { MethodInfo genericInvokeTargetGenericTaskAsyncMethod = _invokeTargetGenericTaskAsync_Method.MakeGenericMethod(adapterMethod.ReturnType.GenericTypeArguments[0]); InvocationTypes targetInvocationType = InvocationTypes.GenericTask; AssertReturnTypeCombination(adapterMethod, targetMethod, targetInvocationType); return(new AdapterInvocationInformation(targetMethod, adapterMethodParameterTypes, targetMethodParmeterTypes, targetInvocationType, genericInvokeTargetGenericTaskAsyncMethod)); } // Task else if (AdapterHelper.IsTask(targetMethodReturnType)) { InvocationTypes targetInvocationType = InvocationTypes.Task; AssertReturnTypeCombination(adapterMethod, targetMethod, targetInvocationType); return(new AdapterInvocationInformation(targetMethod, adapterMethodParameterTypes, targetMethodParmeterTypes, targetInvocationType)); } // ValueTask<> else if (AdapterHelper.IsGenericValueTask(targetMethodReturnType)) { MethodInfo genericInvokeTargetGenericValueTaskAsyncMethod = _invokeTargetGenericValueTaskAsync_Method.MakeGenericMethod(adapterMethod.ReturnType.GenericTypeArguments[0]); InvocationTypes targetInvocationType = InvocationTypes.GenericValueTask; AssertReturnTypeCombination(adapterMethod, targetMethod, targetInvocationType); return(new AdapterInvocationInformation(targetMethod, adapterMethodParameterTypes, targetMethodParmeterTypes, targetInvocationType, genericInvokeTargetGenericValueTaskAsyncMethod)); } // ValueTask else if (AdapterHelper.IsValueTask(targetMethodReturnType)) { InvocationTypes targetInvocationType = InvocationTypes.ValueTask; AssertReturnTypeCombination(adapterMethod, targetMethod, targetInvocationType); return(new AdapterInvocationInformation(targetMethod, adapterMethodParameterTypes, targetMethodParmeterTypes, targetInvocationType)); } else // Likely synchronous { InvocationTypes targetInvocationType = InvocationTypes.Sync; AssertReturnTypeCombination(adapterMethod, targetMethod, targetInvocationType); return(new AdapterInvocationInformation(targetMethod, adapterMethodParameterTypes, targetMethodParmeterTypes, targetInvocationType)); } }