-
Notifications
You must be signed in to change notification settings - Fork 10.4k
Detect services based on service provider #32737
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
+140
−62
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Thank you for submitting this for API review. This will be reviewed by @dotnet/aspnet-api-review at the next meeting of the ASP.NET Core API Review group. Please ensure you take a look at the API review process documentation and ensure that:
|
pranavkm
approved these changes
May 15, 2021
pranavkm
reviewed
May 17, 2021
- As a final fallback, try to detect services from the DI container before falling back to body behavior.
01d048c
to
432b02a
Compare
@halter73 feel free to review this on Monday. I'm merging all of the PRs I've had open to get them in the end to end build for further testing. |
This was referenced Jun 13, 2021
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Labels
api-approved
API was approved in API review, it can be implemented
area-networking
Includes servers, yarp, json patch, bedrock, websockets, http client factory, and http abstractions
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
RequestDelegateFactory.Create
There are some gotchas:
We can't do this at compile time, it's a runtime only feature (for the future). Not a big deal, we know how to handle this for AOT scenarios in the future.There are side effects. Your object will get created once to "test" if it's indeed a service. We could build an optional capability into the DI container for this to avoid the activation.As part of instantiating the object, we need to dispose it. If this object has a scoped lifetime and isIAsyncDisposable
only, this will currently throw an exception.[FromServices]
attribute and by being explicitIt cleans up this scenario nicely:
This PR is now blocked on dotnet/runtime#53919