---
title: Code Analysis Rules
---

This section documents the code analysis rules provided by the Chronicle Code Analyzer for the .NET client.

All rules follow the identifier format `CHR####` where the numbers are sequential without gaps.

## Rules Overview

| Rule ID | Title | Severity | Description |
|---------|-------|----------|-------------|
| [CHR0001](/chronicle/code-analysis/chr0001/) | Event type must have [EventType] attribute | Error | Types appended to event sequences must be marked with [EventType] attribute |
| [CHR0002](/chronicle/code-analysis/chr0002/) | Declarative projection event type must have [EventType] attribute | Error | Declarative projection generic arguments must reference types with [EventType] attribute |
| [CHR0003](/chronicle/code-analysis/chr0003/) | Model bound projection attribute must reference event type with [EventType] attribute | Error | Model bound projection attributes must reference types with [EventType] attribute |
| [CHR0004](/chronicle/code-analysis/chr0004/) | Reactor method signature must match allowed signatures | Warning | Reactor methods must follow allowed signatures |
| [CHR0005](/chronicle/code-analysis/chr0005/) | Reactor event parameter must have [EventType] attribute | Error | Event parameters in reactor methods must be marked with [EventType] attribute |
| [CHR0006](/chronicle/code-analysis/chr0006/) | Reducer method signature must match allowed signatures | Warning | Reducer methods must follow allowed signatures |
| [CHR0007](/chronicle/code-analysis/chr0007/) | Reducer event parameter must have [EventType] attribute | Error | Event parameters in reducer methods must be marked with [EventType] attribute |
| [CHR0012](/chronicle/code-analysis/chr0012/) | Event types should avoid nullable properties | Warning | Nullable properties are supported on events but are often better modeled as separate event types |
| [CHR0013](/chronicle/code-analysis/chr0013/) | Reactor cannot combine EventStore with explicit event sequence | Error | Reactors with [EventStore] must not also configure an explicit event sequence |
| [CHR0014](/chronicle/code-analysis/chr0014/) | Reducer cannot combine EventStore with explicit event sequence | Error | Reducers with [EventStore] must not also configure an explicit event sequence |
| [CHR0015](/chronicle/code-analysis/chr0015/) | Projection must not have side effects | Error | Projections must not inject ICommandPipeline or IEventLog |
| [CHR0016](/chronicle/code-analysis/chr0016/) | Projection Define() must not contain imperative code | Error | Projection Define() must only contain builder calls, not imperative statements |
| [CHR0017](/chronicle/code-analysis/chr0017/) | Constraint must not have side effects | Error | Constraints must not inject ICommandPipeline or IEventLog |
| [CHR0018](/chronicle/code-analysis/chr0018/) | Constraint Define() must not contain imperative code | Error | Constraint Define() must only contain builder calls, not imperative statements |
| [CHR0019](/chronicle/code-analysis/chr0019/) | Projection expression lambda must only access members | Error | Expression lambdas in projection builder methods must be simple member-access expressions |
| [CHR0020](/chronicle/code-analysis/chr0020/) | Constraint expression lambda must only access members | Error | Expression lambdas in constraint builder methods must be simple member-access expressions |
| [CHR0021](/chronicle/code-analysis/chr0021/) | Event types should be record types | Warning | Event types should be declared as record types for immutability |

## Quick Fixes

All error rules (CHR0001, CHR0002, CHR0003, CHR0005, CHR0007) provide a code fix that automatically adds the `[EventType]` attribute to the referenced type.

## Installation

The analyzer is automatically included when you reference the `Cratis.Chronicle` NuGet package.
