Related test issue
Discovered while implementing #608 — event-store dependency injection coverage.
Problem
With tracing enabled, both overloads of AddEventStore<T> use unconditional AddSingleton calls for the traced store and its interface registrations. Calling the registration method repeatedly adds duplicate service descriptors. Calling it after explicitly registering IEventStore, IEventReader, or IEventWriter replaces the service returned by normal single-service resolution.
This differs from the tracing-disabled path's TryAddSingleton behavior. Enabling diagnostics can therefore change service selection and route writes to a different backing store.
Reproduction
Repeated registration
- Enable diagnostics, preserving the previous setting for restoration afterward.
- Call
services.AddEventStore<InMemoryEventStore>() twice and build a host.
- Resolve
GetServices<IEventWriter>(), GetServices<IEventReader>(), and GetServices<IEventStore>().
Actual: each enumeration contains duplicate registrations.
Expected: repeating the default registration leaves one registration per interface.
Explicit service overrides
- Register an existing store instance explicitly as
IEventStore, IEventReader, and IEventWriter.
- Call
services.AddEventStore<InMemoryEventStore>() with tracing enabled.
- Build the host and append an event through its resolved
IEventWriter.
- Read the stream through the explicitly registered instance.
Actual: the explicit instance has no such stream; the later registration selected a different store.
Expected: default store registration preserves explicitly registered interfaces, consistently with tracing disabled.
Fix and acceptance criteria
Existing regression tests and implementation
StoreRegistrationTests.cs in src/Extensions/test/Eventuous.Tests.DependencyInjection contains RepeatedRegistrationKeepsOneServiceAndOneFactory and RegistrationPreservesExplicitInterfaceOverrides. Their tracing-enabled cases reproduced these failures before the fix.
An implementation is already committed locally on fix/issue-608-store-registrations, commit df3dbe48. It also fixes separate backing instances when tracing is disabled. The complete DI project passes all 31 tests on .NET 10 after both fixes. The branch has not been published or merged as part of this work.
Related test issue
Discovered while implementing #608 — event-store dependency injection coverage.
Problem
With tracing enabled, both overloads of
AddEventStore<T>use unconditionalAddSingletoncalls for the traced store and its interface registrations. Calling the registration method repeatedly adds duplicate service descriptors. Calling it after explicitly registeringIEventStore,IEventReader, orIEventWriterreplaces the service returned by normal single-service resolution.This differs from the tracing-disabled path's
TryAddSingletonbehavior. Enabling diagnostics can therefore change service selection and route writes to a different backing store.Reproduction
Repeated registration
services.AddEventStore<InMemoryEventStore>()twice and build a host.GetServices<IEventWriter>(),GetServices<IEventReader>(), andGetServices<IEventStore>().Actual: each enumeration contains duplicate registrations.
Expected: repeating the default registration leaves one registration per interface.
Explicit service overrides
IEventStore,IEventReader, andIEventWriter.services.AddEventStore<InMemoryEventStore>()with tracing enabled.IEventWriter.Actual: the explicit instance has no such stream; the later registration selected a different store.
Expected: default store registration preserves explicitly registered interfaces, consistently with tracing disabled.
Fix and acceptance criteria
Existing regression tests and implementation
StoreRegistrationTests.csinsrc/Extensions/test/Eventuous.Tests.DependencyInjectioncontainsRepeatedRegistrationKeepsOneServiceAndOneFactoryandRegistrationPreservesExplicitInterfaceOverrides. Their tracing-enabled cases reproduced these failures before the fix.An implementation is already committed locally on
fix/issue-608-store-registrations, commitdf3dbe48. It also fixes separate backing instances when tracing is disabled. The complete DI project passes all 31 tests on .NET 10 after both fixes. The branch has not been published or merged as part of this work.