CHR0006: Reducer method signature must match allowed signatures
Rule Description
Section titled “Rule Description”Methods in reducer classes must follow one of the allowed signatures for event handling. This ensures proper integration with Chronicle’s reducer infrastructure.
Severity
Section titled “Severity”Warning
Allowed Signatures
Section titled “Allowed Signatures”Event handler methods in reducers must have one of the following signatures:
// Async with event onlyTask MethodName(TEvent @event)
// Async with event and contextTask MethodName(TEvent @event, EventContext context)
// Synchronous with event onlyvoid MethodName(TEvent @event)
// Synchronous with event and contextvoid MethodName(TEvent @event, EventContext context)Where TEvent is a type marked with [EventType].
Example
Section titled “Example”Violation
Section titled “Violation”public class ShoppingCartReducer : IReducerFor<ShoppingCart>{ // CHR0006: Invalid signature - returns Task<int> instead of Task public async Task<int> ItemAdded(ItemAdded @event) { // Update cart return 1; }
// CHR0006: Invalid signature - too many parameters public async Task ItemRemoved(ItemRemoved @event, EventContext context, bool validate) { // Update cart }}public class ShoppingCartReducer : IReducerFor<ShoppingCart>{ // Valid signature public async Task ItemAdded(ItemAdded @event) { // Update cart }
// Valid signature with context public async Task ItemRemoved(ItemRemoved @event, EventContext context) { // Update cart }
// Valid synchronous signature public void CartCleared(CartCleared @event) { // Clear cart }}Why This Rule Exists
Section titled “Why This Rule Exists”Reducers maintain state by processing events in sequence. Standardized method signatures ensure:
- Predictable reducer behavior
- Proper infrastructure integration
- Clear code patterns across the codebase
- Reliable state management