Related test issue
Discovered while implementing #608 — event-store dependency injection coverage.
Problem
With EventuousDiagnostics disabled, store registration methods register implementations or factories separately for each interface. Each interface therefore gets its own singleton rather than sharing one backing instance.
A successful append through IEventWriter can be followed by StreamNotFound when the same stream is read through IEventReader. This is reproducible with the stateful InMemoryEventStore; it is not a claim that persistent providers lose stored data. Factories can also run more than once, and standalone reader/writer registrations can ignore an already registered concrete store.
Affected APIs include the generic and factory overloads of AddEventStore<T>, AddEventReaderWriter<T>, and separately composed AddEventReader<T> / AddEventWriter<T>.
Reproduction
- Disable diagnostics, preserving the previous setting for restoration afterward.
- Build a host with
services.AddEventStore<InMemoryEventStore>().
- Resolve
IEventWriter and IEventReader from that host.
- Append an event to a new stream through the writer.
- Read that stream through the reader.
Actual: the read throws StreamNotFound because the interfaces resolve to different stores.
Expected: all interfaces registered for the same implementation share one backing singleton. Changing tracing configuration must not change which events are visible.
Fix and acceptance criteria
Existing regression tests and implementation
StoreRegistrationTests.cs in src/Extensions/test/Eventuous.Tests.DependencyInjection contains:
WrittenEventsAreVisibleThroughEveryRegisteredInterface
StandaloneRegistrationUsesTheExistingBackingStore
- The tracing-disabled cases of
RepeatedRegistrationKeepsOneServiceAndOneFactory
These scenarios failed before the production fix. The complete DI project passes all 31 tests on .NET 10 after the fixes for this issue and the companion registration issue.
An implementation is already committed locally on fix/issue-608-store-registrations, commit df3dbe48. It also fixes duplicate registrations and overridden services; this draft does not imply the fix has been published or merged.
Related test issue
Discovered while implementing #608 — event-store dependency injection coverage.
Problem
With
EventuousDiagnosticsdisabled, store registration methods register implementations or factories separately for each interface. Each interface therefore gets its own singleton rather than sharing one backing instance.A successful append through
IEventWritercan be followed byStreamNotFoundwhen the same stream is read throughIEventReader. This is reproducible with the statefulInMemoryEventStore; it is not a claim that persistent providers lose stored data. Factories can also run more than once, and standalone reader/writer registrations can ignore an already registered concrete store.Affected APIs include the generic and factory overloads of
AddEventStore<T>,AddEventReaderWriter<T>, and separately composedAddEventReader<T>/AddEventWriter<T>.Reproduction
services.AddEventStore<InMemoryEventStore>().IEventWriterandIEventReaderfrom that host.Actual: the read throws
StreamNotFoundbecause the interfaces resolve to different stores.Expected: all interfaces registered for the same implementation share one backing singleton. Changing tracing configuration must not change which events are visible.
Fix and acceptance criteria
Existing regression tests and implementation
StoreRegistrationTests.csinsrc/Extensions/test/Eventuous.Tests.DependencyInjectioncontains:WrittenEventsAreVisibleThroughEveryRegisteredInterfaceStandaloneRegistrationUsesTheExistingBackingStoreRepeatedRegistrationKeepsOneServiceAndOneFactoryThese scenarios failed before the production fix. The complete DI project passes all 31 tests on .NET 10 after the fixes for this issue and the companion registration issue.
An implementation is already committed locally on
fix/issue-608-store-registrations, commitdf3dbe48. It also fixes duplicate registrations and overridden services; this draft does not imply the fix has been published or merged.