Type to search pages and rules.

Browse pages

LS1002: Domain Declares an Enum

LS1002 is a compiler check that reports an enum declared in Domain, the project that holds business rules, because an enum carries no behavior and no stable code for callers outside Domain. This page states what the rule reports, where the warning sits, and how to replace the enum with an abstract record and sealed cases.

Markdown

Reference#

What the rule enforces#

LS1002 enforces Model every closed set of domain values without enums (litespec/backend/dotnet/domain#model-every-closed-set-of-domain-values-without-enums). It runs in Domain only. Its category is LiteSpec.Domain. It reports a warning and is enabled by default, as the Analyzers overview describes.

What the rule reports#

The rule reports the name of any enum declared in Domain. The diagnostic sits on the enum name.

Failing example#

C#
namespace Shop.Domain.Orders;

public enum OrderStatus { Draft, Placed }

Passing example#

C#
namespace Shop.Domain.Orders;

public abstract record OrderStatus(string Code);

public sealed record Draft() : OrderStatus("draft");

How to fix#

Replace the enum with an abstract record base and one sealed record per case, exposing a stable Code and converting labels through FromCode.

Notes#

What the rule ignores#

The rule does not report record hierarchies. It does not run outside Domain.