rspec/rules/S3453/why-dotnet.adoc

11 lines
866 B
Plaintext
Raw Normal View History

== 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].