-
Notifications
You must be signed in to change notification settings - Fork 2.1k
Changes to property ModelMetadata provided by a ModelMetadataDetailsProvider are lost for Nullable<T> in Display/Edit templates when DataType is used to change the template #4116
Comments
/cc @dougbu |
The problem is only partially about It's true the The chosen More generally, |
I take back "This makes sense only when |
…tadata` - #4116 - greatly simplify rules for `ModelMetadata`; entirely remove metadata changes when Model is updated - update `HtmlHelper.RenderPartialCoreAsync()` to ensure metadata is _not_ copied unless using existing model - note existing functional tests did not need to change nits: - do not call `virtual SetModel()` method from constructor; now mostly redundant - add some missing doc comments - fix doc comment property versus type confusion; never need to specify `ViewDataDictionary.` prefix
…tadata` - #4116 - greatly simplify rules for `ModelMetadata`; entirely remove metadata changes when Model is updated - update `HtmlHelper.RenderPartialCoreAsync()` to ensure metadata is _not_ copied unless using existing model - note existing functional tests did not need to change nits: - do not call `virtual SetModel()` method from constructor; now mostly redundant - add some missing doc comments - fix doc comment property versus type confusion; never need to specify `ViewDataDictionary.` prefix
- #4116 - generalize rules for `ModelMetadata` creation; minimize metadata changes when Model is updated - down to a single special case in VDD for `Nullable<T>` - note existing functional tests did not need to change - remove `ViewDataDictionary(ViewDataDictionary, object)` constructor; use `new VDD<object>(source, model)` - allow all `Model` assignments in a view component - copy-constructed VDD in `ViewComponentContext` previously preserved the source's declared type nits: - do not call `virtual SetModel()` method from constructor; now mostly redundant - logic in copy constructor and `SetModel()` is consistent but different enough to keep code separate - add some missing doc comments - fix doc comment property versus type confusion; never need to specify `ViewDataDictionary.` prefix - fix a few `TemplateBuilder` comments and remove unnecessary `model: null` argument to VDD constructor
a0c8834 and merged into |
Hello ASP.net team,
This bug is related to #2539, but the fix for that bug doesn't work when the nullable property has a DataType attribute that changes the display / edit templates.
The main part of that fix was this part:
I suspect that the code does not handle nullable types correctly because
metadataModelType
will never beNullable<T>
whereasmodelType
can be, so the ModelExplorer is being always discarded in case of nullable properties.https://github.com/rwasef1830/aspnet-mvc6-modelmetadata-repro
Hope that helps.
The text was updated successfully, but these errors were encountered: