Description
The API docs for IServiceScopeFactory.CreateScope
state:
Returns: An IServiceScope controlling the lifetime of the scope. Once this is disposed, any scoped services that have been resolved from the IServiceScope.ServiceProvider will also be disposed.
This was a source of confusion for me as I always believed that anything created by a child scope is disposed by that child scope. Meaning it would also dispose transient services.
And elsewhere, the docs state:
When you register Transient services that implement IDisposable, by default the DI container will hold onto these references, and not Dispose() of them until the container is disposed when application stops if they were resolved from the container, or until the scope is disposed if they were resolved from a scope. This can turn into a memory leak if resolved from container level.
So the API wording should be changed to include "or transient services".