Skip to content

feat: EventStoreOptions.AddEventType / AddEventTypes (#395) - #396

Merged
jeremydmiller merged 1 commit into
mainfrom
feature/395-add-event-type
Aug 2, 2026
Merged

feat: EventStoreOptions.AddEventType / AddEventTypes (#395)#396
jeremydmiller merged 1 commit into
mainfrom
feature/395-add-event-type

Conversation

@jeremydmiller

Copy link
Copy Markdown
Member

Closes #395.

The gap

StoreOptions.Events is an EventStoreOptions facade exposing RegisterTagType<TTag>() and a pile of flags — but no AddEventType. A user following Marten's documented pattern:

opts.Events.AddEventType<StudentEnrolled>();   // did not compile on Polecat

had to go around the facade to opts.EventGraph.AddEventType(typeof(StudentEnrolled)). That works (StoreOptions.EventGraph is public and EventGraph implements IEventRegistry) but is undiscoverable and matches no Marten-derived docs or samples. It also matters beyond ergonomics: pre-registration is the documented mitigation for the async daemon meeting an event type it has not yet seen appended, and that mitigation was unreachable from the options facade.

The change

Three void delegations on EventStoreOptions, mirroring the existing RegisterTagType delegation pattern (EventGraph! — assigned in the StoreOptions constructor, so non-null at configure time):

  • AddEventType<TEvent>()
  • AddEventType(Type)
  • AddEventTypes(IEnumerable<Type>)

Deliberately not returning IEventStoreOptions for fluent chaining. Marten's AddEventType<T>() does, and that return type is precisely what makes marten#5114 (a generic DIM on IEventRegistry) impossible to land there without a source-breaking change. Keeping these void matches the shared interface and leaves the door open.

Also:

  • PolecatComplianceFixture.PolecatComplianceRegistrar.AddEventType now goes through the facade; its comment explaining the detour is gone with the detour.
  • New "Pre-registering Event Types" section in docs/events/storage.md.

Tests

Four unit tests in StoreOptionsTests covering the generic overload, the Type overload, the batch overload, and idempotency (re-registering the same type does not duplicate it).

Locally on net10.0: StoreOptionsTests 16/16, Polecat.Tests.Compliance 42/42.

🤖 Generated with Claude Code

`StoreOptions.Events` exposed `RegisterTagType` and a pile of flags but no
`AddEventType`, so the Marten-documented pre-registration pattern

    opts.Events.AddEventType<StudentEnrolled>();

did not compile on Polecat. Users had to go around the facade to
`opts.EventGraph.AddEventType(typeof(...))`, which works but is not
discoverable and is not what any Marten-derived sample shows.

Adds three void delegations on `EventStoreOptions`, mirroring the existing
`RegisterTagType` pattern. Deliberately `void` rather than returning
`IEventStoreOptions` for fluent chaining — that return type is what makes a
generic DIM on `IEventRegistry` (marten#5114) source-breaking to add, so
keeping these void matches the shared interface and leaves the door open.

Drops the workaround (and its explanatory comment) from the compliance
fixture's registrar, and documents pre-registration in events/storage.md.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
@jeremydmiller
jeremydmiller merged commit 4f5d258 into main Aug 2, 2026
7 checks passed
@jeremydmiller
jeremydmiller deleted the feature/395-add-event-type branch August 2, 2026 16:06
@jeremydmiller jeremydmiller mentioned this pull request Aug 3, 2026
jeremydmiller added a commit that referenced this pull request Aug 3, 2026
Minor rather than patch: 5.9.1's line added public surface (IEventBinarySerializer,
EventStoreOptions.AddEventType/AddEventTypes) and moved the whole JasperFx/Weasel
matrix forward.

Since 5.9.1:

- feat: pluggable binary event serialization via IEventBinarySerializer (#388/#402)
- feat: EventStoreOptions.AddEventType / AddEventTypes (#395/#396)
- fix: escape interpolated identifiers and literals in constructed SQL (#390/#403)
- fix: throw a lone DcbConcurrencyException unwrapped from SaveChangesAsync (#394/#397)
- deps: JasperFx 2.37.2 -> 2.38.0, Weasel 9.23.0 -> 9.23.2 (#405, #407)
- Polecat's ProjectionScenario is now a thin subclass of the lifted
  JasperFx.Events.TestSupport harness rather than a seven-file copy of Marten's
  (#404/#408, jasperfx#616) -- a behavior change for anyone already using it, see
  the release notes
- test infrastructure: compliance waves 1-3 (#393, #400, #407), parallel-safe test
  suite (#389), IntegrationContext.StoreOptions document cleaning (#398/#401)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

EventStoreOptions has no AddEventType — event type pre-registration is unreachable from the public API

1 participant