private static LambdaExpressionSyntax WithBlockBody( SemanticModel semanticModel, LambdaExpressionSyntax originalDeclaration, LambdaExpressionSyntax currentDeclaration) { var expressionBody = GetBodyAsExpression(currentDeclaration); var createReturnStatementForExpression = CreateReturnStatementForExpression( semanticModel, originalDeclaration); if (!expressionBody.TryConvertToStatement( semicolonTokenOpt: null, createReturnStatementForExpression, out var statement)) { return(currentDeclaration); } // If the user is converting to a block, it's likely they intend to add multiple // statements to it. So make a multi-line block so that things are formatted properly // for them to do so. return(currentDeclaration.WithBody(SyntaxFactory.Block( SyntaxFactory.Token(SyntaxKind.OpenBraceToken).WithAppendedTrailingTrivia(SyntaxFactory.ElasticCarriageReturnLineFeed), SyntaxFactory.SingletonList(statement), SyntaxFactory.Token(SyntaxKind.CloseBraceToken)))); }