-
Notifications
You must be signed in to change notification settings - Fork 649
Conversation
Thanks for the contribution! Could you please also add some tests to verify the feature works? Also, out of curiosity, have you been successful using any 3rd party IoC containers using this change? |
@danroth27 I've added a unit test using autofac, I know its not ideal to add that as a test dependency, however its hard to properly test it without using a different DI framework. I can however revert this change, and implement a unit test that instead just checks whether the GetService method is called on a custom service provider (wraps the default ServiceProvider) atleast once, however due to how ServiceProvider is implemented, it means the host.Services type won't be the custom provider type, and the only easy way to achieve this was through using autofac. Yes, I have Autofac working. It has the same linking issue as json.net, so it just requires the "System.Linq.Expressions*" to be kept in the linker config and to be registered via the Service Provider Factory added by this PR. |
@danroth27 I assume the AppVeyor build failing can be safely ignored, seeing as travis and blazor-ci both build and the tests pass? |
@csnewman Nice job on this PR, very surgical and neat. Are you able to use the I wonder if it wouldn't be a good idea to also add support for the |
Currently neither are supported. This is the simpler I have a planned followup PR that will implement the |
@csnewman Makes sense to separate these two things, indeed. Just to clarify though - you say we need to create a custom var host = BlazorWebAssemblyHost
.CreateDefaultBuilder()
.ConfigureServices(services =>
{
services.AddAutofac(builder =>
{
// Interact directly with ContainerBuilder here...
builder.RegisterModule<CoreModule>();
});
})
.UseBlazorStartup<Startup>()
.Build();
host.Run(); As far as I understand, the |
@DaRosenberg Unfortunately not. As I am following the same principals as aspnet/Hosting, it doesn't work this way. AddAutofac registers a Example ServiceProviderFactory for Autofac
|
@csnewman Ah, got it. Thanks for explaining that. @danroth27 this PR would unblock our development too, so having it merged would be super helpful. |
@danroth27 I have fixed the merge conflicts, if you wish to review the commit. |
Thanks very much for this, @csnewman! It's now moved to https://github.com/aspnet/AspNetCore/pull/4785/files, where it will be merged as soon as it passes automated verification. I did tweak the test to eliminate the Autofac dependency (though I do understand why it was a bit awkward and why you chose to use Autofac in the test originally). Mainly I wanted to avoid the external dependency so as to make the test even more explicit about what interactions we're having with other units of code. Hope that's OK! |
Copied implementation from aspnet/Hosting. Allows overriding of service provider implementation.