Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to make .NET attribute only valid on certain types [duplicate]

Possible Duplicate:
Specify required base class for .NET attribute targets

I want to specify that my custom attribute only be valid on certain types (based on interface or base class).
Like this:

attributes

How can I do that?

like image 891
TDaver Avatar asked Feb 10 '11 16:02

TDaver


1 Answers

It sounds like you want to create an Attribute which can only be applied to certain types in much the way that AttributeUsage can only be applied to types deriving from Attribute. Introducing this type of custom restriction is simply not possible. The particular error you're seeing is not because of a custom restriction, it's one that's simply hard wired into the compiler itself.

like image 105
JaredPar Avatar answered Oct 13 '22 00:10

JaredPar