-
Notifications
You must be signed in to change notification settings - Fork 310
Allow overriding the hosting service provider #1325
Conversation
- Updated the tests to verify that service providers are created and disposed - Called CreateBuilder even in the default case in case the service collection is modified as part of it.
@@ -202,6 +202,22 @@ public IWebHost Build() | |||
host.Dispose(); | |||
throw; | |||
} | |||
|
|||
IServiceProvider GetProviderFromFactory(IServiceCollection collection) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Only used once and not complex, inline.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think it should remain a method. It's not like it's 2 lines of code. It's a few.
|
||
// Don't bother calling CreateBuilder since it just returns the default service collection | ||
applicationServiceProvider = serviceProviderFactory.CreateServiceProvider(services); | ||
var builder = serviceProviderFactory.CreateBuilder(services); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is it guaranteed that factory exists? What if serviceProviderFactory
is null?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This has been the case since 2.0. There’s always one registered. Unless somebody removes it.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
shrug it's a weird use of embedded methods.
Replaces #1322