public static async Task <Document> ChangeArgumentAsync( Document document, ArgumentListSyntax argumentListNode, string newParameterName, CancellationToken cancellationToken) { // Find the Identifier Name for the first argument to Ensure.Arg. var argumentNodes = argumentListNode.DescendantNodes() .OfType <ArgumentSyntax>(); if (argumentNodes.Count() == 0) { return(document); } ArgumentSyntax newIdentifierArg = SyntaxFactory.Argument(SyntaxFactory.IdentifierName(newParameterName)); ArgumentSyntax newNameOfArg = SyntaxFactory.Argument(CreateLiteralForIdentifier(document, newParameterName)); SyntaxNode root = await document.GetSyntaxRootAsync(cancellationToken); var newRoot = root.ReplaceNode(argumentListNode, SyntaxFactory.ArgumentList( SyntaxFactory.SingletonSeparatedList(newIdentifierArg) .Add(newNameOfArg)) .AddArguments(argumentListNode.Arguments .Skip(2) .ToArray())); return(document.WithSyntaxRoot(newRoot)); }