Exemple #1
0
        private BlockSyntax ForwardCall(MethodDeclarationSyntax methodNode, BlockSyntax bodyBlock)
        {
            var invocation = methodNode.ForwardCall(_methodResult.Symbol, methodNode.Identifier.ValueText);
            var block      = Block()
                             .WithCloseBraceToken(bodyBlock.CloseBraceToken)
                             .WithOpenBraceToken(bodyBlock.OpenBraceToken);

            foreach (var precondition in _methodResult.Preconditions)
            {
                block = block.AddStatements(precondition);
            }

            block = _methodResult.Symbol.ReturnsVoid
                                ? AddReturnStatement(block.AddStatements(ExpressionStatement(
                                                                             invocation.WithLeadingTrivia(TriviaList(_transformResult.BodyLeadingWhitespaceTrivia)),
                                                                             Token(TriviaList(), SyntaxKind.SemicolonToken, TriviaList(_transformResult.EndOfLineTrivia)))))
                                : block.AddStatements(ReturnStatement(
                                                          Token(TriviaList(_transformResult.BodyLeadingWhitespaceTrivia), SyntaxKind.ReturnKeyword, TriviaList(Space)),
                                                          invocation.WrapInTaskFromResult(_retunTypeSyntax, _namespaceMetadata.TaskConflict),
                                                          Token(TriviaList(), SyntaxKind.SemicolonToken, TriviaList(_transformResult.EndOfLineTrivia))));
            return(WrapInsideTryCatch(block, false));
        }