private new Expression <TDelegate> Build()
        {
            var body = base.Build();

            if (body.Type != taskType)
            {
                body = body.AddEpilogue(taskType.HasResult, new AsyncResultExpression(taskType));
            }
            Expression <TDelegate> lambda;

            using (var builder = new AsyncStateMachineBuilder <TDelegate>(Parameters))
            {
                lambda = builder.Build(body, tailCall);
            }

            // build lambda expression
            if (!(recursion is null))
            {
                lambda = Expression.Lambda <TDelegate>(
                    Expression.Block(
                        Sequence.Singleton(recursion),
                        Expression.Assign(recursion, lambda),
                        Expression.Invoke(recursion, Parameters)), Parameters);
            }

            return(lambda);
        }
        internal AsyncStateMachineBuilder(IReadOnlyList <ParameterExpression> parameters)
        {
            var invokeMethod = DelegateType.GetInvokeMethod <TDelegate>();

            methodBuilder = new AsyncStateMachineBuilder(invokeMethod.ReturnType, parameters);
        }