public static async Task <Document> RefactorAsync( Document document, BinaryExpressionSyntax binaryExpression, CancellationToken cancellationToken) { SemanticModel semanticModel = await document.GetSemanticModelAsync(cancellationToken).ConfigureAwait(false); StringConcatenationExpressionInfo concatenationInfo = SyntaxInfo.StringConcatenationExpressionInfo(binaryExpression, semanticModel, cancellationToken); StringConcatenationAnalysis analysis = concatenationInfo.Analyze(); ExpressionSyntax newNode; if (analysis.ContainsStringLiteral) { if (analysis.ContainsVerbatimExpression && concatenationInfo.ContainsMultiLineExpression()) { newNode = concatenationInfo.ToMultiLineStringLiteralExpression(); } else { newNode = concatenationInfo.ToStringLiteralExpression(); } } else { newNode = concatenationInfo.ToInterpolatedStringExpression(); } newNode = newNode.WithTriviaFrom(binaryExpression); return(await document.ReplaceNodeAsync(binaryExpression, newNode, cancellationToken).ConfigureAwait(false)); }
public static Task <Document> ToStringLiteralAsync( Document document, StringConcatenationExpressionInfo concatenationInfo, bool multiline, CancellationToken cancellationToken = default(CancellationToken)) { ExpressionSyntax newExpression = (multiline) ? concatenationInfo.ToMultiLineStringLiteralExpression() : concatenationInfo.ToStringLiteralExpression(); return(RefactorAsync(document, concatenationInfo, newExpression, cancellationToken)); }