-
Something that has annoyed me awhile in C# is that when you derive a class with attributes (either on the class itself or its virtual properties), the attributes are ignored and not accessible on the child class.
An additional nice feature would be if child attributes could be mixed with its parent's or overridden (depending if it's the same attribute or not). |
Beta Was this translation helpful? Give feedback.
Replies: 3 comments
-
Is there a particular use case for this? Any code that depends on interrogating attributes can already scan the type hierarchy for attributes applied to the parent classes, depending on how it might support that. Having the compiler (or reflection API) make that happen automatically could easily break a lot of existing code. |
Beta Was this translation helpful? Give feedback.
-
Attributes are inherited if the respective type is marked with |
Beta Was this translation helpful? Give feedback.
-
The IDE still does not have a proper support for them even after all this time unfortunately. |
Beta Was this translation helpful? Give feedback.
Attributes are inherited if the respective type is marked with
[AttributeUsage(Inherited = true)]
. 😉