Hacktoberfest 2026: los issues que los mantenedores marcaron para octubre, abiertos y aptos para principiantes. Explorar issues de Hacktoberfest

Traced event-store registration duplicates services and overrides existing registrations

Abierto
#611 2 comentarios 0 reacciones 0 asignados Ver en GitHub

Los mantenedores suelen responder en 7 días

@nmummau ya está trabajando en esto.

Desde el 14/10/2026.

  • #622 de @nmummau — abierto

Evaluación

Dificultad
2/5
Tiempo estimado
1-3 horas
Aptitud para principiantes
10/100
Tipo de issue
Error
Claridad
Bien especificado
Estado de actividad
Estancado
Stack tecnológico
csharp
Área
backend, testing

Línea de trabajo

Read StoreRegistrationTests.cs in src/Extensions/test/Eventuous.Tests.DependencyInjection, especially the tracing-enabled cases for repeated registrations and explicit overrides. The issue reports an implementation already committed locally on fix/issue-608-store-registrations, so check that branch and commit df3dbe48 before starting. Done means the acceptance criteria pass, including append/read behavior, both tracing modes, and all 31 DI project tests.

Escrito por el modelo de indexación a partir del texto del issue.

Descripción

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
  1. Enable diagnostics, preserving the previous setting for restoration afterward.
  2. Call services.AddEventStore<InMemoryEventStore>() twice and build a host.
  3. 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
  1. Register an existing store instance explicitly as IEventStore, IEventReader, and IEventWriter.
  2. Call services.AddEventStore<InMemoryEventStore>() with tracing enabled.
  3. Build the host and append an event through its resolved IEventWriter.
  4. 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.

Lenguaje dominante
C#
Estrellas
512
Forks
99
Merge medio
5 d 6 h
PR fusionados (30 d)
5

Preparar el entorno

Primeros pasos

  1. Lee el issue completo y luego la guía de contribución del proyecto.
  2. Comenta en el issue que vas a ocuparte — evita que dos personas hagan lo mismo.
  3. Haz un fork del repositorio y trabaja en una rama.
  4. Abre un pull request que haga referencia al número del issue.

Más de Eventuous/eventuous

Todos los issues de Eventuous/eventuous

Issues similares

Más issues de C#

Recibe los nuevos issues en tu correo

Un resumen breve de issues de GitHub para principiantes.