コード例 #1
0
        private static AttributeArgumentSyntax AddParameterName(
            AttributeArgumentSyntax argument,
            SemanticModel semanticModel,
            CancellationToken cancellationToken = default(CancellationToken))
        {
            if (argument.NameColon == null || argument.NameColon.IsMissing)
            {
                IParameterSymbol parameterSymbol = argument.DetermineParameter(
                    semanticModel,
                    allowParams: false,
                    cancellationToken: cancellationToken);

                if (parameterSymbol != null)
                {
                    return(argument
                           .WithNameColon(
                               NameColon(parameterSymbol.ToDisplayString(_symbolDisplayFormat))
                               .WithTrailingTrivia(Space))
                           .WithTriviaFrom(argument));
                }
            }

            return(argument);
        }