Commit Graph

25 Commits

Author SHA1 Message Date
Ryan Nowak 96de1dbe4b Remove IExcludeTypeFilter
- Removes IExcludeTypeFilter
- Replaced with a property 'ValidateChildren' on ModelMetadata
- Teach ValidationVisitor to respect 'ValidateChildren' for enumerable
  types.
2015-12-09 12:30:13 -08:00
Ryan Nowak cf6662d0c3 Partial fix for #3676 - fix race in ElementMetadata
The accessor for ElementMetadata can sometimes return null when
concurrently accessed.

This change solves this issue and simplified a bunch of lazy-computed
properties, by precomputing all type-related facets of ModelMetadata.

This also adds a ElementType property to ModelMetadata to maintain
the current separation of concerns as ModelMetadata is unaware of the
metadata provider.
2015-12-09 08:21:18 -08:00
Pranav K 017bf1a20f Changes to use moq-netcore 2015-11-25 16:04:04 -08:00
Cesar Blum Silveira 9dba871108 Strong name everything. 2015-11-03 21:16:49 -08:00
Doug Bunting 40b7636b72 Use `ModelMetadata.GetDisplayName()` in error message replacing `FormatException` and `OverflowException`
- #3227
- much of change is to tests, creating and passing `ModelMetadata`
- updated `InputFormatterContext` to make `ModelMetadata` available to `JsonInputFormatter`
  - walk `ModelMetadata` tree to get information about property with an issue
- add missing `null` checks in `ModelStateDictionaryExtensions`
2015-10-22 15:50:36 -07:00
Pranav K 8b0c157296 Rename ModelState (the type) -> ModelStateEntry
Fixes #3326
2015-10-20 16:43:00 -07:00
Ryan Nowak 054b39013c Reduce allocations in MSD enumeration 2015-10-20 10:35:16 -07:00
Pranav K f57e180971 Renaming Microsoft.Framework.* -> Microsoft.Extensions.* 2015-10-03 15:44:53 -07:00
Stefán Jökull Sigurðarson c713aa92ca Making the HtmlHelper.GetEnumSelectList take DisplayAttribute.GroupName into account to create select groups. 2015-09-29 09:53:48 -07:00
Doug Bunting 28aec3f5cc Support user overrides of system-provided `ModelError` messages
- #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`
2015-09-28 15:50:21 -07:00
Ryan Nowak 0d6edf240a Move ModelExplorer to ViewFeatures 2015-09-28 14:14:40 -07:00
Doug Bunting d8d0a1ab89 Rename `ModelMetadata.IsCollectionType` and add "real" `ModelMetadata.IsCollectionType`
- #3022
- existing `IsCollectionType` -> `IsEnumerableType`
- use new `IsCollectionType` in a few places
2015-09-22 19:05:40 -07:00
N. Taylor Mullen 4fb2053f34 Update project.json to have warningsAsErrors accept a bool. 2015-09-02 15:35:13 -07:00
Chris R f2db0d1483 React to string[] -> StringValues changes. 2015-08-28 16:36:19 -07:00
Doug Bunting bf7e0f141e Add `IsReferenceOrNullableType` and `UnderlyingOrModelType` to `ModelMetadata`
- #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()`
2015-08-24 12:26:50 -07:00
Ryan Nowak 6d365e9a32 Make ValueProviderResult a string-ish struct 2015-08-21 11:02:40 -07:00
Doug Bunting 715a0b6021 Add `ModelState` entries for greedy and type-matching model binders
- part II of II for #2445
- `FormCollectionModelBinder` is an exception because container is not user-provided
 - no `ModelState` entry added
- enable tests that #2445 was blocking
 - fix these and other tests expecting different `ModelState` entries
- simplify logic in `FormFileModelBinder`

`ValueProviderResult`
- remove `protected` setters and parameterless constructor
 - no scenario for their use in subclasses; however `ConvertTo()` remains `virtual`
- add single-parameter constructor
 - use in most of the greedy and type-matching model binders
- add doc comments throughout class

nits:
- use new `ValueProviderResult` constructor in many existing tests
- `""` -> `string.Empty` and `vpr` -> `valueProviderResult` in `ValueProviderResultTest`
- improve some test names in `BodyValidationIntegrationTests`
- do not check `Message` of a Json.NET `Exception`
2015-06-23 22:34:55 -07:00
Doug Bunting 3f6ab3bb03 Add `ModelMetadata.ElementMetadata`
- #2664
- use new property to correctly determine `isTargetEnum` in `GetCurrentValues()`
 - avoid `ArgumentNullException` in all cases where raw values are `enum` but target is not
- stop skipping tests blocked by #2664, exposing a couple more #1487 issues
- use new property instead of private `GetElementType()` methods where possible
 - cleans up some duplicate code
 - also remove redundant use of `IsCollectionType` and `ElementMetadata`

nits:
- move properties above methods in `ModelMetadata`
- avoid accidentally-incorrect "Remove Unnecessary Usings"
2015-06-10 12:02:50 -07:00
Ajay Bhargav Baaskaran 37d1881dad [Fixes #2609] Support for binding all integer types to enums 2015-06-09 16:08:38 -07:00
Ryan Nowak a679e87a9b Split Mvc.Core
This is the first step is some more refactorings to come in the future
with the goal of making MVC less monolythic. This makes the core of MVC
more reusable and more in line with the design of other vNext platform
components.

With this change, Mvc.Core contains just the minimal guts needed to build
a working app.
- Action Discovery
- Action Invoker
- Filters
- ObjectResult
- Model Metadata
- Model Binding
- Formatters
- Validation System

And yes, we are aware of the irony of 'minimal MVC' not including the view
system. The idea is that this is the kernel of an MVC app, and anything
real is layered on top.

The most noticable impact of this change is that MvcOptions has been blown
apart into more managable chunks. See the various ConfigureMvc*** methods.

The new Mvc.Extensions package is a placeholder while we evaluate and tune
the new definitions. Expect more changes as features are move to their own
packages, and in some case their own repositories.

For now there is no experience to bootstrap an Mvc.Core app. That's coming
next.
2015-06-09 02:12:13 -07:00
Harsh Gupta d0927bdc75 Fixes #2464 - Does not add extra skipped entries for model bound from services.
Also ensures that when a type is marked as skipped, any sub property which is model bound (and hence a modelstate un validated entry),
is marked as skipped (otherwise it would cause the ModelState to be invalid).
Also fixing a bug in model state dictionary FindKeyWithPrefix was not considering [0] & [0][0] as a valid prefix.
2015-05-15 12:27:43 -07:00
Doug Bunting 584015c79b A few quick cleanups
- in .kproj files, let VS mark a couple more test projects as such
- remove duplicate `ModelExpression` class
 - not necessary now that test project references MVC Core project
 - follow up to 9fded74
- avoid `resources` warning in project.json files
2015-05-04 11:55:24 -07:00
N. Taylor Mullen 64e726d2b2 Update LICENSE.txt and license header on files. 2015-05-01 13:55:25 -07:00
Doug Bunting 838f672b10 Clean up .xproj files added with HttpAbstractions 2015-04-27 08:12:22 -07:00
Ryan Nowak 572e57e25c Create Mvc.Abstractions
Creates a new package 'Microsoft.AspNet.Mvc.Abstractions' which defines
APIs and contracts for core concepts and extensibility points in MVC.

Includes:
- ModelBinding
- Validation
- Model State
- Model Metadata
- Action Descriptors
- IActionResult
- Filters
- IActionConstraint
2015-04-27 00:49:14 -07:00