JetBrains Rider 2024.1 Help

Code inspection: Class is never instantiated (private accessibility)

This inspection reports private classes and records, for which no objects were created in the current local scope. Unlike the 'Type is never used' problem, a type reported by this inspection has usages: it may be used as a base type, as a method or type parameter, in an uninitialized variable declaration, and so on.

There are a few possible solutions based on different situations: If the class only contains static members and/or constant fields, consider making it static. If the class is a base class or is used for type parameters, consider making it abstract. If the class is not required and does not affect your existing code, you may consider removing it. However, if the class should be instantiated but is not, consider creating instances where necessary.

In all cases, your intention behind the class should be clear to anyone reading your code in the future. The action you choose should add up to the readability and maintainability of your code.

Last modified: 24 May 2024