예제 #1
0
        public static bool TryRemoveAttributeSuffix(ISymbol symbol, SyntaxContext context, [NotNullWhen(true)] out string?name)
        {
            var isAttributeNameContext = context.IsAttributeNameContext;
            var syntaxFacts            = context.GetRequiredLanguageService <ISyntaxFactsService>();

            if (!isAttributeNameContext)
            {
                name = null;
                return(false);
            }

            // Do the symbol textual check first. Then the more expensive symbolic check.
            if (!symbol.Name.TryGetWithoutAttributeSuffix(syntaxFacts.IsCaseSensitive, out name) ||
                !symbol.IsAttribute())
            {
                return(false);
            }

            return(true);
        }