Skip to content
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

Add support for IServiceProviderIsService #54047

Merged
merged 6 commits into from
Jun 11, 2021

Conversation

davidfowl
Copy link
Member

  • This optional service lets consumers query to see if a service is resolvable without side effects (not having to explicitly resolve the service).
  • Added new spec tests to verify the baseline behavior based on IServiceCollection features.

Fixes #53919

- This optional service lets consumers query to see if a service is resolvable without side effects (not having to explicitly resolve the service).
- Added new spec tests to verify the baseline behavior based on IServiceCollection features.
@davidfowl davidfowl requested a review from pakrym June 11, 2021 05:08
@dotnet-issue-labeler
Copy link

Note regarding the new-api-needs-documentation label:

This serves as a reminder for when your PR is modifying a ref *.cs file and adding/modifying public APIs, to please make sure the API implementation in the src *.cs file is documented with triple slash comments, so the PR reviewers can sign off that change.

@ghost
Copy link

ghost commented Jun 11, 2021

Tagging subscribers to this area: @eerhardt, @maryamariyan
See info in area-owners.md if you want to be subscribed.

Issue Details
  • This optional service lets consumers query to see if a service is resolvable without side effects (not having to explicitly resolve the service).
  • Added new spec tests to verify the baseline behavior based on IServiceCollection features.

Fixes #53919

Author: davidfowl
Assignees: -
Labels:

area-Extensions-DependencyInjection, new-api-needs-documentation

Milestone: -

…tions/src/IServiceProviderIsService.cs

Co-authored-by: Travis Illig <[email protected]>
@pakrym
Copy link
Contributor

pakrym commented Jun 11, 2021

Can you put Debug.Assert(CanGetService(type)) into GetService implementation and run the test suit with that? Make sure we didn't miss anything. And maybe keep it long-term.

- Special case built in services as part of the IsService check
- Added a test case
Copy link
Member

@halter73 halter73 left a comment

Choose a reason for hiding this comment

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

I think I agree with @pakrym that we should put this in DependencyInjectionSpecificationTests with SupportsIsService true by default for greater discoverability when third-party containers update their Specification.Tests dependency.

- Make the tests part of the core DI tests and enable skipping via a property
@davidfowl
Copy link
Member Author

I think I agree with @pakrym that we should put this in DependencyInjectionSpecificationTests with SupportsIsService true by default for greater discoverability when third-party containers update their Specification.Tests dependency.

Done!

@davidfowl
Copy link
Member Author

Errors as unrelated, Merging.

@davidfowl davidfowl merged commit c14ac48 into main Jun 11, 2021
@BrennanConroy BrennanConroy deleted the davidfowl/serviceprovider-isservice branch June 11, 2021 22:39
@ghost ghost locked as resolved and limited conversation to collaborators Jul 11, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Add ability to detect if a service is registered in the DI container
7 participants