Browse pages
LS3004: Concrete Class Is Not Sealed
LS3004 is a compiler check that reports a concrete class with no derived type that is not sealed, which reads as designed for extension, so readers subclass it where the author meant no one to extend it. This page states what the rule reports, where the error sits, and how to seal the class or show it is built for extension.
Reference#
What the Rule Enforces#
LS3004 enforces Keep implementation style consistent (litespec/backend/dotnet/naming#keep-implementation-style-consistent). It runs in every production project. Its category is LiteSpec.Style. Severity and enablement follow the Analyzers overview. It decides at the end of compilation, as the Analyzers overview describes.
What the Rule Reports#
The rule reports a concrete class declared in source that nothing derives from and that is not sealed. The diagnostic sits on the class name.
Failing Example#
public class Order { }Passing Example#
public sealed class Order { }How to Fix#
Mark the leaf class sealed, or add the virtual or protected member that shows the class is designed for extension.
Notes#
What the Rule Ignores#
The rule does not report records, static classes, abstract classes, sealed classes, the Program composition marker, a base that has a derived class, or a class designed for extension through a virtual member, an unsealed override, or a protected member. It does not run outside the production layers.