Skip to content
This repository has been archived by the owner on Jul 31, 2024. It is now read-only.

Validate scoped services #825

Merged
merged 2 commits into from
Feb 22, 2017

Conversation

user1336
Copy link
Contributor

Hi,

So in ASP.NET Core 1.1 it is possible to do the following:

public IServiceProvider ConfigureServices(IServiceCollection services)
{
    return services.BuildServiceProvider(validateScopes: true);
}

Setting this parameter to true will validate the correct lifetime of the dependencies.
This gave a few errors in TestService() in combination with the IdentityServer4.EF package.
The services are being resolved from the root ServiceProvider which means they will be Singleton.

Kinda related:
IdentityServer/IdentityServer4.EntityFramework#57

…viceProvider so it can work with Scoped services
@dnfclas
Copy link

dnfclas commented Feb 16, 2017

Hi @user1336, I'm your friendly neighborhood .NET Foundation Pull Request Bot (You can call me DNFBOT). Thanks for your contribution!
You've already signed the contribution license agreement. Thanks!

The agreement was validated by .NET Foundation and real humans are currently evaluating your PR.

TTYL, DNFBOT;

@giggio
Copy link

giggio commented Feb 21, 2017

You should dispose the serviceProvider at the end.

@leastprivilege leastprivilege merged commit ab09cda into IdentityServer:dev Feb 22, 2017
@leastprivilege leastprivilege added this to the 1.2 milestone Feb 22, 2017
@leastprivilege
Copy link
Member

thanks!

@user1336 user1336 deleted the validate-scoped-services branch February 22, 2017 12:04
@lock
Copy link

lock bot commented Jan 11, 2020

This thread has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.

@lock lock bot locked as resolved and limited conversation to collaborators Jan 11, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants