I need to find the type of the property that a custom attribute is applied to from within the custom attribute.
For example:
[MyAttribute]
string MyProperty{get;set;}
Given the instance of MyAttribute, how could I get a Type descriptor for MyProperty?
In other words, I am looking for the opposite of System.Type.GetCustomAttributes()
The attribute itself knows nothing about the object that was decorated with it. But you could inject this information at the time you retrive the attribute.
At some point you have to retrieve the property using code similar to the following.
The custom attribute knows nothing about the attributed element so I don't think what you want is possible to do unless you enumerate all types in your system and check if they contain such attribute.