Support for record types in MVC #23465
Labels
area-mvc
Includes: MVC, Actions and Controllers, Localization, CORS, most templates
Done
This issue has been fixed
enhancement
This issue represents an ask for new feature or an enhancement to an existing one
Projects
Milestone
The main area of focus is modelbinding/deserialization. For the most part it works, you can define record types and add properties with init only and so on and we should have no problem deserializing or binding to them, since the properties will be public and will have a setter.
We need to examine our support for record types with a "primary" constructor. For these types, I believe we don't have support out of the box. We need to evaluate the work needed to properly integrate with these types. The main issue arises from the fact that these types don't have a parameterless constructor and that can be used to create an instance of the object, and it is not possible to add one in code (as of the latest preview).
I believe the work required here is:
I believe it is important that we support this syntax, since it significantly reduces the cognitive load of declaring a type. Consider a type hierarchy like a todo list:
Compare that to
Not only the second definition is more succinct an clear, but it is also more correct and less verbose.
For example:
The text was updated successfully, but these errors were encountered: