Closed
Description
Description
Discovered in dotnet/efcore#31178 cc @ajcvickers
Marked blocking-release since this is a regression and we're disabling tests against it. We need to understand the implications here before we ship 8.0.
Reproduction Steps
Run attached repro project:
di-test.zip
This is a port of this testcase: https://github.com/dotnet/efcore/blob/926b37073d9a721432513ba7fdaee03543cc2d91/test/EFCore.Tests/DbContextServicesTest.cs#L309
Expected behavior
InvalidOperationException
when resolving scoped service from root provider. Here's the stack from the repro app in successful case:
System.InvalidOperationException: Cannot resolve scoped service 'ApplicationService' from root provider.
at Microsoft.Extensions.DependencyInjection.ServiceLookup.CallSiteValidator.ValidateResolution(Type serviceType, IServiceScope scope, IServiceScope rootScope)
at Microsoft.Extensions.DependencyInjection.ServiceProvider.OnResolve(Type serviceType, IServiceScope scope)
at Microsoft.Extensions.DependencyInjection.ServiceProvider.GetService(Type serviceType, ServiceProviderEngineScope serviceProviderEngineScope)
at Microsoft.Extensions.DependencyInjection.ServiceLookup.ServiceProviderEngineScope.GetService(Type serviceType)
at Microsoft.Extensions.DependencyInjection.ServiceProviderServiceExtensions.GetService[T](IServiceProvider provider)
at TestSingletonService.get_ApplicationService() in C:\scratch\di-test\Program.cs:line 97
Actual behavior
No exception.
Regression?
Yes, regressed in Preview7 by c06d77a
Known Workarounds
No response
Configuration
No response
Other information
No response