private static async Task <Document> RefactorAsync( Document document, InvocationExpressionSyntax invocation, string propertyName = null, CancellationToken cancellationToken = default(CancellationToken)) { var memberAccess = (MemberAccessExpressionSyntax)invocation.Expression; ElementAccessExpressionSyntax elementAccess = ElementAccessExpression( memberAccess.Expression.WithoutTrailingTrivia(), BracketedArgumentList( SingletonSeparatedList( Argument(CreateArgumentExpression(invocation, memberAccess, propertyName))))); return(await document.ReplaceNodeAsync( invocation, elementAccess.WithTriviaFrom(invocation), cancellationToken).ConfigureAwait(false)); }
private static async Task <Document> RefactorAsync( Document document, InvocationExpressionSyntax invocation, string propertyName = null, CancellationToken cancellationToken = default(CancellationToken)) { SyntaxNode oldRoot = await document.GetSyntaxRootAsync(cancellationToken); var memberAccess = (MemberAccessExpressionSyntax)invocation.Expression; ElementAccessExpressionSyntax elementAccess = ElementAccessExpression( memberAccess.Expression.WithoutTrailingTrivia(), BracketedArgumentList( SingletonSeparatedList( Argument(CreateArgumentExpression(invocation, memberAccess, propertyName))))); SyntaxNode newRoot = oldRoot.ReplaceNode( invocation, elementAccess.WithTriviaFrom(invocation)); return(document.WithSyntaxRoot(newRoot)); }