Skip to content

Adding support to infer FromServices parameters#39926

Merged
brunolins16 merged 9 commits into
dotnet:mainfrom
brunolins16:brunolins16/issues/39667
Feb 8, 2022
Merged

Adding support to infer FromServices parameters#39926
brunolins16 merged 9 commits into
dotnet:mainfrom
brunolins16:brunolins16/issues/39667

Conversation

@brunolins16
Copy link
Copy Markdown
Member

Fixes #39667

@ghost ghost added the area-mvc Includes: MVC, Actions and Controllers, Localization, CORS, most templates label Feb 1, 2022
@TanayParikh TanayParikh added old-area-web-frameworks-do-not-use *DEPRECATED* This label is deprecated in favor of the area-mvc and area-minimal labels and removed old-area-web-frameworks-do-not-use *DEPRECATED* This label is deprecated in favor of the area-mvc and area-minimal labels labels Feb 1, 2022
/// When enabled, the following sources are inferred:
/// Parameters that appear as route values, are assumed to be bound from the path (<see cref="BindingSource.Path"/>).
/// Parameters of type <see cref="IFormFile"/> and <see cref="IFormFileCollection"/> are assumed to be bound from form.
/// Parameters that are complex (<see cref="ModelMetadata.IsComplexType"/>) and are registered in the DI Container (<see cref="IServiceCollection"/>) are assumed to be bound from the services <see cref="BindingSource.Services"/>, unless this
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is the precedence order the same in minimal i.e is IServiceProviderIsService only used for complex types?

Comment thread src/Mvc/Mvc.Core/src/ApplicationModels/ApiBehaviorApplicationModelProvider.cs Outdated
Comment thread src/Mvc/Mvc.Core/src/ApplicationModels/InferParameterBindingInfoConvention.cs Outdated
Comment thread src/Mvc/Mvc.Core/src/ApiBehaviorOptions.cs Outdated
Comment thread src/Mvc/Mvc.Core/src/ApiBehaviorOptions.cs Outdated
Comment thread src/Mvc/Mvc.Core/src/ApplicationModels/InferParameterBindingInfoConvention.cs Outdated
@brunolins16 brunolins16 marked this pull request as ready for review February 7, 2022 22:09
@brunolins16 brunolins16 requested a review from javiercn as a code owner February 7, 2022 22:09
@brunolins16 brunolins16 requested a review from pranavkm February 7, 2022 22:09
Comment thread src/Mvc/Mvc.Core/src/ApplicationModels/InferParameterBindingInfoConvention.cs Outdated
Comment thread src/Mvc/test/WebSites/BasicWebSite/Controllers/ContactApiController.cs Outdated
Comment thread src/Mvc/Mvc.Core/src/ApplicationModels/ApiBehaviorApplicationModelProvider.cs Outdated
@brunolins16 brunolins16 enabled auto-merge (squash) February 8, 2022 00:17
@brunolins16 brunolins16 merged commit 44d89fa into dotnet:main Feb 8, 2022
@ghost ghost added this to the 7.0-preview2 milestone Feb 8, 2022
@brunolins16 brunolins16 deleted the brunolins16/issues/39667 branch August 2, 2022 20:49
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area-mvc Includes: MVC, Actions and Controllers, Localization, CORS, most templates

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Add support for implicit inference of FromServices for types that appear in DI

3 participants