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

// Missing [EventType] attribute
public record CustomerRegistered(Guid CustomerId, string Email);
public class CustomerReactor : IReactor
{
// CHR0005: Type 'CustomerRegistered' must be marked with [EventType] attribute
public async Task Registered(CustomerRegistered @event)
{
// Send welcome email
await SendWelcomeEmail(@event.Email);
}
}
using Cratis.Chronicle.Concepts.Events;
[EventType]
public record CustomerRegistered(Guid CustomerId, string Email);
public class CustomerReactor : IReactor
{
// Now valid
public async Task Registered(CustomerRegistered @event)
{
// Send welcome email
await SendWelcomeEmail(@event.Email);
}
}

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