I have this basic class with one custom Attribute
public class Foo
{
[MyAttribute]
public DateTime CurrentDate {get;set;}
}
I'm using reflection to see if CurrentDate
has a MyAttribute
on it.
I create a new instance of Foo
:
var foo = new Foo();
I reflect on foo
:
foo.GetType().GetProperty("CurrentDate").GetCustomAttributes(true);
this gives me my custom attributes.
However, if I reflect like this:
foo.CurrentDate.GetType().GetCustomAttributes(true);
it returns what seems to be native attributes and mine is not in there.
So my question is, why is it doing that?