Type to search pages and rules.

Browse pages

LS2017: LiteSpecLayer Names No Known Layer

LS2017 is a compiler check that reports a LiteSpecLayer project value naming no known layer under the layer-projects extension, so a misspelled value cannot silently turn the analyzers off. This page states what the rule reports, where the error sits, and how to name the layer.

Markdown

Reference#

What the Rule Enforces#

LS2017 enforces Use Five Application Projects (litespec/backend/dotnet/ext/layer-projects#use-five-application-projects). It runs in every project that declares LiteSpecLayer, whatever the value. Its category is LiteSpec.Layers. Severity and enablement follow the Analyzers overview.

What the Rule Reports#

The rule reports a declared LiteSpecLayer value that names no known layer: anything but Domain, Application.Abstractions, Application, Infrastructure, WebApi, Worker, Test, Tests, or None, ignoring dots and case. The diagnostic sits on the first token of the first file, and its message names the declared value and the accepted names.

Failing Example#

C#
namespace Shop.Billing;

internal sealed class ChargeDuesJob
{
}

with <LiteSpecLayer>Staging</LiteSpecLayer> in the project file.

Passing Example#

C#
namespace Shop.Billing;

internal sealed class ChargeDuesJob
{
}

with <LiteSpecLayer>Worker</LiteSpecLayer> in the project file.

How to Fix#

Set LiteSpecLayer to the layer the project holds, or to None to opt the project out. Under the default module layout the analyzers read each file's layer from its folder, so LiteSpecLayer has no effect there.

Notes#

What the Rule Ignores#

The rule does not report a project that declares no LiteSpecLayer value: without the property the analyzers read the assembly name suffix under layer-projects. It does not report the None value, which opts the project out on purpose.