The current implementation of WhenPropertyChangedBehaviorFixture.ExpressionContainsImplicitInterfaceCast() has 99% of this scenario. In fact, writing it is how I noticed this scenario.
If INotifyPropertyChanged is removed from IHasAge and moved down to ChildModel, then the test stops working. The .WhenPropertyChanged() operator seems to only be looking at an object's interpreted type within the expression to see if it has INotifyPropertyChanged compatibility. I.E. if the expression itself doesn't report INotifyPropertyChanged compatibility at compile-time, then the operator doesn't recognize it.
Since INotifyPropertyChanged subscriptions take place at runtime, rather than expression-compile-time, it should be entirely possible to check for compatibility on each object instance, immediately before a subscription would occur. I've got no idea how easy this will be to implement within the existing system, though.
The current implementation of
WhenPropertyChangedBehaviorFixture.ExpressionContainsImplicitInterfaceCast()has 99% of this scenario. In fact, writing it is how I noticed this scenario.If
INotifyPropertyChangedis removed fromIHasAgeand moved down toChildModel, then the test stops working. The.WhenPropertyChanged()operator seems to only be looking at an object's interpreted type within the expression to see if it hasINotifyPropertyChangedcompatibility. I.E. if the expression itself doesn't reportINotifyPropertyChangedcompatibility at compile-time, then the operator doesn't recognize it.Since
INotifyPropertyChangedsubscriptions take place at runtime, rather than expression-compile-time, it should be entirely possible to check for compatibility on each object instance, immediately before a subscription would occur. I've got no idea how easy this will be to implement within the existing system, though.