Weird service collection self-registration
Closed this issue · 3 comments
j-mok commented
Hi, is there any reason the platform registers the DI service collection in itself? This feels very weird...
mvktsk commented
Task https://virtocommerce.atlassian.net/browse/VP-8582 has been created
OlegoO commented
@j-mok Good quetion, the code was added 5 years ago, I will review with the team and maybe find some reason.
OlegoO commented
This code is required to resolve IServiceCollection for ModuleInitializer class and then pass to modules. Without this line, DI throws exception. Maybe code can be improved but let's keep it as is.
Unhandled exception. System.InvalidOperationException: Unable to resolve service for type 'Microsoft.Extensions.DependencyInjection.IServiceCollection' while attempting to activate 'VirtoCommerce.Platform.Modules.ModuleInitializer'.
at Microsoft.Extensions.DependencyInjection.ServiceLookup.CallSiteFactory.CreateArgumentCallSites(ServiceIdentifier serviceIdentifier, Type implementationType, CallSiteChain callSiteChain, ParameterInfo[] parameters, Boolean throwIfCallSiteNotFound)
...
at VirtoCommerce.Platform.Modules.ServiceCollectionExtensions.AddModules(IServiceCollection services, IMvcBuilder mvcBuilder, Action`1 setupAction) in C:\Projects\git\VirtoCommerce\vc-platform\src\VirtoCommerce.Platform.Web\Extensions\ServiceCollectionExtensions.cs:line 33
...