[API Proposal]: ServiceCollection support post service registration #110926
Labels
api-suggestion
Early API idea and discussion, it is NOT ready for implementation
area-Extensions-DependencyInjection
untriaged
New issue has not been triaged by the area owner
Background and motivation
I'm a framework programmer. Usually, I often add extension method for
IServiceCollection
. But sometimes, my extension method is required to knowIServiceCollection
state.For instance,
services.AddUnitOfWork()
need to know allDbContextOptions
in services and updateDbContextOptions
. ifservices.AddUnitOfWork()
is added after registration of all dbcontexts, it can work properly. Otherwise, can get side effect(unexpected behavior). Some users maybe callservices.AddUnitOfWork
before or between dbcontexts registration by accident, becauseAddUnitOfWork
is built onIServiceCollection
and there is no restriction.API Proposal
I suggest has an interface can be invoked after all services registered but before build to provider.
API Usage
Hence
services.AddUnitOfWork
can use the new feature to register own services or add validation, and can be added out of order by user. User only know I need to call this method without other knowledge.Alternative Designs
No response
Risks
No response
The text was updated successfully, but these errors were encountered: