alowing delegates in attribute c'tors

  • Thread starter Thread starter PJ6
  • Start date Start date
P

PJ6

I was just wondering why AddressOf <methodname> is not considered a constant
expression for attributes. I mean, is it too much of a stretch to have a
method resolved before compile-time? I think this would be a good step
toward more explicitly supporting aspect-oriented programming in the
Framework. Has this come up for suggestion in 2.0, or any version?

Paul
 
I was just wondering why AddressOf <methodname> is not considered a constant
expression for attributes. I mean, is it too much of a stretch to have a
method resolved before compile-time?

Keep in mind that delegates can refer to instance methods too. There's
no way at compile time to know which instance the method should be
called on.

As long as you target a static method, you can provide the class and
method names to the attribute, and it can dynamically construct a
delegate using that information at runtime.


Mattias
 
Back
Top