Commit Graph

122 Commits

Author SHA1 Message Date
Doug Bunting 5bddd226a3
Use Internal.AspNetCore.Sdk as an MSBuild SDK
- should resolve issues with occasional strange MSBuild caching issues in this repo
- modeled after aspnet/Scaffolding#905
- follows aspnet/BuildTools#729 recommendation to check in global.config file
  - see also Microsoft/msbuild#2914
- use newer KoreBuild
  - `.\build.cmd -update /t:noop`
2018-10-04 15:12:38 -07:00
Doug Bunting 5c8dfef15e
Change `CollectionModelBinder` and `ComplexTypeModelBinder` to enforce `[BindRequired]`
- #8180
- add an error when binding fails for top-level model
  - same case as when MVC creates "default" / empty model i.e. `ParameterBinder` can't detect this
- update `CollectionModelBinder` subclasses and the various providers as well
- controlled by existing `MvcOptions.AllowValidatingTopLevelNodes` option

smaller issue:
- change `ModelBinding_MissingBindRequiredMember` resource to mention parameters too
2018-09-21 11:08:16 -07:00
Doug Bunting c13e2498a8
Create model in `ComplexTypeModelBinder` if ANY property has a greedy binding source
- #7562 part 1
2018-09-18 11:44:37 -07:00
Simon Cropp 43d4416a1d Fix typos (#8413) 2018-09-12 09:34:45 -07:00
Simon Cropp b156dee4f1 Fix some spelling (#8378) 2018-09-06 07:39:01 -07:00
Pranav K 522006d2c8
[Design] Add a MaxValidationDepth option to ValidationVisitor
Fixes #7357
2018-08-16 15:01:18 -07:00
Doug Bunting 35fad0881b
Mark unused `ParameterBinder.BindModelAsync(...)` overloads as `[Obsolete]`
- #7660
- also addresses part of #7317, only in `ComplexTypeModelBinderIntegrationTest`
2018-07-13 13:26:56 -07:00
Hao Kung a5083d525b
Fix regression with Authorize + IPolicyProvider (#8068) 2018-07-12 15:36:03 -07:00
Pranav K e1eaf6a6e0
Cleanup TestCommon 2018-05-18 10:45:57 -07:00
Doug Bunting e0e96ce53b
Include parameter type's attributes in ModelMetadata
- #7595
- #7595 relates to #7350 but does not have the same root cause
  - did _not_ revert the src changes in #7350 fix (d995b0418a)
- make non-`[Obsolete]` `ModelAttributes` constructor overload `internal`
  - should generally use `static` methods and not any constructor
  - change some unit tests to use `[Obsolete]` constructor overloads (with suppressions)
- fix test `ParameterBinderExtensions` to use current `ParameterBinder.BindModelAsync(...)` overload
  - found some tests updated `IModelMetadataProvider`, `MvcOptions`, etc. instances but didn't register them in DI
- extend `ModelBindingTestHelper` and `ModelBindingTestContext`
  - reorder some tests to use correct `MvcOptions` and `IModelMetadataProvider` everywhere
  - fixes above issues

nits:
- take a few VS suggestions
- remove an old comment indended only for PR "Reviewers:"
2018-04-17 12:40:38 -07:00
Doug Bunting cc5ae02b7d
Fix binding & validating dictionaries of non-simple types in jQuery requests
- #7423
- retry failed inner bindings with alternate syntax in `ModelStateDictionary`
  - use property syntax if first attempt tried index syntax and visa versa
- instantiate `ShortFormDictionaryValidationStrategy` with full `ModelState` keys
  - can now provide exact `ModelState` keys that `ModelStateDictionary` used in inner bindings
- normalize model names without a leading period in `JQueryKeyValuePairNormalizer`

nits:
- take a few VS suggestions
2018-04-14 10:41:00 -07:00
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