S3453 — Classes should not have only "private" constructors

Language
VB.NET
Type
Bug
Severity
Major
Tags
design

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 dead code and should be fixed

Exceptions

How to fix it

Code examples

Noncompliant code example


Public Class [MyClass] ' Noncompliant: the class contains only private constructors
    Private Sub New()
        ' ...
    End Sub
End Class

Compliant solution


Public Class [MyClass] ' Compliant: the class contains at least one non-private constructor
    Public Sub New()
        ' ...
    End Sub
End Class

Resources

Documentation

↑ Back to top