Inheritance of Custom Attributes on Abstract Properties
Solution 1:
Instead of calling PropertyInfo.GetCustomAttributes(...), you have to call the static method System.Attribute.GetCustomAttributes(pi,...), as in:
PropertyInfo info = GetType().GetProperties();
// this gets only the attributes in the derived class and ignores the 'true' parameter
object[] DerivedAttributes = info.GetCustomAttributes(typeof(MyAttribute),true);
// this gets all of the attributes up the heirarchy
object[] InheritedAttributes = System.Attribute.GetCustomAttributes(info,typeof(MyAttribute),true);
Solution 2:
No, attributes are inherited.
It's the GetCustomAttributes()
method that does not look at parent declarations. It only looks at attributes applied to the specified member. From the docs:
Remarks
This method ignores the inherit parameter for properties and events. To search the inheritance chain for attributes on properties and events, use the appropriate overloads of the Attribute..::.GetCustomAttributes method.