public static bool HasAttributeOnAncestorOrSelf(this CSharpSyntaxNode node, string attributeName)
        {
            var parentMethod = (BaseMethodDeclarationSyntax)node.FirstAncestorOrSelfOfType(typeof(MethodDeclarationSyntax), typeof(ConstructorDeclarationSyntax));

            if (parentMethod?.AttributeLists.HasAttribute(attributeName) ?? false)
            {
                return(true);
            }
            var type = (TypeDeclarationSyntax)node.FirstAncestorOrSelfOfType(typeof(ClassDeclarationSyntax), typeof(StructDeclarationSyntax));

            while (type != null)
            {
                if (type.AttributeLists.HasAttribute(attributeName))
                {
                    return(true);
                }
                type = (TypeDeclarationSyntax)type.FirstAncestorOfType(typeof(ClassDeclarationSyntax), typeof(StructDeclarationSyntax));
            }
            var property = node.FirstAncestorOrSelfOfType <PropertyDeclarationSyntax>();

            if (property?.AttributeLists.HasAttribute(attributeName) ?? false)
            {
                return(true);
            }
            var accessor = node.FirstAncestorOrSelfOfType <AccessorDeclarationSyntax>();

            if (accessor?.AttributeLists.HasAttribute(attributeName) ?? false)
            {
                return(true);
            }
            var anInterface = node.FirstAncestorOrSelfOfType <InterfaceDeclarationSyntax>();

            if (anInterface?.AttributeLists.HasAttribute(attributeName) ?? false)
            {
                return(true);
            }
            var anEvent = node.FirstAncestorOrSelfOfType <EventDeclarationSyntax>();

            if (anEvent?.AttributeLists.HasAttribute(attributeName) ?? false)
            {
                return(true);
            }
            var anEnum = node.FirstAncestorOrSelfOfType <EnumDeclarationSyntax>();

            if (anEnum?.AttributeLists.HasAttribute(attributeName) ?? false)
            {
                return(true);
            }
            var field = node.FirstAncestorOrSelfOfType <FieldDeclarationSyntax>();

            if (field?.AttributeLists.HasAttribute(attributeName) ?? false)
            {
                return(true);
            }
            var eventField = node.FirstAncestorOrSelfOfType <EventFieldDeclarationSyntax>();

            if (eventField?.AttributeLists.HasAttribute(attributeName) ?? false)
            {
                return(true);
            }
            var parameter = node as ParameterSyntax;

            if (parameter?.AttributeLists.HasAttribute(attributeName) ?? false)
            {
                return(true);
            }
            var aDelegate = node as DelegateDeclarationSyntax;

            if (aDelegate?.AttributeLists.HasAttribute(attributeName) ?? false)
            {
                return(true);
            }
            return(false);
        }