You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Traced event-store registration duplicates services and overrides existing registrations #611
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
Use conditional registration for the traced store and interface aliases.
Repeated generic and factory registrations do not add duplicate interface services.
Existing interface registrations remain the services resolved by the host.
An unused replacement factory is not invoked.
Tests verify actual append/read behavior, in addition to service counts and identities.
Test both tracing modes and restore the global diagnostics setting with parallel isolation.
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.
I’ve implemented this locally with regression tests. I’m waiting for a prerequisite PR 603 to merge so I can rebase and open a focused PR. I’ll link it here once it’s ready.
Activity
linear commentedon Oct 6, 2026
EVE-262
nmummau commentedon Oct 6, 2026
I’ve implemented this locally with regression tests. I’m waiting for a prerequisite PR 603 to merge so I can rebase and open a focused PR. I’ll link it here once it’s ready.