Combining multiple Attributes to a single Attribute - Merge Attributes

asked9 years ago
last updated6 years ago
viewed11.5k times
Up Vote25Down Vote

On a control I am using multiple attribute properties:

[Browsable(false)]
[Bindable(false)]
[EditorBrowsable(EditorBrowsableState.Never)]
[DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
[Obsolete("", true)]
public new Boolean AllowDrop;

I am using those properties on a lot of the other control properties as well.

I am wondering if there is a way to reduce the amount of code to write each time.

It would be nice if I could combine multiple attributes like this:

[Hidden(true)]
public new Boolean AllowDrop;

Where the Hidden Property would include all the attributes above. So there is only 1 single line of code.

Maybe there is also a way to combine the attributes in a macro or something?

I am aware that there are other ways of hiding properties but I chose the way of using attributes.

Thanks