Extend property covariance into the internal model. #1713
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Makes
TProperty
covariant within the internal model'sIValidationRule<T,TProperty>
interface.This would resolve #1711 and related scenarios where the property type may be an inheritor of the type defined in a rule extension method.
This would introduce several breaking changes. Specifically:
IValidationRule.Current
would need to beIRuleComponent<T,TProperty>
rather thanRuleComponent<T,TProperty>
GetErrorMessage
would not be exposed onIRuleComponent<T,TProperty>
Making various properties write-only is potentially problematic, but in theory users should only ever be setting these, and only the library's internals need to get them. But I expect there will be someone out there who relies on this for something nonstandard.
MessageBuilders still need some work. The quick fix is to not expose
TProperty
on theMessageBuilderContext
and instead go back to exposing this as a non-genericobject
. This isn't ideal, so see whether there's a better way around this that still allows the MessageBuilder's getter to be exposed.