pakrym / jab

C# Source Generator based dependency injection container implementation.
MIT License
1.04k stars 35 forks source link

Add failing test for CreateScope #135

Closed notanaverageman closed 1 year ago

notanaverageman commented 1 year ago

If there is a call like: c.GetService<IServiceScopeFactory>() IServiceScopeFactory type is registered in RootCallSites and an entry is generated for it: https://github.com/pakrym/jab/blob/aab09936addd9a82dc483efb73290abf03bb0645/src/Jab/ContainerGenerator.cs#L333

Use a separate container and test fails with an exception:

Message: 
    System.InvalidOperationException : No service for type 'Microsoft.Extensions.DependencyInjection.IServiceScopeFactory' has been registered.

  Stack Trace: 
    ServiceProviderServiceExtensions.GetRequiredService(IServiceProvider provider, Type serviceType)
    ServiceProviderServiceExtensions.GetRequiredService[T](IServiceProvider provider)
    ServiceProviderServiceExtensions.CreateScope(IServiceProvider provider)
    MEDIContainerTests.CanCreateScopeUsingExtensionMethod() line 29
    RuntimeMethodHandle.InvokeMethod(Object target, Void** arguments, Signature sig, Boolean isConstructor)
    MethodInvoker.Invoke(Object obj, IntPtr* args, BindingFlags invokeAttr)