Inferring FromServices
optionality based on nullability information
#39757
Labels
area-web-frameworks
*DEPRECATED* This label is deprecated in favor of the area-mvc and area-minimal labels
breaking-change
This issue / pr will introduce a breaking change, when resolved / merged.
Docs
This issue tracks updating documentation
feature-model-binding
Milestone
Current design
Currently, when binding
FromServices
always is called theServiceProviderServiceExtensions.GetRequiredService
(that throws anInvalidOperationException
when the service is not found)aspnetcore/src/Mvc/Mvc.Core/src/ModelBinding/Binders/ServicesModelBinder.cs
Line 26 in 6bbd520
Proposed Change
The proposal is following the same approach apply in Minimal APIs, that basically evaluates the default value and nullability context to decide if the parameter is optional or not and call the
ServiceProviderServiceExtensions.GetService
instead when the parameter is optional.aspnetcore/src/Http/Http.Extensions/src/RequestDelegateFactory.cs
Line 866 in 6bbd520
The text was updated successfully, but these errors were encountered: