Remove DefaultValue support from model binding and do it only in the invoker for action parameters #2414
Comments
We should also consider just removing this code.
|
Legacy info: MVC5 and WebAPI2 respected MVC futures and WebAPI2 respected |
Remove DefaultValue support from model binding and do it only in the invoker for action parameters. |
This part of the change removes default value support from ModelBinding. Updated some unit tests to verify that it does nothing in that case. Deleted a functional test as it was pure duplication of another (supported) case where the property has a pre-initialized value.
Does this include bound-controller-properties? This affects the shape of the implementation. Is the goal to limit the spread of a feature that we need for compat? Or to be consistent? |
Bound controller properties are an interesting case. They're more akin to action parameters, so that makes it more interesting. Having said that, I'm fine not supporting DefaultValue on controller properties for now, and we could add that in the future if there's demand. |
The interesting thing about doing it on both properties/parameters is that the implementation concerns would probably dictate that it be first-class at that point -- Seems to me like that's a bit overkill, will just do it at a low-level for now and just for parameters 👍 |
Yeah that sounds like the best plan for now. Thanks! |
Part 1 checked in: 2fc983b |
Part 2 checked in: cc4ee10 |
MutableObjectModelBinder
performs reflection to look up properties and their default values.https://github.com/aspnet/Mvc/blob/dev/src/Microsoft.AspNet.Mvc.ModelBinding/Binders/MutableObjectModelBinder.cs#L298
We should move this into
ModelMetadata
so it can be cached, and so that the model binding system is more data driven.The text was updated successfully, but these errors were encountered: