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 warning 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 all five projects. Its category is LiteSpec.Style. It reports a warning and is enabled by default, as the Analyzers overview describes. It decides at the end of compilation, after every derived type is known.
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, 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 five projects.