In a few places, we inherit from some of our Entities. Something very straightforward like:
public class FancyEmployee : Employee{ // Extra logic here } |
However, that isn't enough. We've found that we need to re-delcare the PropertyMetadata nested class in our FancyEmployee.....even though we aren't adding any more properties. So our code becomes less straightforward:
public class FancyEmployee : Employee{ public new class PropertyMetadata : Employee.PropertyMetadata { //This class is necessary to make Dev Force happy - otherwise serves no purpose :-) }
// Extra logic here } |
If we don't do that, DevForce will just happily assume there are no properties! Which I actually think is worse behavior than you used to have in previous versions where you would explicitly throw an exception saying "EntityType: FancyEmployee is not a valid 'Entity' subclass. It inherits from Entity but does not contain a PropertyMetadata nested type." - at least that error told us that we were doing something wrong instead of silently ignore it.
It's not terribly complicated to have these extra PropertyMetadata classes but it does add some extra boilerplate code that is easy to forget. Also, we have complicated inheritance hierarchies and we've started running into some weird errors cause by bad copy/pasting in the boilerplate code. For example, the new PropertyMetadata class in FancyEmployee might accidentally inherit from Order.PropertyMetadata. That kind of thing may work at first but eventually can come back to bite you. Also, if we add a new class to our hierarchy, we have to be careful that we also update all these PropertyMetadata class so they inherit correctly.
I'm wondering if there might be a way that DevForce could do some kind of 'FlattenHierarchy' when it uses reflection to find the PropertyMetadata class. That way we would only need to re-delcare it if we were actually adding properties (which is considerably more rare).