
## Review A dedicated reviewer checked the rule description successfully for: - [ ] logical errors and incorrect information - [ ] information gaps and missing content - [ ] text style and tone - [ ] PR summary and labels follow [the guidelines](https://github.com/SonarSource/rspec/#to-modify-an-existing-rule)
11 lines
866 B
Plaintext
11 lines
866 B
Plaintext
== Why is this an issue?
|
|
|
|
When a class has only a `private` constructor, it can't be instantiated except within the class itself.
|
|
Such classes can be considered https://en.wikipedia.org/wiki/Dead_code[dead code] and should be fixed
|
|
|
|
=== Exceptions
|
|
|
|
* Classes that access their private constructors (https://en.wikipedia.org/wiki/Singleton_pattern[singletons] or https://learn.microsoft.com/en-us/dotnet/architecture/microservices/microservice-ddd-cqrs-patterns/enumeration-classes-over-enum-types[smart enums]) are ignored.
|
|
* Classes with only `static` members are also ignored because they are covered by Rule S1118.
|
|
* Classes that derive from https://learn.microsoft.com/en-us/dotnet/api/system.runtime.interopservices.safehandle[SafeHandle] since they can be instantiate through https://learn.microsoft.com/en-us/dotnet/standard/native-interop/pinvoke[P/Invoke].
|