Skip to content

Explicit test for injecting scoped IServiceProvider (#63225) #64558

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

Conversation

lord-executor
Copy link
Contributor

Alternative to #63226 which only adds a new test without modifying the existing ones.

The new test is analogous to the existing SingletonServiceCanBeResolvedFromScope but covers the more general (at least from my point of view) case of non-singleton injection.

I have also updated LightInjectDependencyInjectionSpecificationTests to skip this new test since it otherwise fails on the last line of the test Assert.NotSame(fakeServiceFromScope1, fakeServiceFromScope2), meaning that LightInject actually injects the same scoped or transient service instance in both of the created service provider scopes - probably the result of making the original SingletonServiceCanBeResolvedFromScope test pass.

@ghost ghost added community-contribution Indicates that the PR has been added by a community member area-Extensions-DependencyInjection labels Jan 31, 2022
@ghost
Copy link

ghost commented Jan 31, 2022

Tagging subscribers to this area: @dotnet/area-extensions-dependencyinjection
See info in area-owners.md if you want to be subscribed.

Issue Details

Alternative to #63226 which only adds a new test without modifying the existing ones.

The new test is analogous to the existing SingletonServiceCanBeResolvedFromScope but covers the more general (at least from my point of view) case of non-singleton injection.

I have also updated LightInjectDependencyInjectionSpecificationTests to skip this new test since it otherwise fails on the last line of the test Assert.NotSame(fakeServiceFromScope1, fakeServiceFromScope2), meaning that LightInject actually injects the same scoped or transient service instance in both of the created service provider scopes - probably the result of making the original SingletonServiceCanBeResolvedFromScope test pass.

Author: lord-executor
Assignees: -
Labels:

area-Extensions-DependencyInjection, community-contribution

Milestone: -

@eerhardt eerhardt merged commit ec4d084 into dotnet:main Feb 7, 2022
@eerhardt
Copy link
Member

eerhardt commented Feb 7, 2022

Thanks for the contribution, @lord-executor!

@ghost ghost locked as resolved and limited conversation to collaborators Mar 9, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
area-Extensions-DependencyInjection community-contribution Indicates that the PR has been added by a community member
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants