ReSharper 2024.1 Help

Code Inspection: Make constructor in abstract class protected

Category

Common Practices and Code Improvements

ID

PublicConstructorInAbstractClass

EditorConfig

resharper_public_constructor_in_abstract_class_highlighting

Default severity

Suggestion

Language

C#

Requires SWA

No

It makes little sense to have the public modifier on an abstract class constructor. After all, an abstract class cannot be created directly – only via a derived instance. Consequently, it is only the derived classes for whom it makes sense to access the constructor in the first place. Hence, ReSharper recommends that you make the constructor protected.

Last modified: 15 April 2024