What's the reason for not being able to use static methods, instance methods, etc as a argument to an attribute in .NET?
Why doesn't C# allow this?
What's the reason for not being able to use static methods, instance methods, etc as a argument to an attribute in .NET?
Why doesn't C# allow this?
From a recent discussion in #mono on GIMPNet, attributes in C# are actually encoded directly into the IL of the generated assembly. As such, the arguments passed into the attributes are limited to what can reasonably be directly encoded.
You can get around this with a bit of reflection. Simply give the attribute enough information, in string form, to identify what you want it to do, then use reflection to find the appropriate methods and properties to invoke/use.