Skip to content

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.

Rule IDTitleSeverityDescription
CHR0001Event type must have [EventType] attributeErrorTypes appended to event sequences must be marked with [EventType] attribute
CHR0002Declarative projection event type must have [EventType] attributeErrorDeclarative projection generic arguments must reference types with [EventType] attribute
CHR0003Model bound projection attribute must reference event type with [EventType] attributeErrorModel bound projection attributes must reference types with [EventType] attribute
CHR0004Reactor method signature must match allowed signaturesWarningReactor methods must follow allowed signatures
CHR0005Reactor event parameter must have [EventType] attributeErrorEvent parameters in reactor methods must be marked with [EventType] attribute
CHR0006Reducer method signature must match allowed signaturesWarningReducer methods must follow allowed signatures
CHR0007Reducer event parameter must have [EventType] attributeErrorEvent parameters in reducer methods must be marked with [EventType] attribute
CHR0012Event types should avoid nullable propertiesWarningNullable properties are supported on events but are often better modeled as separate event types
CHR0013Reactor cannot combine EventStore with explicit event sequenceErrorReactors with [EventStore] must not also configure an explicit event sequence
CHR0014Reducer cannot combine EventStore with explicit event sequenceErrorReducers with [EventStore] must not also configure an explicit event sequence
CHR0015Projection must not have side effectsErrorProjections must not inject ICommandPipeline or IEventLog
CHR0016Projection Define() must not contain imperative codeErrorProjection Define() must only contain builder calls, not imperative statements
CHR0017Constraint must not have side effectsErrorConstraints must not inject ICommandPipeline or IEventLog
CHR0018Constraint Define() must not contain imperative codeErrorConstraint Define() must only contain builder calls, not imperative statements
CHR0019Projection expression lambda must only access membersErrorExpression lambdas in projection builder methods must be simple member-access expressions
CHR0020Constraint expression lambda must only access membersErrorExpression lambdas in constraint builder methods must be simple member-access expressions
CHR0021Event types should be record typesWarningEvent types should be declared as record types for immutability

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

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