This change fixes call sites on the main request path for a simple site
(model binding, validation, views) that allocate boxed list enumerators.
Some cases aren't addressed by this change because the fix is too invasive
or requires changing an important contract to take IList instead of
IEnumerable. Will follow up on those case by case in order of importance.
- #2969
- add `ModelBindingMessages` for configuration and `IBindingMetadataProvider` overrides
- use `interface` to avoid `new` oddities when adding a setter to an `abstract` property
- add `IModelBindingMessages` to `ModelMetadata` for use in rest of the product code
- plumb the various bits through the system
- add integration tests using a custom `IBindingMetadataProvider`s to override messages
nits:
- remove unused resources
- use `AttemptedValue` and not `model` in `SimpleTypeModelBinder`
This change works around two mono issues that are blocking travis. I'd
like to have tests skip instead, but unfortunately that would mean not
running any validation tests on mono so this seems better.
- RuntimeHelpers.GetHashCode will sometimes crash the runtime
- PropertyHelper sometimes returns throws null-ref
- Added generic add model error and remove extensions for
ModelStateDictionary, to avoid using hard coded strings then specifying
model state dictionary keys.
- Added generic removal all extension for ModelStateDictionary, to
support removing all the model state keys for given expression.
aspnet/Mvc#3164
This solves a perf issue for views which produce content that is smaller
than the buffer size of HttpResponseStreamWriter. In this case, the writer
ends up synchronously writing to the Response as part of Dispose which
affects perf.
This change makes ViewComponentResult respect an existing Content-Type
setting on the HttpResponse. Code is very similar to the code in
ViewExector, and includes the same quirks.
Abstractions - Core MVC extensibility
Controllers - MVC implementations of .Abstractions and supporting
contracts
Infrastructure - General purpose support APIs. Metadata APIs that don't
fit clearly with a feature or with .Abstraction
[FromServices] requires modelbinding to run for each of these four
properties, which allocates a lot, and ultimately just ends up calling
GetRequiredService in the end.
Also, retrieving these services is now lazy, which should be very
beneficial as few of them aren't used often.
We don't want these extensions methods defined in a wierd namespace, it's
straightforward and future-proof to just make these strongly-typed
collections.
- #2722
- make communication of errors from formatters to `BodyModelBinder` explicit
- `JsonInputFormatter` now adds errors to `ModelStateDictionary` with correct key
- change `InputFormatter.SelectCharacterEncoding()` to add an error and return `null` when it fails
- one less `Exception` case and removes some duplicate code
nits:
- improve some doc comments (more `<inheritdoc/>`, `<paramref/>` and `<see/>`)
- add another two `BodyValidationIntegrationTests` tests
Improves authoring experience when using TagBuilder by taking advantage of
IHtmlContentBuilder an its extension methods.
TagBuilder.InnerHtml is no longer settable.