Exemple #1
0
 public AttributeModel(AttributeDefinition attribute, string title, string messageFormat, string description, DiagnosticIds diagnosticId, bool canBeSuppressed, bool isEnabledByDefault)
     : this(attribute.Name, attribute.FullName, title, messageFormat, description, diagnosticId, canBeSuppressed, isEnabledByDefault)
 {
 }
 public static bool HasAttribute(AttributeListSyntax attributes, SyntaxNodeAnalysisContext context, AttributeDefinition attributeDefinition, out Location location)
 {
     return(HasAttribute(attributes, context, attributeDefinition.Name, attributeDefinition.FullName, out location));
 }
 public static bool IsAttribute(AttributeSyntax attribute, SyntaxNodeAnalysisContext context, AttributeDefinition attributeDefinition, out Location location, out AttributeArgumentSyntax argument)
 {
     return(IsAttribute(attribute, context, attributeDefinition.Name, attributeDefinition.FullName, out location, out argument));
 }
 public static bool HasAttribute(SyntaxList <AttributeListSyntax> attributeLists, SyntaxNodeAnalysisContext context, AttributeDefinition attributeDefinition, out Location location, out AttributeArgumentSyntax argument)
 {
     return(HasAttribute(attributeLists, context, attributeDefinition.Name, attributeDefinition.FullName, out location, out argument));
 }
        public static bool HasAttribute(SyntaxList <AttributeListSyntax> attributeLists, SyntaxNodeAnalysisContext context, AttributeDefinition attributeDefinition, out Location location, out string argumentValue)
        {
            argumentValue = string.Empty;
            if (HasAttribute(attributeLists, context, attributeDefinition.Name, attributeDefinition.FullName, out location, out AttributeArgumentSyntax argument))
            {
                argumentValue = argument.ToString();

                return(true);
            }

            return(false);
        }
 public static bool HasAttribute(SyntaxList <AttributeListSyntax> attributeLists, SyntaxNodeAnalysisContext context, AttributeDefinition attribute)
 {
     return(HasAttribute(attributeLists, context, attribute.Name, attribute.FullName, out _));
 }
Exemple #7
0
        public static bool TryGetAttribute(AttributeListSyntax attributes, SyntaxNodeAnalysisContext context, AttributeDefinition attributeDefinition, out AttributeSyntax attribute)
        {
            foreach (AttributeSyntax attr in attributes.Attributes)
            {
                if (attr.Name.ToString().Contains(attributeDefinition.Name))
                {
                    IMethodSymbol memberSymbol = context.SemanticModel.GetSymbolInfo(attr).Symbol as IMethodSymbol;
                    if (memberSymbol != null && memberSymbol.ToString().StartsWith(attributeDefinition.FullName))
                    {
                        attribute = attr;
                        return(true);
                    }
                }
            }

            attribute = default;
            return(false);
        }
Exemple #8
0
        public static bool TryGetAttribute(SyntaxList <AttributeListSyntax> attributeLists, SyntaxNodeAnalysisContext context, AttributeDefinition attributeDefinition, out AttributeSyntax attribute)
        {
            foreach (AttributeListSyntax syntax in attributeLists)
            {
                if (TryGetAttribute(syntax, context, attributeDefinition, out attribute))
                {
                    return(true);
                }
            }

            attribute = default;
            return(false);
        }