Adds a new property, FieldName, to ModelBindingContext. The FieldName is
the name of whatever code-element is being bound, regardless of what
model-prefix is in use.
This is needed for cases like the Header model binder. We always want to
use the property/parameter name and we don't care about model prefixes.
- The corresponding Razor change results in `HelperResult`s being rendered with async lambdas.
- This change enables `TagHelper`s and other async code to exist inside of `HelperResult` blocks.
- Added test to validate Templates (they generate `HelperResult`s) can utilize `TagHelper`s correctly.
- Rename `RazorPage`s `RenderBodyDelegate` to `RenderBodyDelegateAsync`.
aspnet/Razor#494
- #2993
- use `ClosedGenericMatcher` to handle e.g. non-generic model types implementing requested interfaces
- reduce `IsAssignableFrom()` use since created binders use explicit casts i.e. handle explicit implementations
- also add more integration tests covering various collection key formats, some with validation errors
- merge a few `[Fact]`s into `[Theory]`s
- #2992
- use new properties to replace common helper methods
- still a few `Nullable.GetUnderlyingType()` calls
- creating `ModelMetadata` or sites lacking `ModelMetadata` access e.g. `ModelBindingHelper.ConvertTo()`
- #2941
- honor `ModelBindingResult.IsModelSet` and use `ModelBindingResult.ValidationNode`
- enable correct validation of collections or after model binding falls back to the empty prefix
- code previously matched `Controller.TryValidateModel()`; less context available in that case
- `ScriptTagHelper`, `LinkTagHelper` and `ImageTagHelper` now default to using `output.Attributes["href|src"]` if it's present when they run. This enables other `TagHelper`s to run prior and add those attributes.
- Added unit tests to validate this behavior.
- Updated `ImageTagHelper` functional test resources. Now that we're always defaulting to `output.Attributes["src"]` for `ImageTagHelper.Src` we're properly copying attributes back into the `output.Attributes` collection in the correct order (isntead of appending to the end).
#2902
- Updated implementation to do a best guess at copying an attribute back into `TagHelperOutput.Attributes`.
- Updated existing functional and unit tests to account for maintained attribute order.
- Added a set of complex order based unit tests to validate `CopyHtmlAttribute` properly maintains order.
#2639
- #2836
Part 1: Use existing property values when recursing in `MutableObjectModelBinder`
- remove `ComplexModelDTO` because that indirection made fixing this issue more difficult and doesn't add value
- started with an old closed PR (#2241) which did some of this work
- correct `MutableObjectModelBinderTest` tests that exercised behaviour that can't occur
- the old `dto.Results` dictionary was never incomplete; nor could it contain `null` values
Part 2: Change `MutableObjectModelBinder` to pass complex property values into binding system
- model binding no longer trounces nodes in the model tree that aren't bound
- create model instances less often in `TryUpdateModel` scenarios
- refactor `EnsureModel()` to `GetModel()` and use appropriately
- reorder logic in `SetProperty()` and `AddToProperty()` to avoid copying to / from the same collection
- also cleans up some code duplication
nits:
- clean up `MutableObjectModelBinderTest`
- fix odd line wrappings and indentation
- use `nameof()` more
- use `string.Empty` more
- simplify a couple of `Returns()` expressions
- make assertions in `TryUpdateModelIntegrationTest` more readable
- no need to work through `ModelStateDictionary.Keys`
- also use `Length` instead of `Count()`; test code but we don't need Linq at all in that test class
some more tests.
This change reverts the behavior change from
a6ce9abab1 and adds more tests around the
scneario that was actually broken.
The right behavior is that unconvertable values result in a validation
error. There's no special behavior around value types and required values.
- Now allow the attribute to exist on `img` and `source` tags.
- Updated existing `UrlResolutionTagHelper` functional test to validate `srcset` attribute.
#2964
- Making TagRenderMode a property in TagBuilder.
- Modifying places where TagBuilder is used to suit the new model.
- This reduces space occupied by a normal application by 11.8%.
This change restores a link generation behavior from MVC5 and earlier
where 'action' and 'controller' values are special cased-when using
Url.Action(...).
The change is that in-effect 'action' and 'controller' are always included
in the route values given to the routing system. Passing a null value into
the Url.Action(...) method means that the ambient value for that token
should be used explicitly. This means that the 'action' and 'controller'
tokens become sticky, even when something to the lexical left in the URL
(like area) changes.
- Razor rendering now understands `TagMode` which allows void elements to be rendered.
- Added a `TagStructure.WithoutEnd` bit to `InputTagHelper`, `ImageTagHelper` and `UrlResolutionTagHelper`. This will allow users to write the various elements in the void format. Used the HTML5 spec to determine the elements appropriate.
- Added tests to ensure `TagMode.StartTagOnly` is rendered properly.
- Updated a few functional tests to showcase the void element formats.
aspnet/Razor#450