Skip to content
This repository was archived by the owner on Dec 14, 2018. It is now read-only.

Correct and clean up ViewDataDictionary semantics #1466

Closed
@dougbu

Description

@dougbu

Issues found during recent investigations:

  • ViewDataDictionary.ModelMetadata.Model and ViewDataDictionary.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 use ViewData.ModelMetadata.Model, which is still 23
  • ViewDataDictionary.ModelMetadata==null isn’t always true when ViewDataDictionary.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
  • ViewDataDictionary<int>.Model will throw an NRE if it is read before it’s written
    • should return 0 in this case
  • some calls to the ViewDataDictionary and ViewDataDictionary<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
  • the recent fix for Provide correct ViewDataDictionary<TModel>.ModelMetadata when Model is null #1426 (in Beta1) likely has some corner cases

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions