Commit Graph

111 Commits

Author SHA1 Message Date
Pranav K c515cece8e Use ModelMetadataProvider to infer BindingSource on application model 2018-04-02 09:48:49 -07:00
Ryan Nowak f20bf9ea02 Fix #7503 change to model name for IValidableObject
This change undoes a breaking change introduced by the 2.1 model
validation changes. Now an implementation of IValidableObject on a
top-level model will be called correctly with the 'empty' prefix instead
of the parameter name.

When fixing this we undid a workaround for another issue.

When validating a parameter that didn't bind we didn't correctly compute
the model name for 'fallback to empty prefix' cases.

(cherry picked from commit 7a1096a72b)
2018-03-29 21:35:59 -07:00
Doug Bunting 5e245da326
Add compatibility switch controlling parameter metadata and top-level validation
- #7413 part 1 of 2
- made all `ModelMetadataProvider` and `ObjectModelValidator`-specific code conditional
  - fortunately, `MvcOptions` easy to get; affected code is primarily `internal` or pub-`Internal`
  - remove unnecessary `ModelMetadataProvider` use in `ApiBehaviorApplicationModelProvider`
- run integration and functional tests with `CompatibilityVersion.Version_2_1`
  - functional test change depends on @javiercn's recent #7541 fix
  - remove test code now redundantly turning compatibility switches on

nits:
- correct spelling errors in `CompatibilitySwitch`
- take VS suggestions, mostly in test code
- rename methods in `ControllerBinderDelegateProviderTest` to match current API
- slightly refactor in `ApiBehaviorApplicationModelProvider`
2018-03-26 12:29:04 -07:00
Doug Bunting 390ebbb258
Do not bind `"[index]"` in `CollectionModelBinder` subsetting feature
- #7091
- add `IKeyRewriterValueProvider` to remove rewritten keys or value providers containing such keys
  - similar to `IBindingSourceValueProvider` except `CompositeValueProvider` keeps non-implementers around
- remove `after.Order == before.Order` special cases
  - a premature optimization that could lead to lost inner provider replacements
  - rework `EnumerableValueProviderTest` to ease test override in `CompositeValueProviderTest`
- add `EmptyValueProvider` fields to reduce `CompositeValueProvider` allocations

nits:
- remove Linq use in `CompositeValueProvider`
- do not create an unnecessary dictionary in `CompositeValueProvider.Filter(...)` methods
- accept VS suggestions, mostly pattern matching
2018-03-19 12:53:05 -07:00
Kiran Challa a0b1b15101 [Fixes #7412] AspNetCore 2.1 breaks integration with 3rd party validation libraries 2018-03-13 02:07:56 -07:00
Kiran Challa a952313f1c Added JQueryQueryStringValueProviderFactory and JQueryQueryStringValueProvider
[Fixes #6372] jQuery ajax request with complex data does not work with .net core 1.1 model bindings
2018-03-12 16:40:04 -07:00
Kiran Challa 0215740183 [Fixes #5859] Consider allowing binding header values to types other than string and string collections 2018-01-30 11:47:16 -08:00
Kiran Challa c922b0b90d Improving logging - model binding
Related to issue #6498: When enabling "Trace" logging for MVC loggers, I should be buried in log messages
2018-01-11 14:51:53 -08:00
Hao Kung 73bd09dc1c Add CombineAuthorizeFilters option 2018-01-08 11:59:30 -08:00
ASP.NET CI 2e73bab2a4 Move option for JSON errors to MvcJsonOptions
This was in the wrong place - JSON formatters have their own options
type already.

Moved the option to MvcJsonOptions and updated the naming + defaults to
reflect our plan.

Also did a bunch of general cleanup on these tests, which were a bit
sloppy.
2018-01-07 21:48:58 -08:00
Jeremy Skinner 711a618310 Adds test for proposal in #7014 2017-11-22 07:50:37 -08:00
Pranav K b6144142fe Update samples and tests to target netcoreapp2.1 2017-11-13 14:58:40 -08:00
Steve Sanderson d9825d1547 Better JSON deserialization errors. Implements #4607, #4862 2017-11-06 23:02:13 +00:00
Nate McMaster 2e4bc548f5
Pin tool and package versions to make builds more repeatable (#7013) 2017-10-31 19:18:14 -07:00
Pranav K 41efa409a4 Remove TestOptionsManager 2017-10-30 17:49:15 -07:00
Nate McMaster 3f02482617 Minor test code changes to resolve xUnit2013 build error 2017-10-05 16:04:20 -07:00
Steve Sanderson 236ef5d1d1 Support validation and BindBehavior on top-level action parameters and bound properties. Fixes #6790 2017-09-22 10:13:48 +01:00
bchavez 16c267d95e House Cleaning - Spelling and grammar 🚿 2017-08-30 14:58:44 -07:00
Nate McMaster b811e69d00 Use PackageLineup to manage PackageReference versions
- Move the Mvc.Performance project from test/ to benchmarks/.
 - Remove the Version attribute on PackageReference.
 - Add a reference to two PackageLineup's.
 - Add snippet to README explaining the additional requirement to run build.cmd /t:restore.
 - Add a target to check that packages have been pinned.
2017-08-30 12:14:11 -07:00
Nate McMaster 3a710c3d64 Upgrade to xunit 2.3.0-beta4 2017-08-17 10:45:03 -07:00
Nate McMaster b43b244830 Use Directory.Build.props/targets 2017-08-16 12:30:13 -07:00
Doug Bunting c351712419 Add `FloatingPointTypeModelBinderProvider` and related binders
- #5502
- support thousands separators for `decimal`, `double` and `float`
- add tests demonstrating `SimpleTypeModelBinder` does not support thousands separators for numeric types
- add tests demonstrating use of commas (not thousands separators) with `enum` values
2017-07-03 17:55:04 -07:00
Javier Calvarro Nelson 728b96344d [Fixes #6274] Fix and re-enable skiped test 2017-07-03 13:00:38 -07:00
Doug Bunting a90f4118ad Do not include type names in `ModelState` error messages
- #6076
- add resources and accessors specifically for the element / parameter cases
- avoid `metadata.GetDisplayName()` where possible
- fill in the `ValidationContext` that `ValidatorObjectAdapter` uses
  - e.g. `Validate_NestedComplexType_IValidatableObject_Invalid()` test fails without this

Possible future work:
- improve error message used for `ModelMetadata.IsRequired` elements and parameters
- use something besides the type for `ValidationContext.DisplayName` of elements and parameters

nits:
- trailing whitespace
- use more `out var`
2017-06-28 15:16:23 -07:00
Ryan Nowak 0ad9c7d4eb Making Pages Binding Consistent
This changeset reckonciles the binding work we did for pages with
controllers.

A quick summary:
- Moves [BindProperty] to the MVC namespace (#6401)
- Makes [FromRoute] and friends behave consistently (#6402)
- Makes [BindProperty] work with controllers (untracked)
2017-06-26 18:11:44 -07:00
Pranav K a5f3a6425e Remove TaskCache and TaskCacheOfT 2017-06-08 08:19:20 -07:00
Ryan Brandenburg 03404cd3df Return to NetStandard 2017-05-25 10:34:16 -07:00
Nate McMaster d70bfdd1ea Upgrade test framework versions and fix test issues 2017-05-15 14:11:27 -07:00
Steve Sanderson 014a786b45 Replace IModelBindingMessageProvider with new highly-virtual base class (#6241)
Replace IModelBindingMessageProvider with new highly-virtual base class. Fixes #6069
2017-05-10 16:02:18 +01:00
Pranav K 64ffcfaa89 Merge pull request #6236 from aspnet/rel/2.0.0-preview1
Change TFM to netcoreapp2.0 (#6234)
2017-05-04 22:18:48 -07:00
Pranav K 1c5e417606 Change TFM to netcoreapp2.0 (#6234)
* Change TFM to netcoreapp2.0
2017-05-04 18:11:26 -07:00
Sébastien Ros 525a479660 Fixing ExcludeBindingMetadataProvider unit test (#6113)
Fixes #6110
2017-04-27 11:42:06 -07:00
Steve Sanderson 90acd055fe Make [FromBody] treat empty request bodies as invalid (#4750) 2017-04-10 16:55:14 +01:00
Kiran Challa 19cb15be54 Revert "Skipping model validation tests temporarily to unblock mirror"
This reverts commit e25bfa8919.
2017-04-03 17:13:49 -07:00
Kiran Challa e25bfa8919 Skipping model validation tests temporarily to unblock mirror
- A fix was already checked in f3d0e4d0dd but this did not make into the netcoreapp2.0 shared runtime
2017-03-31 12:38:10 -07:00
Pranav K e7101f248a Support model binding to Razor Pages properties on page and PageModel classes
Fixes #5952
2017-03-24 07:45:19 -07:00
Pranav K badb6ce8e5 Remove net451 as a cross-compile target 2017-03-22 06:32:50 -07:00
Nate McMaster 6f7717a381 Unify dependency versions to one file 2017-03-15 16:54:32 -07:00
N. Taylor Mullen acfad83aa6 Migrate to MSBuild
- thanx to @NTaylorMullen for initial conversion
  - e.g. AssemblyInfo.cs files were already minimized or removed :)
- allow `>=` RC3 CLI's to build and run MVC
- work around several dotnet migration issues; see #5482
- disable full .NET Framework runs of functional tests; see #5873
- remove `Microsoft.DotNet.InternalAbstractions` and `System.Xml.XmlDocument` dependencies
- remove project.json (!!), *.xproj, .notest, and web.config files

Redo earlier changes:
- apply test migration to .NET 4.5.2 in *.csproj world
  - see 63507c8 for previous, project.json work
- apply dependency version downgrade from 0097e40 in *.csproj world

Make other test-related changes:
- make Microsoft.AspNetCore.Mvc.TestDiagnosticListener a regular class library
- add support for `/p:GenerateBaselines=true` for functional and Razor.Host tests
- separate `GetCSharpTypeName_ReturnsCorrectTypeNames_ForOutParameter()` test
  - work around inability to deserialize a odd `ref` type
  - xUnit and vstest now serialize / deserialze test data more often
- skip poor test mentioned in #5768
- work around Microsoft/vstest#392
  - rename tests to avoid duplicates
- work around Microsoft/vstest#419
  - set up created `AppDomain`s with current `ApplicationBase`
2017-02-28 21:20:39 -08:00
Doug Bunting 63507c8da9 Bump test projects up to .NET 4.5.2
- aspnet/Testing#248
- xUnit no longer supports .NET 4.5.1
- update AppVeyor config so this framework version is available
- build tests for desktop .NET only on Windows
2017-02-21 07:15:36 -08:00
Jass Bagga 927e75870d Add BindingSourceMetadataProvider
Addresses #5673
2017-02-17 13:22:10 -08:00
Nate McMaster 0097e40e46 Downgrade to stable packages 2017-02-15 14:23:48 -08:00
Kiran Challa a00acceaa9 Merge branch 'rel/1.1.2' into dev 2017-02-15 12:43:37 -08:00
Kiran Challa 29647fda33 [Fixes #5801] Move call to validate constructor in ComplexTypeModelBinder into CreateModel 2017-02-15 12:33:01 -08:00
Doug Bunting fc40985412 Merge branch 'rel/1.1.2' into dev 2017-02-10 14:55:32 -08:00
Kiran Challa 842d661ac2 [Fixes #5698] Regression in 1.1 model binding for model types without default constructor
- Also reverts "Check for default constructor in ComplexTypeModelBinderProvider" commit d09e921c4a.
2017-02-10 11:10:02 -08:00
Doug Bunting ce53675b87 Add `[ValidateNever]` and `IPropertyValidationFilter`
- #5642
- lazy-load `ValidationEntry.Model`
  - avoids `Exception`s when moving to a property that will not be validated

nits:
- remove duplicate code in `ValidationVisitor`
- clarify "all properties of" doc comments
  - also add missing `<param>` doc in `ViewDataInfo`
2017-01-15 21:40:29 -08:00
Pranav K 2b50ec99df Updating to 4.4 CoreFx packages 2016-12-21 16:47:14 -08:00
Pranav K 5b2a4aecb6 Make Microsoft.AspNetCore.Mvc.TestCommon a regular project
* This allows specifying all it's dependencies rather than for consuming projects to do this
* Remove unused APIs
* Fix weird downgrade warnings that show up due to P2P references
2016-11-23 16:23:56 -08:00
Pranav K 74c9194aee Pinning versions for 1.1.0 release 2016-11-18 12:12:52 -08:00