-
Notifications
You must be signed in to change notification settings - Fork 10.4k
Closed
Labels
DocsThis issue tracks updating documentationThis issue tracks updating documentationbreaking-changeThis issue / pr will introduce a breaking change, when resolved / merged.This issue / pr will introduce a breaking change, when resolved / merged.feature-model-bindingold-area-web-frameworks-do-not-use*DEPRECATED* This label is deprecated in favor of the area-mvc and area-minimal labels*DEPRECATED* This label is deprecated in favor of the area-mvc and area-minimal labels
Milestone
Description
Current design
Currently, when binding FromServices
always is called the ServiceProviderServiceExtensions.GetRequiredService
(that throws an InvalidOperationException
when the service is not found)
var model = requestServices.GetRequiredService(bindingContext.ModelType); |
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.
private static Expression BindParameterFromService(ParameterInfo parameter, FactoryContext factoryContext) |
Metadata
Metadata
Assignees
Labels
DocsThis issue tracks updating documentationThis issue tracks updating documentationbreaking-changeThis issue / pr will introduce a breaking change, when resolved / merged.This issue / pr will introduce a breaking change, when resolved / merged.feature-model-bindingold-area-web-frameworks-do-not-use*DEPRECATED* This label is deprecated in favor of the area-mvc and area-minimal labels*DEPRECATED* This label is deprecated in favor of the area-mvc and area-minimal labels