public static Task <Document> RefactorAsync( Document document, ConditionalExpressionSyntax conditionalExpression, CancellationToken cancellationToken) { ExpressionSyntax condition = conditionalExpression.Condition; ExpressionSyntax whenTrue = conditionalExpression.WhenTrue; ExpressionSyntax whenFalse = conditionalExpression.WhenFalse; SyntaxToken questionToken = conditionalExpression.QuestionToken; SyntaxToken colonToken = conditionalExpression.ColonToken; var writer = new NodeWriter(conditionalExpression); writer.WriteLeadingTrivia(); writer.WriteSpan(condition); Write(condition, whenTrue, questionToken, "? ", writer); Write(whenTrue, whenFalse, colonToken, ": ", writer); writer.WriteTrailingTrivia(); ExpressionSyntax newNode = SyntaxFactory.ParseExpression(writer.ToString()); return(document.ReplaceNodeAsync(conditionalExpression, newNode, cancellationToken)); }