---
title: 'CHR0007: Reducer event parameter must have [EventType] attribute'
---

## Rule Description

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

## Severity

Error

## Example

### Violation

```csharp
// Missing [EventType] attribute
public record InventoryAdjusted(string ProductId, int Quantity);

public class InventoryReducer : IReducerFor<InventoryState>
{
    // CHR0007: Type 'InventoryAdjusted' must be marked with [EventType] attribute
    public void Adjusted(InventoryAdjusted @event)
    {
        // Update inventory
        State.Quantity += @event.Quantity;
    }
}
```

### Fix

```csharp
using Cratis.Chronicle.Concepts.Events;

[EventType]
public record InventoryAdjusted(string ProductId, int Quantity);

public class InventoryReducer : IReducerFor<InventoryState>
{
    // Now valid
    public void Adjusted(InventoryAdjusted @event)
    {
        // Update inventory
        State.Quantity += @event.Quantity;
    }
}
```

## Quick Fix

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

## Why This Rule Exists

Reducers build state from events in a deterministic way. Ensuring all event types are properly marked:
- Guarantees proper event routing to reducers
- Enables type-safe state reduction
- Ensures events are correctly serialized/deserialized
- Maintains schema tracking for events
- Allows for proper reducer replay and catchup

## Related Rules

- [CHR0001](/chronicle/code-analysis/chr0001/): Event sequence append operations
- [CHR0005](/chronicle/code-analysis/chr0005/): Reactor event parameters
- [CHR0006](/chronicle/code-analysis/chr0006/): Reducer method signatures
