This repository was archived by the owner on Dec 14, 2018. It is now read-only.
Correct and clean up ViewDataDictionary
semantics #1466
Closed
Description
Issues found during recent investigations:
ViewDataDictionary.ModelMetadata.Model
andViewDataDictionary.Model
can easily get out of sync- e.g. controller passes 23 to a view and
ViewData.Model=24
executes in the view; later helpers (especially the lambda-based ones) will useViewData.ModelMetadata.Model
, which is still 23
- e.g. controller passes 23 to a view and
ViewDataDictionary.ModelMetadata==null
isn’t alwaystrue
whenViewDataDictionary.Model==null
- in the
false
cases,ViewDataDictionary.ModelMetadata.ModelType
may not match the containing page’s@model
type (a corner case) - generally
ViewDataDictionary
contract isn't clear nor implemented consistently
- in the
ViewDataDictionary<int>.Model
will throw an NRE if it is read before it’s written- should return
0
in this case
- should return
- some calls to the
ViewDataDictionary
andViewDataDictionary<TModel>
constructors (e.g. from page activation) are incorrect for the intended semantics- “incorrect” is usually limited to
ViewDataDictionary.ModelState
being empty but could, in corner cases, lead to unwarranted errors about invalid model values
- “incorrect” is usually limited to
- the recent fix for Provide correct
ViewDataDictionary<TModel>.ModelMetadata
whenModel
isnull
#1426 (in Beta1) likely has some corner cases- should now provide a more robust fix for Provide correct
ViewDataDictionary<TModel>.ModelMetadata
whenModel
isnull
#1426
- should now provide a more robust fix for Provide correct