Proposal: Allow class inheritance with property exclusions #9186
-
Would it be at all possible to allow classes inherit from other classes, but flag a list of properties as excluded? This could be helpful if building a wrapper around a class beyond a developer's control, but the base class has properties which the wrapping class does not wish to consume. |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment
-
Inheritance represents an "is a" relationship, so the child type is required to support all of the functionality and contract of the parent type. At best you could override the members and use attributes to hide them from the IDE, and perhaps also write an analyzer that would emit an error if someone attempting to consume that method directly, but you could never prevent someone from upcasting to the base class and consuming those members. |
Beta Was this translation helpful? Give feedback.
Inheritance represents an "is a" relationship, so the child type is required to support all of the functionality and contract of the parent type. At best you could override the members and use attributes to hide them from the IDE, and perhaps also write an analyzer that would emit an error if someone attempting to consume that method directly, but you could never prevent someone from upcasting to the base class and consuming those members.