Is it possible to get metadata about a class member in an attribute constructor

Suppose I have a simple custom attribute:

public class MyCustomAttribute : Attribute
{
    public MyCustomAttribute(string parameter1)
    {
    }
}

      

And use it to decorate a member in the classroom

public class Foo
{
    [MyCustomAttribute("test")]
    string bar;
}

      

When the constructor for MyCustomAttribute is run - in this example with "test" as the value of the first parameter - is it possible to get any of the metadata about the element that was decorated? that is, in this example, you can find out that the property is called "bar" or that it is of type System.String?

I can't see how to do this - I might go blind! - but it looks like the metadata should be available somewhere?

+3


source to share


1 answer


Not.



Of course, you can add additional parameters to the attribute constructor to provide whatever information you like, but there is nothing like it available out of the box.

0


source







All Articles