Browse pages
LS5005: Runtime Value Differs from Its Record
LS5005 is a compiler check that reports a hand-written event Classification or exception Code differing from what its record states, because a second copy of a record value drifts from the record. This page states what the rule reports, where the error sits, and how to let the record decide the value.
Reference#
What the Rule Enforces#
LS5005 enforces Generate Runtime Values from the Records (litespec/backend/dotnet/stack#generate-runtime-values-from-the-records). It runs in Domain only. Its category is LiteSpec.Traceability.
What the Rule Reports#
The rule reports a domain event declaring Classification with a value other than its event identifier, and a rule exception declaring Code with a value other than the code of the refusal result its rule names. The diagnostic sits on the member name.
Failing Example#
/// <implements>event/expense.submitted</implements>
public sealed partial record ExpenseSubmittedEvent(ExpenseId ExpenseId, Money Amount) : IDomainEvent
{
public const string Classification = "event/expense.placed";
}Passing Example#
/// <implements>event/expense.submitted</implements>
public sealed partial record ExpenseSubmittedEvent(ExpenseId ExpenseId, Money Amount) : IDomainEvent;How to Fix#
Delete the hand-written value and declare the type partial, so the generator writes the value from the record; or correct the value to match the record. A code fix deletes the hand-written value that differs from the record, titled with the value the record states when the record resolves, with Fix All. Deleting a hand-written value that equals the record is the code fix for LS5006.
Notes#
What the Rule Ignores#
The rule does not report a value equal to its record. It does not report an event or exception with no mark, or with a mark naming no record; LS5001 and LS5002 own those findings. It does not report an exception whose rule names no refusal result with a code. The rule stays silent when no .litespec/project.json is in reach, or when the docs root it names cannot be resolved; the CLI owns that configuration error. It does not run outside Domain.
Severity#
The rule reports an error. A finding that a live exception covers stays silent. An .editorconfig entry for the rule id overrides the computed severity.