You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Merge branch 'bugfix/ReverseTopicMappingService-records' into develop
The `TopicMappingService` takes a very permissive approach to mapping; if the target property doesn't exist on the source `Topic`, or cannot be mapped, it fails silently. By contrast, the `ReverseTopicMappingService` is much more conservative, since the results are (potentially) invasive, resulting in updating the underlying persistence store. As a result, if the source binding model has properties that cannot be mapped, or don't correspond to attributes on the `ContentTypeDescriptor`, an exception is thrown. This helps warn implementers about design flaws that might result in data loss.
This introduces problems with C# 9.0 record types, however, as the compiler dynamically generates a `EqualityContract` property for each record. But as there isn't an `EqualityContract` attribute on the `ContentTypeDescriptor`, the `BindingModelValidator` will throw an exception.
To mitigate that, a hard-coded exception is added to both the `ReverseTopicMappingService` and the `BindingModelValidator` to ignore properties named `EqualityContract`, treating them as though they are decorated with the `[DisableMapping]` attribute. This effectively allows binding models to be implemented as record types, just as we prefer for view models. And since we implemented our stock `OnTopic.ViewModels` as records, it also allows binding models to derive from those models.
0 commit comments