aspnet / DependencyInjection

[Archived] Contains common DI abstractions that ASP.NET Core and Entity Framework Core use. Project moved to https://github.com/aspnet/Extensions
Apache License 2.0
877 stars 320 forks source link

BuildServiceProvider should return IServiceProvider instead of ServiceProvider #614

Closed cknaap closed 6 years ago

cknaap commented 6 years ago

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.

davidfowl commented 6 years ago

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

aspnet-hello commented 6 years ago

This issue was moved to aspnet/Home#2329