Skip to content
This repository was archived by the owner on Dec 19, 2018. It is now read-only.

Conversation

@kaztechSolutions
Copy link

Allow to pass an existing IServiceCollection instance to WebHostBuilder which should be used instead of creating a new one inside WebHostBuilder. Could be a solution to issue #1060.

Allow to pass an existing IServiceCollection instance to WebHostBuilder which should be used instead of creating a new one inside WebHostBuilder. Could be a solution to issue #1060.
@dnfclas
Copy link

dnfclas commented Dec 27, 2017

CLA assistant check
All CLA requirements met.

@davidfowl
Copy link
Member

I'm not 100% certain I like this. The caveats here are that the service collection cannot be modified after the it is give to the web host. That's not clear from the method that this is the case.

Also, why is it a Func<IServiceCollection> instead of just an IServiceCollection

@kaztechSolutions
Copy link
Author

The caveats here are that the service collection cannot be modified after the it is give to the web host

I see your point. But the main issue here is that WebHostBuilder is passing the serviceProvider to WebHost to do service location. Of course this is not easy to change but therefore its the serviceCollection's last stop.

That's not clear from the method that this is the case.

Maybe it is enough to just change the methods name to for example BuildServiceCollection?

Also, why is it a Func instead of just an IServiceCollection

I also thought about that after my pull request. My first intention was to be able to create the ServiceCollection as late as possible. But you are right, maybe it is just simpler to pass an IServiceCollection.

@davidfowl
Copy link
Member

Take a look at 6b095cf and see if you still need this feature. I don't think you do but I don't understand your scenario enough to make that call.

@davidfowl
Copy link
Member

Closing this out. If you can't make the change above work I'd like to understand why

@davidfowl davidfowl closed this Feb 5, 2018
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants