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

Provide correct ViewDataDictionary<TModel>.ModelMetadata when Model is null #1426

Closed
dougbu opened this issue Oct 21, 2014 · 4 comments
Closed
Assignees
Milestone

Comments

@dougbu
Copy link
Member

dougbu commented Oct 21, 2014

create views (any view where Model==null) currently have ViewData.ModelMetadata.ModelType==typeof(object) and calculated ModelMetadata for properties have metadata.ModelType==typeof(string). the problem prevents correct operation of @Html.Editor() and similar helpers. for example @Html.EditorFor(model => model.Alive) in a create view returns <input type="text" .../> though Alive is a bool property and should have <input type="checkbox" .../>.

fix here is very small. should be done in the ViewDataDictionary<TModel>.ModelMetadata getter.

@danroth27 danroth27 added this to the 6.0.0-beta1 milestone Oct 21, 2014
@danroth27 danroth27 added the bug label Oct 21, 2014
@dougbu
Copy link
Member Author

dougbu commented Oct 21, 2014

hmm, removing last (incorrect) sentence in description.

@danroth27 danroth27 modified the milestones: 6.0.0-beta2, 6.0.0-beta1 Oct 22, 2014
@dougbu
Copy link
Member Author

dougbu commented Oct 22, 2014

Problem reproduces consistently if the project contains a _ViewStart.cshtml file, even one that's empty.

dougbu added a commit that referenced this issue Oct 23, 2014
…` is

 never that for `object`
- `ViewDataDictionary<TModel>.ModelMetadata` was for `object` after base
 copy constructor got value from `ViewDataDictionary<object>`
- problem led to #1426 symptoms
- with copy constructor leaving `base.ModelMetadata==null` more often,
 `ViewDataDictionary<TModel>.ModelMetadata` usually tracks `TModel` if
 `Model==null`

nit:
- fix existing comment in main `ViewDataDictionary` copy constructor
- add some `<remarks/>` to the four `ViewDataDictionary` copy constructors
dougbu added a commit that referenced this issue Oct 23, 2014
…` is

 never that for `object`
- `ViewDataDictionary<TModel>.ModelMetadata` was for `object` after base
 copy constructor got value from `ViewDataDictionary<object>`
- problem led to #1426 symptoms
- with copy constructor leaving `base.ModelMetadata==null` more often,
 `ViewDataDictionary<TModel>.ModelMetadata` usually tracks `TModel` if
 `Model==null`

nit:
- fix existing comment in main `ViewDataDictionary` copy constructor
- add some `<remarks/>` to the four `ViewDataDictionary` copy constructors
@danroth27 danroth27 modified the milestones: 6.0.0-beta1, 6.0.0-beta2 Oct 27, 2014
@danroth27
Copy link
Member

We will take the copy constructor fix for beta1 and then revisit this for beta2.

dougbu added a commit that referenced this issue Oct 27, 2014
…` is

 never that for `object`
- `ViewDataDictionary<TModel>.ModelMetadata` was for `object` after base
 copy constructor got value from `ViewDataDictionary<object>`
- problem led to #1426 symptoms
- with copy constructor leaving `base.ModelMetadata==null` more often,
 `ViewDataDictionary<TModel>.ModelMetadata` usually tracks `TModel` if
 `Model==null`

nit:
- fix existing comment in main `ViewDataDictionary` copy constructor
dougbu added a commit that referenced this issue Oct 27, 2014
…` is

 never that for `object`
- `ViewDataDictionary<TModel>.ModelMetadata` was for `object` after base
 copy constructor got value from `ViewDataDictionary<object>`
- problem led to #1426 symptoms
- with copy constructor leaving `base.ModelMetadata==null` more often,
 `ViewDataDictionary<TModel>.ModelMetadata` usually tracks `TModel` if
 `Model==null`

nit:
- fix existing comment in main `ViewDataDictionary` copy constructor
@dougbu
Copy link
Member Author

dougbu commented Oct 27, 2014

Fixed in Release (for Beta1) w/ commits 8d2a1c4 through cfcb1f2 and merged into Dev

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

2 participants