Commit Graph

4004 Commits

Author SHA1 Message Date
Pranav K c7559e1ff4
Merge pull request #7590 from aspnet/release/2.1
Release/2.1
2018-04-02 09:49:14 -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
N. Taylor Mullen ebd328853c Merge branch 'release/2.1' into dev 2018-03-30 17:12:35 -07:00
N. Taylor Mullen 7d1576a65d Fix MVC being able to build in VisualStudio. 2018-03-30 17:12:10 -07:00
Pranav K aebea720ed
Merge pull request #7582 from aspnet/release/2.1
Target a lower TFM
2018-03-30 14:46:07 -07:00
Pranav K 30f0883319 Target a lower TFM 2018-03-30 14:45:42 -07:00
Pranav K 35bf14e972
Merge pull request #7581 from aspnet/release/2.1
Make Microsoft.AspNetCore.Mvc depend on Microsoft.AspNetCore.Mvc.Anal…
2018-03-30 14:20:51 -07:00
Pranav K 133dd964ab 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-03-30 14:19:52 -07:00
Pranav K 61f260e386 Make Microsoft.AspNetCore.Mvc depend on Microsoft.AspNetCore.Mvc.Analyzers 2018-03-30 12:34:08 -07:00
Pranav K 6f03496448 Make Microsoft.AspNetCore.Mvc depend on Microsoft.AspNetCore.Mvc.Analyzers 2018-03-30 12:33:45 -07:00
Pranav K 577c2745d5
Merge remote-tracking branch 'origin/release/2.1' into dev 2018-03-29 21:51:45 -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
Ryan Nowak 7a1096a72b 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.
2018-03-29 21:35:03 -07:00
Ryan Nowak 96f29c5696 Use latest compat version in MvcSandbox 2018-03-29 21:35:03 -07:00
Pranav K 4b15ad60b1
Merge pull request #7575 from aspnet/release/2.1
Add an analyzer to warn against the use of IHtmlHelper.Partial and IH…
2018-03-29 21:26:17 -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
Doug Bunting 24eaa740f5
Merge pull request #7570 from aspnet/release/2.1
Merge to `dev`: Restore `ModelMetadata.PropertyName != null` behaviour
- and: Fix #7558 infer [FromRoute] with parameter in ANY route
2018-03-29 08:22:37 -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 dae280b06a
Update dependencies.props 2018-03-28 11:29:27 -07:00
Pranav K f55730676b
Merge branch 'release/2.1' into dev 2018-03-28 11:29:05 -07:00
Pranav K 8960f605fc
Merge commit 'de3f77c34b33d5ce7f4e2a8dac12234b01cd4419' into dev 2018-03-28 11:29:00 -07:00
Pranav K f8e315d03d
CompiledPageRouteModelProvider should de-dup descriptors
Fixes #7543
2018-03-28 11:24:49 -07:00
Nate McMaster (automated) de3f77c34b
Update dependencies.props
[auto-updated: dependencies]
2018-03-28 10:56:00 -07:00
Ryan Nowak 599d1a502e Merge branch 'release/2.1' into dev 2018-03-27 17:14:24 -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 a72b56f49e
Merge branch 'release/2.1' into dev 2018-03-27 12:29:36 -07:00
Pranav K 927af3125e
Use RazorCompiledItemMetadataAttribute to calculate route 2018-03-27 12:24:37 -07:00
Pranav K 711a0d7003
Merge remote-tracking branch 'origin/release/2.1' into dev 2018-03-27 12:15:34 -07:00
Pranav K 62fec52a9f Add a framework specific reference to Microsoft.DiaSymReader.Native
Fixes https://github.com/aspnet/Mvc/issues/7478
2018-03-27 12:08:46 -07:00
Kiran Challa 203ebb64ed Updated dependencies.props 2018-03-27 10:07:35 -07:00
Kiran Challa 1186fa66ab Merge branch 'release/2.1' into dev 2018-03-27 10:06:51 -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 79c4986685
Merge branch 'release/2.1' into dev 2018-03-26 12:36:45 -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
ASP.NET CI fa629cd5e1 Update dependencies.props
[auto-updated: dependencies]
2018-03-25 15:48:27 -07:00
Javier Calvarro Nelson 94d60de310 Merge remote-tracking branch 'origin/release/2.1' into dev 2018-03-24 18:35:22 -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 739c8bb1dd Merge remote-tracking branch 'origin/release/2.1' into dev 2018-03-23 16:23:08 -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 db6aed7f36 Merge branch 'release/2.1' into dev 2018-03-23 14:50:36 -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 994b08844c Merge branch 'release/2.1' into dev 2018-03-23 14:24: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 bb408e9f18
Merge pull request #7534 from aspnet/release/2.1
Release/2.1
2018-03-23 09:38:37 -07:00
Pranav K 1d6c09ab31 Make the use of Assembly.CodeBase more robust 2018-03-23 09:35:55 -07:00
Pranav K 56501cb8a0 Cleanup ApplicationPartFactory 2018-03-23 09:35:55 -07:00
Ryan Brandenburg 8590bb9367 Updating baselines 2018-03-22 14:39:58 -07:00
Pranav K 12f8e10e1a
Merge branch 'release/2.1' into dev 2018-03-22 14:22:46 -07:00