This post originated from an RSS feed registered with .NET Buzz
by Eric Gunnerson.
Original Post: Attributes that take parameterinfo or methodinfo
Feed Title: Eric Gunnerson's C# Compendium
Feed URL: /msdnerror.htm?aspxerrorpath=/ericgu/Rss.aspx
Feed Description: Eric comments on C#, programming and dotnet in general, and the aerodynamic characteristics of the red-nosed flying squirrel of the Lesser Antilles
*** typeof( x.y ) gives you propertyInfo/MethodInfo
We are making all sorts of cool framework things, using reflection and attributes.They are all great, but we've found a few places where we want to specify properties/methods in other classes, as arguments to attributes - (for instance - the value of this calculated field depends on the value of this other field).It would be really nice if the typeof operator could return a methodinfo/propertyinfo object!
To do this we would have to extend the attribute scheme to support new kinds of information, and that would require all the languages to add support. I think it would take a fairly compelling argument to do that. I don't think that changing Type to also be able to point to methods or properties is feasible.