So, if i have:
public class Sedan : Car
{
/// ...
}
public class Car : Vehicle, ITurn
{
[MyCustomAttribute(1)]
public int TurningRadius { get; set; }
}
public abstract class Vehicle : ITurn
{
[MyCustomAttribute(2)]
public int TurningRadius { get; set; }
}
public interface ITurn
{
[MyCustomAttribute(3)]
int TurningRadius { get; set; }
}
What magic can I use to do something like:
[Test]
public void Should_Use_Magic_To_Get_CustomAttributes_From_Ancestry()
{
var property = typeof(Sedan).GetProperty("TurningRadius");
var attributes = SomeMagic(property);
Assert.AreEqual(attributes.Count, 3);
}
Both
property.GetCustomAttributes(true);
And
Attribute.GetCustomAttributes(property, true);
Only return 1 attribute. The instance is the one built with MyCustomAttribute(1). This doesn't seem to work as expected.