aspnet/DependencyInjection

BuildServiceProvider should return IServiceProvider instead of ServiceProvider

cknaap opened this issue · 2 comments

Method Microsoft.Extensions.DependencyInjection.ServiceCollectionContainerBuilderExtensions.BuildServiceProvider returns a ServiceProvider instead of the associated interface IServiceProvider.

The latter allows for better mocking in unit tests.

Plus, the documentation on the method also says it returns IServiceProvider.

No, it shouldn't. How can you mock an extension method? This method is about building a concrete implementation of an IServiceProvider.

Plus, the documentation on the method also says it returns IServiceProvider.

It was changed in 2.0 and needs to be updated /cc @Rick-Anderson

This issue was moved to dotnet/aspnetcore#2329