Code analysis
This section documents the code analysis rules provided by the Chronicle code analyzer for .NET.
Chronicle includes Roslyn analyzers that validate aggregate root event handler signatures at compile time to catch errors early and enforce best practices.
All rules follow the identifier format ARCCHR#### where the numbers are sequential without gaps.
Rules Overview
Section titled “Rules Overview”| Rule ID | Title | Severity | Description |
|---|---|---|---|
| ARCCHR0001 | Incorrect aggregate root event handler signature | Error | Aggregate root event handlers must follow allowed On method signatures. |
| ARCCHR0002 | Ambiguous command event source id | Warning | A command has multiple candidate identities without specifying which to use. Positional [Key] parameters count alongside keyed properties and event-source-id types. |
| ARCCHR0003 | Reactor must not reach the default event log | Warning | A reactor appends to the default event log directly instead of returning the events. |
| ARCCHR0005 | Chronicle is used but not wired up | Warning | A project uses Chronicle features but sets up Arc without WithChronicle() or AddCratis(). |
| ARCCHR0008 | Command key marked with the data annotations Key attribute | Warning | A command marks its key with an attribute Chronicle does not resolve keys from. |
| ARCCHR0009 | Command property reads as a secret and should be marked [NotAudited] | Warning | A command carries a property whose name reads like a secret, whose value is written to the causation of every event it appends. |
For example, record Change([Key] Guid First, [Key] Guid Second) has two candidates for ARCCHR0002. Use Cratis.Chronicle.Keys.KeyAttribute to mark only the intended key, or implement ICanProvideEventSourceId to choose explicitly. Marking both the parameter and its matching property counts as one candidate, not two. Existing exemptions for handlers returning explicit event-source identities still apply.
Quick Fixes
Section titled “Quick Fixes”| Rule ID | Quick fix |
|---|---|
| ARCCHR0008 | Use the Chronicle Key attribute — rewrites the attribute to the one Chronicle resolves keys from. |
The other rules have no automatic code fix.
Installation
Section titled “Installation”The analyzer is automatically included when you reference Chronicle in your project. No additional configuration is required.
<ItemGroup> <ProjectReference Include="../Chronicle/Chronicle.csproj" /></ItemGroup>