CHR0026: [Key] on an EventSourceId<T> is redundant
Rule Description
Section titled “Rule Description”A property or record parameter whose type derives from EventSourceId<T> already carries the key (stream identity). Remove the redundant [Key] attribute.
This rule does not report [Subject]. The type of an identifier does not establish its role as a compliance subject: an event can carry an order’s event-source identity and a separate actor identity, both derived from EventSourceId<T>. Keep an explicit [Subject] when it identifies that actor.
Severity
Section titled “Severity”Warning
Example
Section titled “Example”using Cratis.Chronicle.Events;using Cratis.Chronicle.Keys;
public record Chr0026AccountId(Guid Value) : EventSourceId<Guid>(Value);
public record Chr0026Account( // Warning CHR0026: Chr0026AccountId derives from EventSourceId<T>, so it already is the // key/stream identity — the [Key] attribute is redundant. [Key] Chr0026AccountId Id, string Name);Why This Rule Exists
Section titled “Why This Rule Exists”EventSourceId<T> is a strongly typed event-source identity. Adding [Key] repeats the key role already expressed by the type, so the code fix removes only that attribute.
An explicit [Subject] has a different purpose. At runtime, Chronicle reads the marked property’s or constructor parameter’s value to resolve the compliance subject. Removing it can change whose protected data an event contains. CHR0026 therefore leaves [Subject] unchanged, including on EventSourceId<T>-derived members.
Related Rules
Section titled “Related Rules”- Event source — how
EventSourceId<T>identifies a stream. - Subject — how the compliance subject is resolved.