public static bool SelfOrDescendantHasAttributeWithName(
     this ITypeSymbol typeSymbol,
     string name)
 {
     return(typeSymbol.DescendantsAndSelf(x => x.BaseType)
            .Any(
                x => x.GetAttributes()
                .Any(
                    a => a.HasName(name)
                    )
                ));
 }
 public static bool SelfOrDescendantHasAttribute(
     this ITypeSymbol typeSymbol,
     INamedTypeSymbol attributeClass)
 {
     return(typeSymbol.DescendantsAndSelf(x => x.BaseType)
            .Any(
                x => x.GetAttributes()
                .Any(
                    a =>
                    a.AttributeClass != null &&
                    a.AttributeClass.Equals(attributeClass, SymbolEqualityComparer.Default)
                    )
                ));
 }