To check, whether an element in .NET has set the browsable attribute, use the following code:
public static bool HasBrowsableAttributeTrue( object o ) { if ( o==null ) { return false; } else { var fi = o.GetType().GetField( o.ToString() ); var attributes = (BrowsableAttribute[])fi.GetCustomAttributes( typeof( BrowsableAttribute ), false ); if ( attributes != null && attributes.Length > 0 ) { return attributes[0].Browsable; } else { return false; } } }
This works even if the object is null
.