Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Groups of C# Attributes

Tags:

c#

attributes

Is there any way to build a group of attributes?

Before:

[SuppressMessage("Microsoft.Design", "CA1061")]
[SuppressMessage("Microsoft.Usage", "CA1812")]
[SuppressMessage("Microsoft.Design", "CA1064")]
public abstract void Foo();

What I want:

[SpecialStuff]
public abstract void Foo();

Is this possible? Can I build an attribute that groups others?

like image 346
alejandro5042 Avatar asked Jul 15 '11 21:07

alejandro5042


1 Answers

The way attributes and their respective values are examined is usually through reflection - your special aggregate attribute SpecialDispose would not have any meaning since its unknown to a potential inspector so I do not think its possible to achieve what you want.

like image 62
BrokenGlass Avatar answered Oct 21 '22 03:10

BrokenGlass