The .AddSimpleInjector() extension method adds the registration for the framework's IServiceScope to the Simple Injector container, but it does so after calling the setupAction. This is unfortunate, because this makes it really hard for any extension on top of SimpleInjectorAddOptions that wants to replace the IServiceScope to do so.
Use case is Blazor integration. A hypothetical integration would look like this:
This integration, however, needs to replace the IServiceScope, but at the time AddServerSideBlazor is called, IServiceScope hasn't been registered, as AddSimpleInjector adds this registration after the delegate call. This causes that last registration to fail, because at that point there already exists a registration for IServiceScope.
By moving this registration before calling the delegate, the AddServerSideBlazor can easily replace that registration.
Do note that this change is theoretically a breaking change, although the chance that any user is impacted by this is pretty low.
The
.AddSimpleInjector()
extension method adds the registration for the framework'sIServiceScope
to the Simple Injector container, but it does so after calling thesetupAction
. This is unfortunate, because this makes it really hard for any extension on top ofSimpleInjectorAddOptions
that wants to replace theIServiceScope
to do so.Use case is Blazor integration. A hypothetical integration would look like this:
This integration, however, needs to replace the
IServiceScope
, but at the timeAddServerSideBlazor
is called,IServiceScope
hasn't been registered, asAddSimpleInjector
adds this registration after the delegate call. This causes that last registration to fail, because at that point there already exists a registration forIServiceScope
.By moving this registration before calling the delegate, the
AddServerSideBlazor
can easily replace that registration.Do note that this change is theoretically a breaking change, although the chance that any user is impacted by this is pretty low.