Skip to content

EVTC001 false positive when passing IEventReader.ReadEvents() payload to State<T>.When() #535

@nmummau

Description

@nmummau

Description

The EVTC001 analyzer (introduced in 0.16.x) flags object types that aren't annotated with [EventType]. However, it fires on Eventuous's own event replay pattern — reading events from the store and folding them through State.When().

Reproduction

var events = await _eventReader.ReadEvents(stream, start, int.MaxValue, true, ct);
foreach (var evt in events) {
   if (evt.Payload != null) state = state.When(evt.Payload);
   // EVTC001: Event type 'object' is used as a domain event but isn't annotated with [EventType]
}

ReadEvents returns StreamEvent[] where Payload is object?. The concrete event types are registered via TypeMap and resolved at deserialization time, but the static type at the call site is object — which the analyzer flags.

Expected behavior

The analyzer should not flag object when it originates from Eventuous's own StreamEvent.Payload (or similar deserialization outputs like IMessageConsumeContext.Message). These are runtime-resolved types that are inherently object-typed at the call site.

Actual behavior

  • error EVTC001: Event type 'object' is used as a domain event but isn't annotated with [EventType]
  • Build fails. This is a breaking change in a patch update (0.16.0 → 0.16.3).

Screenshot

Image

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions