Question: could we decorate the `IServiceScopeFactory`
WeihanLi opened this issue · 2 comments
WeihanLi commented
I'm trying to create a trace id for each scope resolved, while the IServiceScopeFactory
is registered when BuildServiceProvider
, is it possible to decorate the IServiceScopeFactory
?
khellang commented
Hello @WeihanLi! 👋
The decorating code requires an existing registration be present when decorating. If IServiceScopeFactory
isn't registered before building, it won't work. I didn't even know there was a registration for IServiceScopeFactory
😅
WeihanLi commented
@khellang thanks for your reply, I found the registration here
https://github.com/dotnet/runtime/blob/df822e7573363f82111c96a0b1d3f904fe812b55/src/libraries/Microsoft.Extensions.DependencyInjection/src/ServiceProvider.cs#L48 (more like a implicit registration)