---
title: 'CHR0004: Reactor method signature must match allowed signatures'
---

## Rule Description

Methods in reactor classes must follow one of the allowed signatures for event handling. This ensures proper integration with Chronicle's reactor infrastructure.

## Severity

Warning

## Allowed Signatures

Event handler methods in reactors must have one of the following signatures:

```csharp
// Async with event only
Task MethodName(TEvent @event)

// Async with event and context
Task MethodName(TEvent @event, EventContext context)

// Synchronous with event only
void MethodName(TEvent @event)

// Synchronous with event and context
void MethodName(TEvent @event, EventContext context)
```

Where `TEvent` is a type marked with `[EventType]`.

## Example

### Violation

```csharp
public class OrderReactor : IReactor
{
    // CHR0004: Invalid signature - returns Task<bool> instead of Task
    public async Task<bool> OrderCreated(OrderCreated @event)
    {
        // Process event
        return true;
    }

    // CHR0004: Invalid signature - third parameter not allowed
    public async Task OrderUpdated(OrderUpdated @event, EventContext context, string extraParam)
    {
        // Process event
    }
}
```

### Fix

```csharp
public class OrderReactor : IReactor
{
    // Valid signature
    public async Task OrderCreated(OrderCreated @event)
    {
        // Process event
    }

    // Valid signature with context
    public async Task OrderUpdated(OrderUpdated @event, EventContext context)
    {
        // Process event
    }

    // Valid synchronous signature
    public void OrderShipped(OrderShipped @event)
    {
        // Process event
    }
}
```

## Why This Rule Exists

Reactors are a core pattern in Chronicle for handling side effects when events occur. Standardized method signatures ensure:
- Predictable reactor behavior
- Proper infrastructure integration
- Clear code patterns across the codebase
- Reliable event handling

## Related Rules

- [CHR0005](/chronicle/code-analysis/chr0005/): Reactor event parameter must have [EventType] attribute
- [CHR0006](/chronicle/code-analysis/chr0006/): Reducer method signatures
