Code inspection: Class can be made sealed (non-inheritable) (non-private accessibility)
This inspection reports a class that has no inheritors in the current solution and can be marked sealed.
It is useful for classes that are not intended to be base classes, because sealing them makes that intent explicit and can simplify further analysis and refactoring.
Example
In this example, the MessageFormatter class is never used as a base class. The quick-fix marks it as sealed.
public class MessageFormatter
{
public string Format(string value) => value.Trim();
}
public sealed class MessageFormatter
{
public string Format(string value) => value.Trim();
}
Quick-fix
The quick-fix makes the class sealed. If the class contains non-override virtual members, the quick-fix also removes virtual dispatch that no longer makes sense in a sealed class.
27 March 2026