Browse pages
LS1001: Domain References an Outer-Layer Concern
LS1001 is a compiler check that reports code in Domain, the project that holds business rules, naming a persistence, web, messaging, or logging type, which would tie those rules to infrastructure they cannot test on their own. This page states what the rule reports, where the warning sits, and how to move the flagged use out of Domain.
Reference#
What the rule enforces#
LS1001 enforces Keep Domain free of outer-layer concerns (litespec/backend/dotnet/domain#keep-domain-free-of-outer-layer-concerns). 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 every identifier or using name that resolves to one of the 19 outer-layer namespace prefixes listed on the overview. The diagnostic sits on the identifier in code, or on the name in a using directive. Its message names the type and the namespace it comes from.
Failing example#
using Microsoft.Extensions.Logging;
namespace Shop.Domain.Orders;
public sealed class Order
{
}Passing example#
using System;
using System.Collections.Generic;
namespace Shop.Domain.Orders;
public sealed class Order
{
public List<string> Tags { get; } = new();
public DateTime PlacedAt { get; init; }
}How to fix#
Move the outer-layer use out of Domain: depend on a Domain type or a base class library type instead, and let Application or Infrastructure adapt the outer-layer service.
Notes#
What the rule ignores#
The rule does not report project types or base class library types such as System, System.Collections.Generic, or System.Linq. It does not report var, documentation comments, or a namespace that only shares a prefix, such as MartenStore. In a member access such as session.Store(session), the rule reports the member name rather than the qualifier. It does not run outside Domain.