- Add abstract CompositeValidationAttribute.
- Change DataAnnotationsMetadataProvider.CreateValidationMetadata to
populate ValidatorMetadata with validation attributes from CompositeValidationAttribute.
If you give ModelExpressionProvider a lambda with a private property
you'll end up here. This wasn't common before, but it seems like users
are more likely to try it with pages.
Model Metadata and Model Binding don't handle private properties, so
supporting it in Model Expressions seems less than useful.
This isn't a breaking change because this case would have resulted in a
null-ref. Addresses #6400
- #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
- #1485, #1487
- handle `TemplateInfo.HtmlFieldPrefix` in `ViewDataEvaluator.Eval()`
- attempt lookup in the `ViewDataDictionary` using full name then evaluate
relative `expression` against `viewData.Model`
- handle `null` or empty `expression` special case in this method (remove `throw`s)
- always pass relative `expression` name into `Eval()`
- remove `null` or empty `expression` handling from higher-level code
- in a couple of cases, special-case returned `ViewDataInfo`
- #2662
- remove incorrect guard from `DefaultHtmlGenerator.GenerateRadioButtion()`
- add doc comments for the core methods that have changed
- enable unit tests skipped due to one of above bugs
- fix one (yeah, just one) other test with incorrect expectations
- remove functional test comments about the above bugs and update expectations
nits:
- move some comments describing `ViewDataEvaluator` methods above the methods
- test additional cases _close_ to these bugs as well
for #1485
- show odd `@Html.CheckBox()`, `@Html.Hidden()` behaviour in unit tests
- show odd `@Html.TextBox()` behaviour in functional tests (templates)
for #1487
- show odd `@Html.Value()` behaviour in unit tests
- show odd `@Html.RadioButton()`, `@Html.TextArea()` behaviour in functional tests
- show lack of validation attributes for `@Html.RadioButton()`, `<select>` tag helper
for #2662
- show odd `@Html.RadioButton(string.Empty)` behaviour in functional tests
for #2664
- show failures with `@Html.ListBox()` in unit tests
nits:
- test `IHtmlHelper` methods, not extensions
- use `ViewData`, not `ViewBag` in `HtmlGeneration_FormController`
- name test methods a bit more consistently
- rename `HtmlHelperValueExtensionsTest` to `HtmlHelperValueTest`