public override SyntaxNode VisitYieldStatement(YieldStatementSyntax node) { SyntaxToken keyword = node.ReturnOrBreakKeyword; ExpressionSyntax expression = node.Expression; SyntaxKind kind = node.Kind(); if (kind == SyntaxKind.YieldReturnStatement) { ParenthesizedExpressionSyntax parenthesizedExpression = expression .Parenthesize(moveTrivia: true) .WithSimplifierAnnotation(); CastExpressionSyntax castExpression = CastExpression( _typeSymbol.ToMinimalTypeSyntax(_semanticModel, node.SpanStart), parenthesizedExpression); InvocationExpressionSyntax invocationExpression = SimpleMemberInvocationExpression( _identifierName, _addName, Argument(castExpression.WithSimplifierAnnotation())); return(ExpressionStatement(invocationExpression.WithoutTrivia()) .WithTriviaFrom(node) .AppendToLeadingTrivia(node.DescendantTrivia(TextSpan.FromBounds(keyword.Span.End, expression.Span.Start)))); } else if (kind == SyntaxKind.YieldBreakStatement) { return(ReturnStatement( Token(keyword.LeadingTrivia, SyntaxKind.ReturnKeyword, keyword.TrailingTrivia), _identifierName, node.SemicolonToken)); } Debug.Fail(node.Kind().ToString()); return(base.VisitYieldStatement(node)); }