Hacktoberfest 2026:メンテナが10月に向けて印を付けた、オープンで初心者向けの issue。 Hacktoberfest の issue を見る

Traced event-store registration duplicates services and overrides existing registrations

オープン
#611 コメント 2 件 リアクション 0 件 担当者 0 名 GitHub で見る

メンテナーはふだん 7 日以内に返信

@nmummau がすでに取り組んでいます。

2026年10月14日 から。

  • #622 @nmummau による — オープン

評価

難易度
2/5
見積もり時間
1〜3時間
初心者へのやさしさ
10/100
issue の種類
バグ
明瞭さ
明確に書かれている
活発さ
停滞
技術スタック
csharp
領域
backend, testing

調査の方向性

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.

索引モデルが issue の本文から書いたものです。

説明

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.

主要言語
C#
スター
512
フォーク
99
平均マージ
5日 6時間
マージ済み PR(30日)
5

環境構築

はじめの一歩

  1. issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
  2. 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
  3. リポジトリをフォークし、ブランチを切って変更します。
  4. issue 番号を参照したプルリクエストを送ります。

Eventuous/eventuous のほかの issue

Eventuous/eventuous の issue をすべて見る

似ている issue

C# の issue をもっと見る

新しい issue をメールで受け取る

初心者向けの GitHub issue を短くまとめたダイジェスト。