Skip to content

CHR0005: Reactor event parameter must have [EventType] attribute

Event parameters in reactor methods must be types marked with the [EventType] attribute. This ensures that reactors only handle properly identified event types.

Error

using Cratis.Chronicle.Reactors;
// Missing [EventType] attribute
public record Chr0005CustomerRegistered(Guid CustomerId, string Email);
public class Chr0005CustomerReactor : IReactor
{
// CHR0005: Type 'Chr0005CustomerRegistered' must be marked with [EventType] attribute
public Task Registered(Chr0005CustomerRegistered @event) => Task.CompletedTask;
}
using Cratis.Chronicle.Events;
using Cratis.Chronicle.Reactors;
[EventType]
public record Chr0005CustomerRegisteredFixed(Guid CustomerId, string Email);
public class Chr0005CustomerReactorFixed : IReactor
{
// Now valid
public Task Registered(Chr0005CustomerRegisteredFixed @event) => Task.CompletedTask;
}

The analyzer provides a code fix that automatically adds the [EventType] attribute to the event parameter type.

Reactors handle side effects when events occur. Ensuring all event types are properly marked:

  • Guarantees proper event routing to reactors
  • Enables type-safe event handling
  • Ensures events are correctly serialized/deserialized
  • Maintains schema tracking for events
  • CHR0001: Event sequence append operations
  • CHR0004: Reactor method signatures
  • CHR0007: Reducer event parameters