Hacktoberfest 2026: những issue maintainer đã đánh dấu cho tháng Mười, đang mở và phù hợp người mới. Xem issue Hacktoberfest

Traced event-store registration duplicates services and overrides existing registrations

Đang mở
#611 2 bình luận 0 reaction 0 người được giao Xem trên GitHub

Maintainer thường phản hồi trong vòng 7 ngày

@nmummau đang làm issue này rồi.

Từ ngày 14/10/2026.

  • #622 của @nmummau — đang mở

Đánh giá

Độ khó
2/5
Thời gian dự kiến
1-3 giờ
Mức phù hợp với người mới
10/100
Loại issue
Lỗi
Độ rõ ràng
Đặc tả rõ ràng
Mức độ hoạt động
Đình trệ
Công nghệ
csharp
Lĩnh vực
backend, testing

Hướng nghiên cứu

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.

Do mô hình lập chỉ mục viết ra từ nội dung của issue.

Mô tả

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.

Ngôn ngữ chính
C#
Star
512
Fork
99
Merge trung bình
5 ngày 6 giờ
Pull request đã merge (30 ngày)
5

Chuẩn bị môi trường

Bắt đầu từ đâu

  1. Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
  2. Bình luận trên issue rằng bạn sẽ nhận — tránh hai người làm cùng một việc.
  3. Fork repository và làm thay đổi trên một nhánh.
  4. Mở pull request có tham chiếu số hiệu của issue.

Issue khác của Eventuous/eventuous

Tất cả issue của Eventuous/eventuous

Issue tương tự

Thêm issue về C#

Nhận issue mới trong hộp thư của bạn

Bản tóm tắt ngắn những issue GitHub phù hợp với người mới.