Exemple #1
0
        private static async Task <Document> AddParameterNameToArgumentsAsync(
            Document document,
            AttributeArgumentListSyntax argumentList,
            AttributeArgumentSyntax[] arguments,
            CancellationToken cancellationToken = default)
        {
            SemanticModel semanticModel = await document.GetSemanticModelAsync(cancellationToken).ConfigureAwait(false);

            AttributeArgumentListSyntax newArgumentList = AddParameterNameSyntaxRewriter.VisitNode(argumentList, arguments, semanticModel)
                                                          .WithFormatterAnnotation();

            return(await document.ReplaceNodeAsync(argumentList, newArgumentList, cancellationToken).ConfigureAwait(false));
        }
        private static async Task <Document> AddParameterNameToArgumentsAsync(
            Document document,
            ArgumentListSyntax argumentList,
            ImmutableArray <ArgumentSyntax> arguments,
            CancellationToken cancellationToken = default(CancellationToken))
        {
            SyntaxNode oldRoot = await document.GetSyntaxRootAsync(cancellationToken).ConfigureAwait(false);

            SemanticModel semanticModel = await document.GetSemanticModelAsync(cancellationToken).ConfigureAwait(false);

            ArgumentListSyntax newArgumentList = AddParameterNameSyntaxRewriter.VisitNode(argumentList, arguments, semanticModel)
                                                 .WithFormatterAnnotation();

            SyntaxNode newRoot = oldRoot.ReplaceNode(argumentList, newArgumentList);

            return(document.WithSyntaxRoot(newRoot));
        }
        private static async Task <Document> AddParameterNameToEachArgumentAsync(
            Document document,
            ArgumentListSyntax argumentList,
            ArgumentSyntax[] arguments,
            CancellationToken cancellationToken)
        {
            SyntaxNode oldRoot = await document.GetSyntaxRootAsync(cancellationToken);

            SemanticModel semanticModel = await document.GetSemanticModelAsync(cancellationToken);

            ArgumentListSyntax newArgumentList = AddParameterNameSyntaxRewriter.VisitNode(argumentList, arguments, semanticModel)
                                                 .WithAdditionalAnnotations(Formatter.Annotation);

            SyntaxNode newRoot = oldRoot.ReplaceNode(argumentList, newArgumentList);

            return(document.WithSyntaxRoot(newRoot));
        }