public static async Task <Document> RefactorAsync( Document document, LiteralExpressionSyntax literalExpression, CancellationToken cancellationToken) { InvocationExpressionSyntax newNode = CSharpFactory.NameOf(literalExpression.Token.ValueText) .WithFormatterAnnotation(); return(await document.ReplaceNodeAsync(literalExpression, newNode, cancellationToken).ConfigureAwait(false)); }
private static async Task <Document> UseNameOfOperatorAsync( Document document, LiteralExpressionSyntax literalExpression, CancellationToken cancellationToken) { SyntaxNode oldRoot = await document.GetSyntaxRootAsync(cancellationToken).ConfigureAwait(false); InvocationExpressionSyntax newNode = CSharpFactory.NameOf(literalExpression.Token.ValueText) .WithFormatterAnnotation(); SyntaxNode newRoot = oldRoot.ReplaceNode(literalExpression, newNode); return(document.WithSyntaxRoot(newRoot)); }