private static Task <Document> ToInterpolatedStringAsync( Document document, StringConcatenationExpressionInfo concatenationInfo, CancellationToken cancellationToken) { InterpolatedStringExpressionSyntax newExpression = concatenationInfo.ToInterpolatedString(); return(RefactorAsync(document, concatenationInfo, newExpression, cancellationToken)); }
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); if (concatenationInfo.Success) { ExpressionSyntax newNode = null; if (concatenationInfo.ContainsLiteralExpression) { if (concatenationInfo.ContainsVerbatim && ContainsMultiLine(concatenationInfo, cancellationToken)) { newNode = concatenationInfo.ToMultilineStringLiteral(); } else { newNode = concatenationInfo.ToStringLiteral(); } } else { newNode = concatenationInfo.ToInterpolatedString(); } newNode = newNode.WithTriviaFrom(binaryExpression); return(await document.ReplaceNodeAsync(binaryExpression, newNode, cancellationToken).ConfigureAwait(false)); } Debug.Fail(binaryExpression.ToString()); return(document); }