Commit Graph

2799 Commits

Author SHA1 Message Date
Pranav K 0726b8b98b
Make publicly exposed Roslyn types internal 2018-07-31 11:08:22 -07:00
Pranav K d346255db6
Add analyzer and codefix that suggests removing unnecessary invalid model state validity checks
Fixes #8146
2018-07-30 13:14:20 -07:00
Justin Kotalik 367717760b
Handle subtype with suffix being a subtype without a suffix (#8170) 2018-07-30 12:05:41 -07:00
Pranav K 0102d4efab
Introduce ApiConventionMethodAttribute
Fixes #8147
2018-07-30 11:13:25 -07:00
James Newton-King 41de26a546
Add UseMvc unit tests (#8164) 2018-07-29 16:58:50 +12:00
Ryan Nowak fbae57cde1 React to the removal of EndpointConstraint 2018-07-28 19:03:16 -07:00
James Newton-King c01c7075be
Add EndpointMetadata to ActionDescriptor and hookup CORS (#8158) 2018-07-28 16:12:54 +12:00
Doug Bunting 556880872d
Ensure later validations of `null` models do not overwrite `Invalid` state
- #8078
2018-07-26 13:49:22 -07:00
Doug Bunting 0d427a60e5
Use `TheoryData` properties to avoid duplicate test data
- couldn't just remove duplicate `[TheoryData]` in `GlobalRoutingTest`
  - xUnit analyzers don't understand `[InlineData]` is inherited (though runtime certainly does)
2018-07-26 10:12:50 -07:00
Doug Bunting 498fa2d72f
Avoid `InvalidOperationException` when serializing `SerializableError`
- #8055
- provide unique name (`<Empty-Key>`) for XML elements that would otherwise be nameless

nits:
- remove now-useless Mono special case in updated test class
- extend updated tests to involve square brackets as well as empty keys
2018-07-26 08:56:02 -07:00
James Newton-King f31ab716ee
Change MvcEndpointDataSource to use GetChangeToken (#8137) 2018-07-26 09:20:26 +12:00
Kiran Challa 10ce77b9ca Updated MvcEndpointDataSource to create endpoints with SuppressLinkGenerationMetadata 2018-07-25 06:41:57 -07:00
Ryan Nowak b71d5da05e Fix test break due to 405 returned from routing 2018-07-24 22:15:32 -07:00
James Newton-King c08504b08a
MVC startup experience (#8131) 2018-07-25 14:30:51 +12:00
Kiran Challa 630aeade07 Added tests related to generating urls with route name 2018-07-24 15:06:16 -07:00
Alexej Timonin 52c1e942c6
Added UseCamelCasing and UseMemberCasing extension methods to MvcJsonOptions (#7256) 2018-07-23 10:11:04 -07:00
Ryan Nowak 196e3f109f React to Routing branding
This is a reaction PR for the branding changes in progress in Routing.

This can be merged after the changes to in to Routing.
2018-07-22 19:47:15 -07:00
kishan.anem c0ba374549 Custom error messages with validation message tag helper #8035
#8035
PR #8087
https://github.com/aspnet/Razor/issues/2497
2018-07-22 17:55:06 +05:30
Kiran Challa e1e7ec0f28 Enable couple of skipped Dispatching functional tests 2018-07-21 04:44:38 -07:00
Alexej Timonin d4beab5d09
CompositeValidationAttribute
- Add abstract CompositeValidationAttribute.
- Change DataAnnotationsMetadataProvider.CreateValidationMetadata to
populate ValidatorMetadata with validation attributes from CompositeValidationAttribute.
2018-07-20 15:31:14 -07:00
Ryan Nowak 5c488bf09c make feature branch build 2018-07-20 12:57:43 -07:00
Ryan Nowak 3ba6f35495 React to RoutePattern changes in Routing 2018-07-20 12:57:43 -07:00
Kristian Hellang 53930af0e3 Set ProblemDetails status field during ObjectResult formatting 2018-07-19 17:57:55 -07:00
James Newton-King 36d90c9bc2
Run request service constraint test with dispatching (#8112) 2018-07-19 16:43:51 +12:00
James Newton-King ec8976ffaf
Update MvcEndpointDataSource on raised change token (#8108) 2018-07-19 16:43:24 +12:00
James Newton-King 42218d5fb5
Versioning with endpoint constraint (#8098) 2018-07-17 16:37:45 +12:00
Pranav K b62499e02c
Ensure PageContext.ViewData and ViewContext.ViewData are the same instance
Fixes #7675
2018-07-16 11:16:03 -07:00
Pranav K 9d951325b2
Re-organize shared src packages so we can do true IVT between src assemblies 2018-07-16 11:15:58 -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
Doug Bunting f2608c2ff4
Do not suppress `ModelValidationState.Invalid` entries
- #7992, #7963
2018-07-13 13:21:43 -07:00
Pranav K dfbdb37979
Refactorings for codefix (#8067)
* Refactorings for codefix

- Move some common code in SymbolApiResponseMetadataProvider
- Don't run diagnostics for 1006 if we are unable to parse a return type
2018-07-13 13:05:49 -07:00
James Newton-King f12f9b46ed
Add startup filter to set MiddlewareFilterBuilder.ApplicationBuilder 2018-07-13 12:23:30 +12:00
Hao Kung a5083d525b
Fix regression with Authorize + IPolicyProvider (#8068) 2018-07-12 15:36:03 -07:00
Pranav K 46189abda7 Refactoring for ApiConvention analyzers 2018-07-12 14:26:27 -07:00
James Newton-King a67d9363e2
Consumes endpoint constraint (#8057) 2018-07-12 16:35:33 +12:00
James Newton-King c367e1d681
Fix dispatching functional tests not using dispatching startup (#8052) 2018-07-12 14:19:48 +12:00
James Newton-King 183ecd85d6
Fix MVC integration with UseEndpoint (#8047) 2018-07-11 11:47:33 +12:00
Kiran Challa 0812279464 Merge branch 'release/2.1' into kichalla/21.to.22.mergecommit
# Conflicts:
#	build/dependencies.props
#	korebuild-lock.txt
#	src/Microsoft.AspNetCore.Mvc.ApiExplorer/DefaultApiDescriptionProvider.cs
#	test/Microsoft.AspNetCore.Mvc.Core.Test/Internal/ApiBehaviorApplicationModelProviderTest.cs
#	version.props
2018-07-09 13:00:10 -07:00
Kiran Challa bd995d4cb1 [Fixes #7959] Conventional routing with custom templates not working when you have area attributes 2018-07-09 12:35:14 -07:00
Alexej Timonin dc2ae93c3f
Add fallback attribute to partial tag helper.
Addresses #7515
2018-07-09 12:24:26 -07:00
hishamco dee479fda7
Add partial helper to Razor Page \ PageModel
Fixes #7885
2018-07-09 11:01:15 -07:00
Pranav K d2bb674b0a
Add support for default response (#8028)
* Add support for default response

Fixes #6828
2018-07-06 16:44:07 -07:00
Pranav K 335500ab0e Use ModelMetadata from actual types for validation
Fixes https://github.com/aspnet/Mvc/issues/7952
2018-07-02 11:23:16 -07:00
Alexej Timonin c2fcfabdf3 Add optional property to PartialTagHelper (#7991)
* Add optional to PartialTagHelper

Addresses #7268
2018-06-29 16:02:38 -07:00
Nathanael Marchand 133d49c57e
Fix Api Explorer not returning type with ActionResult<T> and no type in ProducesResponseTypeAttribute 2018-06-29 13:55:30 -07:00
Pranav K 7f2a64e32b
Razor runtime compilation produces errors if running on a shared runtime that's rolled forward
Do not provide compilation references from runtime MVC assemblies. This avoids cases where the app is compiled
against an older MVC but running against a newer one (e.g. shared fx roll forward) resulting in compiling against multiple
versions of MVC assemblies

Fixes #7969
2018-06-29 13:55:22 -07:00
Nathanael Marchand 82f7f2aab8 Fix Api Explorer not returning type with ActionResult<T> and no type in ProducesResponseTypeAttribute 2018-06-29 12:00:16 -07:00
Pranav K c4d5ef94a9 Razor runtime compilation produces errors if running on a shared runtime that's rolled forward
Do not provide compilation references from runtime MVC assemblies. This avoids cases where the app is compiled
against an older MVC but running against a newer one (e.g. shared fx roll forward) resulting in compiling against multiple
versions of MVC assemblies

Fixes #7969
2018-06-29 11:17:25 -07:00
Doug Bunting 192e8073ee
Work around `CryptographicException`s thrown in some full framework test runs
- always skip affected tests on full framework
2018-06-28 15:52:19 -07:00
Kiran Challa 54c14b8782 Reacting to Routing repo's EndpointFinder changes 2018-06-28 12:40:04 -07:00
Doug Bunting 4dd4e5ef3e
Shorten names so MVC repo can be cloned on Windows benchmarks server 2018-06-27 14:33:31 -07:00
kishanAnem e1af5b8b6d Array or List in query string does not get parsed #7712 (#7967)
- exclude collections when detecting complex types in `ApiBehaviorApplicationModelProvider`
- add test cases
2018-06-26 11:43:46 -07:00
Pranav K 94a7c83998
Change DefaultApiConventions (#7939)
* Change DefaultApiConventions

* Introduce attributes for matching by name and type.

* Move discovery of ApiConventionAttribute to ApiBehaviorApplicationModelProvider. This is required
for us to detect during startup if the convention is incorrectly authored.
2018-06-25 08:24:30 -07:00
Doug Bunting 53857d052f
Add BasicApi and BasicViews apps
- #7805
- make initial copy of apps from aspnet/Performance repo
  - add apps to solution
  - add Readme for the benchmark apps
- update BasicApi app to actually do authentication and authorization
  - bug in the ported app
- refactor `Main` methods and add `CreateWebHostBuilder(...)` methods
- change projects to understand `$(BenchmarksTargetFramework)`
  - use NuGet.org EF packages to avoid changing the Universe build graph
- use SQLite instead of LocalDb by default
  - remove unnecessary appsettings.json files and JSON configuration support
- add EF migrations
  - (greatly) reduce startup times compared to creating / deleting databases
- add MySql, PostgreSQL, and SqlServer support
  - load BasicApi data in a `DbContext.OnModelCreating(...)` override
    - no longer need seed.sql
  - generalize migrations to support multiple providers
  - use negative seeding indices to work around npgsql/Npgsql.EntityFrameworkCore.PostgreSQL#36
  - work around Pomelo lack of strong name (PomeloFoundation/Pomelo.EntityFrameworkCore.MySql#603)
  - use BenchmarksOnly* properties for EF dependencies
    - see also aspnet/Universe#1224
- drop databases (if SQLite) or migrations (otherwise) in `IApplicationLifetime.ApplicationStopping` handlers
- add functional tests
  - drop SQLite database at end of test run
- add benchmarks automation
  - add anonymous BasicApi action i.e. require no authorization
  - add non-antiforgery BasicViews actions

Address PR comments
- remove `AntiforgeryTestHelper` workarounds
- use `[ApiController]`
- use `ActionResult<Pet>`
- remove unused classes

nits:
- take VS suggestions in added files
- optionally display create and delete SQL scripts for per-database migrations
- merge `InsertData(...)` calls for consistency with most supported EF providers
  - SQLite is the only one that requires separate `INSERT`s and EF does the splitting
2018-06-22 16:41:17 -07:00
Pranav K 6911e192e4
Add IsRequired and DefaultValue to ApiParameterDescription 2018-06-22 06:51:58 -07:00
Pranav K 17d2545b55
Throw if the type parameter for ActionResult<T> is an action result (#7942)
Fixes #7931
2018-06-21 07:51:12 -07:00
N. Taylor Mullen 2599e0f5cc Fix up a few pieces for the fallback integrity check feature.
- Regenerated test baselines.
- Update code styling in TagHelpers.
- Modified some comments for clarity.
- Renamed fallback integrity attribute for both script and link tags.

#7845
2018-06-20 16:10:52 -07:00
jmhmaine 8a77ed23d3 Added support for ignoring integrity attribute on fallback for the Link TagHelper
- Do not include integrity attribute when asp-fallback-intergrity-check is false
 - Added Unit Tests, manual tests

Addresses #7845
2018-06-20 16:10:52 -07:00
Pranav K 4f7e849cc1
Setting up for ApiConventionAttribute analyzers (#7912)
* Setting up for ApiConventionAttribute analyzers
2018-06-20 15:22:53 -07:00
Pranav K e7ab81fe0b Ensure analyzer package is referenced by Microsoft.AspNetCore.Mvc
Fixes #7684
2018-06-19 16:11:47 -07:00
Ajay Bhargav Baaskaran 3d32b6da2f
Upgrade deps and unskip tests (#7936) 2018-06-19 14:58:40 -07:00
James Newton-King 3547341762
Add support for conventional routes with dispatching (#7928) 2018-06-20 09:02:52 +12:00
James Newton-King 58aa16ee69
Centralize routing and dispatching functional test logic (#7938) 2018-06-19 23:24:15 +12:00
Kiran Challa a0a9c2c585 Integrate Dispatcher's link generator
Related to https://github.com/aspnet/Routing/issues/530
2018-06-19 04:14:05 -07:00
Pranav K e07054e0a7 Skip failing tests 2018-06-18 09:20:08 -07:00
Pranav K a712ccc98a Fix up error message when compilation references are missing 2018-06-18 09:20:08 -07:00
Pranav K 1aea6fd5bd Remove instrumentation functional tests
Fixes #7921
2018-06-15 12:42:37 -07:00
James Newton-King a7406d4497
Add MvcEndpointDataSource and functional tests (#7886) 2018-06-14 11:03:45 +12:00
Pranav K 287a3c5e69 Allow IgnoreAntiForgeryToken applied on Razor Page models to work
Fixes #7795
2018-06-13 11:59:47 -07:00
Pranav K 6c2ef122f8 Add support for conventions in DefaultApiDescriptionProvider 2018-06-11 16:07:09 -07:00
Doug Bunting df6b798117
Remove `xUnit1026` workaround in test projects
- contained a typo (colon versus semicolon) and just doesn't matter
2018-06-08 15:24:36 -07:00
Pranav K c29527f992
Add some assertions for controllers and controller actions 2018-06-08 15:00:19 -07:00
Pranav K f2eb6f8d37 Add some tests for CodeAnalysisExtensions 2018-06-08 14:58:29 -07:00
Pranav K 592ed3b4f5
Create an analyzer to warn users not to decorate filters on page handler methods
Fixes #7684
2018-06-05 17:23:30 -07:00
Kiran Challa 2d63669695 [Fixes #7609] ApiBehaviorApplicationModelProvider overwrites existing BindingInfo in entirety when inferring binding sources 2018-05-30 05:30:10 -07:00
Pranav K 984cd46c4d Fix ActionMethodExecutor incorrectly setting DeclaredType on ObjectResult
Fixes #7782
2018-05-29 14:35:42 -07:00
Pranav K 632425d0e6 Unskip skipped tests 2018-05-29 12:10:59 -07:00
Pranav K 8e31319215
Prevent null refs in some simple cases in CachedExpressionCompiler
Fixes #6928
2018-05-29 11:09:48 -07:00
Ryan Brandenburg edf4e8fd9e DataAnnotations of Enum values use DataAnnotationLocalizerProvider 2018-05-25 16:00:00 -07:00
Kiran Challa 418aac57f4 [Fixes #7609] ApiBehaviorApplicationModelProvider overwrites existing BindingInfo in entirety when inferring binding sources 2018-05-24 14:28:42 -07:00
Pranav K 49c653ed0b Infer BindingSource.FormFile for IEnumerable<IFormFile>
Fixes #7770
2018-05-22 11:05:09 -07:00
Nisha Kaushik 077b1d87a9 #7024 Request: ServiceBasedPageModelActivatorProvider [Review Changes] 2018-05-22 10:23:08 -07:00
Nisha Kaushik b8e5036e20 #7024 Request: ServiceBasedPageModelActivatorProvider 2018-05-22 10:23:08 -07:00
Nisha Kaushik 0c795c4f33 #7024 Request: ServiceBasedPageModelActivatorProvider 2018-05-22 10:23:08 -07:00
Pranav K e1eaf6a6e0
Cleanup TestCommon 2018-05-18 10:45:57 -07:00
Pranav K 624a5ed522 Fix ActionMethodExecutor incorrectly setting DeclaredType on ObjectResult
Fixes #7782
2018-05-18 10:43:28 -07:00
Sébastien Ros 19d82928ba
Making Razor compilation cache replaceable (#7780) 2018-05-15 11:36:47 -07:00
Pranav K d9f035ad7c
CacheTagHelper should be able to vary by culture
Fixes #3398
2018-05-13 14:21:08 -07:00
Pranav K 1ca6ce3377 setupAction parameter in MvcLocalizationServices.AddLocalizationServices is never used
Fixes #7761
2018-05-09 18:12:15 -07:00
Doug Bunting ec2d5c7aa4
Run functional tests with a `TestLoggerFactory`
- #7744
2018-05-08 11:52:20 -07:00
Ryan Brandenburg 9f7629b448 Upgrade to netcoreapp22 2018-05-08 10:51:17 -07:00
Pranav K 26454fb1da Add ViewComponentResult helper methods to Page \ PageModel
Fixes #7051
2018-05-07 16:35:29 -07:00
Pranav K f52c9c0f97 Update analyzer tests to use Microsoft.AspNetCore.Analyzer.Testing 2018-05-07 16:06:01 -07:00
Pranav K 777782ac6e Test cleanup 2018-05-03 16:03:42 -07:00
Kiran Challa 35f7d3f09c Added tests to verify that RazorPages and FuzzyMatching with Head requests work 2018-05-01 14:01:00 -07:00
Ajay Bhargav Baaskaran 595e83d0eb Added nuspec file to Mvc.Analyzers assembly 2018-04-20 14:53:46 -07:00
Pranav K 5d5222cdd8 Introduce BindPropertiesAttribute
* Allow controller and Razor Page models to be annotated with BindPropertiesAttribute
* Disallow BindPropertyAttribute from being declared on types.
* Do not allow arbitrary binding attributes to be applied to Razor Page models.

Fixes #7686
2018-04-20 14:32:14 -07:00
Pranav K 60a9810268 Allow PartialTagHelper to specify a null model. Fixes #7667 2018-04-18 14:16:44 -07:00
Kiran Challa faca3da42f Ensure ViewData is set on PageResult after a handler method executes
[Fixes #7665] Initializing PageResult.Page as part of result execution breaks Identity UI
2018-04-18 11:44:04 -07:00
Kiran Challa 4f7d53f4e7 [Fixes #7658] FileStreamResultExecutor fails to Dispose FileStream 2018-04-18 11:43:09 -07:00
Javier Calvarro Nelson e781cd38cf [Fixes #7635] Provide a way to configure HTTP Client instances 2018-04-17 12:52:56 -07:00
Javier Calvarro Nelson e0b4c13895 [Fixes #7587] Default to Development environment in tests 2018-04-17 12:52:51 -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
Pranav K d8fc2d4009 Fix test failures
* Disable deps file generation in class library project. This workarounds known issue - https://github.com/dotnet/core-setup/issues/3726
* Update RazorProjectRouteModelProvider to not specify a trailing slash. This produces paths with a single slash as opposed to two slashes messing with route creation.
* React to Microsoft.AspNetCore.Mvc.Razor.Extensions.Reference that shows up in the deps file.
2018-04-15 16:31:41 -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
Kiran Challa e52933e4e3 Removed UrlTestEncoder references in tests
This is because with the following commit, Routing no longer depends on DI to get a UrlEncoder and always uses UrlEncoder.Default.
4184b2406d
2018-04-14 06:08:20 -07:00
Kiran Challa d5e044f693 [Fixes #7373] Assigning to the context's Result property, when implementing IPageFilter, causes an exception 2018-04-13 15:11:44 -07:00
Ajay Bhargav Baaskaran bfbd286ab6 Remove usages of obsolete APIs 2018-04-13 14:54:35 -07:00
Pranav K d995b0418a Allow BindPropertyAttribute to be specified on controller classes
Fixes #7350
2018-04-13 13:58:44 -07:00
John Luo c35030267c Update usage of TestSink 2018-04-13 10:21:41 -07:00
Pranav K e34b4e8335
Use DependencyContext.CompileLibraries to determine dependency graph (#7626)
* Use DependencyContext.CompileLibraries to determine dependency graph

Fixes https://github.com/aspnet/Mvc/issues/7617
2018-04-11 15:57:11 -07:00
Pranav K 9cea47fa7d Remove root directory customization options for Razor Pages areas
Fixes #7608
2018-04-11 15:25:31 -07:00
Kiran Challa 62272ad56a Round off file result's LastModifiedDate to whole seconds for correct comparison with http header dates
[Fixes #7572] PhysicalFileResult does not respond 304 Not Modified
2018-04-11 06:43:50 -07:00
Pranav K 3db924003e Use VirtualRazorProjectSystem for Razor tests 2018-04-09 15:27:03 -07:00
Pranav K ec31ff0c28
Throw if multiple Body bound parameters are discovered
Fixes #6963
2018-04-09 11:20:34 -07:00
Pranav K 5e019bd707
Add Microsoft.AspNetCore.All
Fixes https://github.com/aspnet/Mvc/issues/7605
2018-04-06 10:57:59 -07:00
Pranav K 07a1907918
Introduce ViewDataAttribute
Allow properties on controllers, Razor Page and Razor Page models annotatted with [ViewDataAttribute]
to populate ViewDataDictionary

Fixes https://github.com/aspnet/Mvc/issues/6525
2018-04-02 10:31:16 -07:00
Pranav K c515cece8e Use ModelMetadataProvider to infer BindingSource on application model 2018-04-02 09:48:49 -07:00
Kristian Hellang a16504b941 Added failing test for #7546 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
Pranav K 264f9c871e Add an analyzer to warn against the use of IHtmlHelper.Partial and IHtmlHelper.RenderPartial
Fixes https://github.com/aspnet/Mvc/issues/7417
2018-03-29 21:25:54 -07:00
Ryan Nowak d360886b78 Fix #7558 infer [FromRoute] with parameter in ANY route
This changes the logic for when we infer [FromRoute] on an action
parameter from *ALL* to *ANY*.

This means that if a parameter occurs in any route on an ApiController,
we will treat it as [FromRoute]. We think this is the best decision
because it's less ambiguous. If a parameter appears in a route, it won't
be eligible to be bound from query. I think that's good.

If for some reason you want this kind of behavior (route or query) then
we suggest breaking up the actions. This isn't very documentation
friendly (swagger) so we don't suggest it.
2018-03-29 07:54:39 -07:00
Doug Bunting fc3a815e57
Restore `ModelMetadata.PropertyName != null` behaviour
- #7413 part 2 of 2
- add `ModelMetadata.Name` and `ParameterName`
  - use `Name` instead of `PropertyName` in most cases
- update `ModelMetadata.ContainerType` and other property use
  - choose using `MetadataKind` almost everywhere; support all possibilties
    - usually parameter metadata was possible but not handled
    - worst case was one or two potential NREs, especially `ContainerType.*` dereferences
  - improve `MvcCoreLoggerExtensions` metadata handling
    - add three new debug messages, one for type metadata and two for parameter metadata
- update `ModelMetadata.ContainerMetadata`, `ContainerType` and `PropertyName` doc comments
- no changes needed in Microsoft.AspNetCore.Mvc.ViewFeatures because parameters aren't viewed

nits:
- add missing `TestModelMetadataProvider.ForParameter(...)` method
- remove unused `EmptyModelMetadataProvider` instances in `ModelMetadataTest`
- refactor `ModelValidationResultComparer` out of DataAnnotationsModelValidatorTest`
- take VS suggestions, mostly related to variable inlining and object initializers
2018-03-29 07:22:00 -07:00
Pranav K f8e315d03d
CompiledPageRouteModelProvider should de-dup descriptors
Fixes #7543
2018-03-28 11:24:49 -07:00
Ryan Nowak c93c168df3 Add mapping service for action results
This allows the use of custom 'envelope' types like ActionResult<> with
a corresponding API Explorer implementation.

Basically this PR services to decouple a bunch of infrastructure from
ActionResult<>.
2018-03-27 17:13:41 -07:00
Pranav K 927af3125e
Use RazorCompiledItemMetadataAttribute to calculate route 2018-03-27 12:24:37 -07:00
Kiran Challa 0c084fa28a [Fixes #7518] NullReferenceException thrown when Controller method uses Guid parameter default value 2018-03-27 05:22:20 -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
Javier Calvarro Nelson 51784bb2d6
[Fixes #7541] Per-test class customization should not remove global (per-fixture) customization 2018-03-24 18:33:48 -07:00
N. Taylor Mullen e94d77c47f Add model attribute for PartialTagHelper.
- The model attribute is used to define any object based model to be passed to a `TagHelper`. It enables scenarios when users want to pass in `new` poco types.
- Added unit tests for the new `ResolveModel` method in `PartialTagHelper`.
- Added a single functional test to verify the end-to-end.

#7374
2018-03-23 16:13:55 -07:00
Ryan Nowak 1ff5bdca79 Set model prefix for [ApiController]
Infers the 'empty' model prefix for complex types that are read from the value
providers. This gives us better defaults when using the parameter object
pattern with respect to swagger/API explorer.
2018-03-23 14:49:54 -07:00
Ryan Nowak 14429721d9 Make handler selector more flexible
Some details of this pending discussion, but this is a new 2.1 change
and compatibility switch in the spirit of making pages handler selection
less error-prone.

In particular we don't want anyone to have to define HEAD to do the
trivial thing. This currently routes all 'safe' HTTP methods to the GET
handler and all other HTTP methods to the POST handler.

This is technically not the correct thing to do for OPTIONS and TRACE,
so we might still do something different.

The tests will change a little depending on exactly what we decide to
do, but this is the main idea of the change.
2018-03-23 14:22:48 -07:00
Pranav K 1d6c09ab31 Make the use of Assembly.CodeBase more robust 2018-03-23 09:35:55 -07:00
Pranav K ccb6793126
Introduce LifecycleProperty
Update TempDataAttribute infrastructure to use LifecycleProperty
2018-03-22 10:18:36 -07:00
Pranav K d6176ac7de ApplicationPartFactory: The works 2018-03-21 15:40:15 -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
Javier Calvarro Nelson 908e7a863b Improvements to the MVC testing package
* Clean up unnecessary workarounds on the build project.
* Remove the need to specify the content root relative to the solution
  and use a solution based on an assembly level attribute on the test
  assembly created at build time.
* Remove non parameterless constructors.
* Add support for creating specialized factories from the base factory
  and keep track of "child" factories for disposal.
* Add support for creating clients that handle cookies and redirects
  automatically.
2018-03-19 12:19:45 -07:00
Doug Bunting 869825b16c
Quick fix: Add test of #2890
- tests added (ages ago) in aspnet/Mvc@a045324 no longer fail when `__` handling removed
2018-03-19 11:59:52 -07:00
Kiran Challa e2b6975bff Marked PageArgumentBinder type as Obsolete 2018-03-19 11:50:20 -07:00
Kiran Challa 09b5ff7b72 Use ParameterInfo for getting metadata of a parameter to show the correct information in ApiExplorer
[Fixes #7435] 2.1-Preview 1: IsBindingRequired and IsRequired still false with RequiredAttribute on controller parameter.
2018-03-19 11:50:19 -07:00
Pranav K e7b2e3fe2d Stop building\testing on netcoreapp2.0 2018-03-19 10:09:51 -07:00
Pranav K ae2d82c748 Remove FiltersWebSite 2018-03-16 16:54:10 -07:00
N. Taylor Mullen 4e7d1a5a32 Rename PartialTagHelper `asp-for` to `for`.
#7379
2018-03-15 16:07:13 -07:00
Ajay Bhargav Baaskaran 90b07a9e9a Enable RazorCompileOnBuild of test website 2018-03-14 15:37:49 -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
Pranav K 62fdf3a472 Fix issues with RazorCompileOnBuild=true being default 2018-03-09 14:39:18 -08:00
Ryan Brandenburg 9b4b373014 Remove IErrorDescriptionFactory 2018-03-07 13:09:13 -08:00
Pranav K 5af246b554 Ignore constructors when discovering actions 2018-03-06 17:42:53 -08:00
Jass Bagga f3ffdada95
Remove problem+json Content-Type (#7440)
Addresses #7344
2018-03-06 13:46:40 -08:00
Pranav K 3517ecda2f Ensure DebugType = embedded and DebugType = none work
Fixes #7406
2018-03-05 09:21:13 -08:00
Doug Bunting f061d328d9
Do not use `FormattedModelValue` in password editor template
- #7418
- add quirk switch to reverse this if necessary
2018-03-05 08:33:16 -08:00
Jass Bagga 8d1c85ab74
Add overload for AddModelError without ModelMetadata (#7407)
Addresses #6102
2018-03-02 11:03:46 -08:00
Doug Bunting daf341df35 Add more tests of #7033 scenarios 2018-02-21 15:11:52 -08:00
Charlie Daly 4f3e044928 HtmlHelper.DisplayTextFor should use DisplayAttribute of enums
- #7033
2018-02-21 15:11:51 -08:00
N. Taylor Mullen 43106f688a Re-enable "Move to RazorProjectEngine."
- This was initially reverted due to insufficient packages for local builds.

This reverts commit 5ac6fa77f8.
2018-02-16 16:13:54 -08:00
Ryan Nowak 9df6ba8c4f Add MVC Razor msbuild files 2018-02-16 07:54:37 -08:00
N. Taylor Mullen 5ac6fa77f8 Revert "Move to RazorProjectEngine."
- Waiting for packages to be available from Razor.

This reverts commit 608330dc86.
2018-02-15 17:01:07 -08:00
N. Taylor Mullen 608330dc86 Move to RazorProjectEngine.
- Updated our consumption of `RazorEngine` and `RazorTemplateEngine` to use `RazorProjectEngine` and its features.
- Updated service registrations to maintain existing services but to also register new ones.
- When moving `RazorViewEngine` to use `RazorProjectFileSystem` I had to add an unused constructor item in order to disambiguate the constructors.
- Updated tests to use `RazorProjectEngine` and `RazorProjectFileSystem`.

#7377
2018-02-15 16:34:26 -08:00
Pranav K 06e40252a0 Add support for top level validation to Razor Pages 2018-02-14 14:39:25 -08:00
Artak Mkrtchyan e308c0fe5f
Merge pull request #7290 from FabienLavocat/dev
Add constructor for the SelectListItem class
2018-02-06 16:29:57 -08:00
Jass Bagga d27e66a8fc
Initialize ViewContext for TagHelperComponentTagHelper (#7326)
Addresses #7017
2018-02-06 16:07:38 -08:00
Fabien Lavocat c062d637fe Add new contructor in SelectListItem.cs 2018-02-06 11:01:24 -08:00
Artak Mkrtchyan 7a13eb8b21 Addressed review feedback 2018-02-01 14:44:06 -08:00
Artak Mkrtchyan dea3eb7856 Not instantiating the RequestHeaders and not relying on TypedHeaders to parse AcceptCharset 2018-01-31 17:20:29 -08: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
Pranav K dbff416be6 Add support for running conventions on controller properties, Razor Page parameter and properties
Fixes #6935
2018-01-29 11:43:25 -08:00
Javier Calvarro Nelson 7127bb5dbb Add DeclaredModelType to Razor pages
* This allows razor pages to override their model type with a model that
  extends the declared model type through the page application model.
2018-01-25 16:00:54 -08:00
Pranav K b30020a655 PartialTagHelper should not fallback to the current page's model if asp-for expression exists
Fixes #7295
2018-01-25 11:06:40 -08:00
Pranav K a74ef9dfd9 Error message for [ApiController] without attribute route needs to be better
Fixes #7277
2018-01-25 10:25:52 -08:00
Artak Mkrtchyan 4f3e0966d9 Enabling antiforgery tests, which were disabled because of the #7040 issue 2018-01-23 19:16:24 -08:00
Javier Calvarro Nelson 17a407bba2 [Fixes #7271] Support covariant casting of ViewDataDictionary<T>
On HtmlHelper<T> we now support contextualizing an instance of
HtmlHelper<TBase> with a ViewDataDictionary<TDerived> in
ViewContext.ViewData.

This can happen in some situations when the model for a RazorPage has
been changed using a page application model convention.

In these cases we just build a new ViewDataDictionary<TBase> and pass in
the TDerived model as an instance.
2018-01-23 17:31:03 -08:00
Ryan Brandenburg ea14942525 React to Options change 2018-01-23 08:07:45 -08:00
Pranav K ebdb3c650a Smooth rough ApiBehavior edges
Fixes #7262
2018-01-22 09:53:21 -08:00
Ajay Bhargav Baaskaran 2c6ba372c1 Some cleanup around FileProviderRazorProject with tests 2018-01-21 21:38:25 -08:00
Javier Calvarro Nelson 1d6b02c1f5 [Fixes #7239] Add support for loading additional parts.
* Support loading parts through an assembly metadata attribute with a
  key of Microsoft.AspNetCore.Mvc.AdditionalReference and a value that
  describes the additional assembly to add to the list of parts and
  whether or not it should be added by default. The additional reference
  can only contain the file name of the assembly and it must be located
  side by side with the assembly where the additional reference is
  defined.
* Add an AdditionalAssemblyPart application parts to represent parts
  that are not part of the original application per se, like precompiled
  views.
* Update the ViewsFeatureProvider to search for razor views in the
  application part directly instead of trying to load the precompiled
  views assembly part.
2018-01-21 08:02:20 -08:00
Pranav K c6c77dd4d3 Introduce Mvc analyzers 2018-01-19 16:02:50 -08:00
Ryan Nowak f2d6cfa821 Update checksums
These are generated based on an incorrect version of the file. This code
is now testing the right thing.
2018-01-18 10:54:15 -08:00
Pranav K f0ae0ce528 Add PageConvention overloads for areas
Fixes #7246
2018-01-18 08:21:21 -08:00
John Luo 6751e3b7ca Discover assembly parts for Microsoft.AspnetCore.All 2018-01-17 13:20:09 -08:00
Pranav K ab3134e373 Support conflict resolution when multiple precompiled views have the same path
Fixes #7223
2018-01-16 08:04:39 -08:00
Pranav K 946b64143e Allow override routes on Pages
Fixes #6605
2018-01-12 15:57:13 -08:00
Pranav K 094b61dfc6 Refactor PageRouteModel generation 2018-01-12 15:44:23 -08:00
Jass Bagga 66c13ae5e5
Use weak comparison for If-None-Match header (#7237) 2018-01-12 12:40:51 -08:00
Ryan Nowak d342ebf8c8 Use compatibility switch for auth filters 2018-01-11 17:42:32 -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
Ajay Bhargav Baaskaran b20e35e76a Set RelativePhysicalPath in FileProviderRazorProjectItem 2018-01-11 13:20:17 -08:00
Jass Bagga 9438a453b0
Do not serve response body for HEAD requests (#7230)
Addresses #7208
2018-01-11 12:19:43 -08:00
Kiran Challa 2aae8774f6 [Fixes 7139] Add format filter mapping for xml formatters 2018-01-10 15:18:37 -08:00
Kiran Challa 00c6b53b06 [Fixes #7115] Update property type check in SaveTempDataPropertyFilterBase to match TempDataSerializer requirements 2018-01-10 15:08:01 -08:00
Pranav K b196708a3e Merge tag '2.0.2' into dev 2018-01-10 10:02:54 -08:00
Ryan Nowak 95d743e2c6 Renable compatibility switch functional tests 2018-01-09 22:24:19 -08:00
Doug Bunting 58026eacbd Correct a few model binding typos
- worst cases were incorrect references in doc comments
- also a few doc comments ended with `..` or `/`
- otherwise, address nits and take VS suggestions
2018-01-09 12:49:40 -08:00
Ryan Nowak 913cefdea2 Fix a bug blocking recompilation 2018-01-09 12:25:11 -08:00
Nick Mayne 6bd421d197 Fixing BackSlashExpander class name 2018-01-09 11:30:27 -08:00
Doug Bunting afc75a8296 Move `IHttpRequestStreamReaderFactory` from `.Internal` to `.Infrastructure`
- #7044
- move `IHttpResponseStreamWriterFactory` too
- add breaking change records e.g. for changes to `BodyModelBinder[Provider]` constructors
  - these changes relate to previously-"internal" constructors and one property

nits: take VS suggestions for changed files
2018-01-09 10:51:09 -08:00
Doug Bunting c9ac2e6c29 Add `DisplayMetadata.NullDisplayTextProvider` and similar properties
- #6730
- `DisplayFormatStringProvider`, `EditFormatStringProvider`

nits:
- use `<see langword="null"/>` more
- accept VS suggestions in changed files
2018-01-09 09:01:57 -08:00
Doug Bunting ecedbd5372 Allow `null` or empty `fullName` in one special case
- #6662
- users can now provide a `name` or `data-valmsg-for` attribute to avoid `ArgumentException`s
  - affects `<input>`, `<select>`, `<textarea>` elements and validation message `<div>`s
- remove `fullName` check in `DefaultHtmlGenerator.GetCurrentValues(...)` entirely

The new workaround is _not_ identical to changing `ViewData.TemplateInfo.HtmlFieldPrefix`
- does not change where expression values are found in `ModelState` or `ViewData`
- likely needs to be combined with additional workarounds i.e. for advanced use only

nits:
- clean up some excessive argument naming; add a few missing argument names
- take VS suggestions in changed classes e.g. inline a few variable declarations
- clean up some test data
2018-01-09 08:53:37 -08:00
Ryan Nowak 75e3ed952b Update functional tests 2018-01-08 19:55:01 -08:00
Ryan Nowak d58d0f917f Add support for recompilation 2018-01-08 15:26:20 -08:00