Skip to content

Abstract class ctors should not have public constructors #164

@ElemarJR

Description

@ElemarJR
abstract class Foo
{
    public Foo() { /* .. */ }
}

May become:

abstract class Foo
{
    protected Foo() { /* .. */ }
}

or

abstract class Foo
{
    protected internal Foo() { /* .. */ }
}

or

abstract class Foo
{
    private Foo() { /* .. */ }
}

It may only become private if no deriving class is already referencing it. And protected internal if no deriving class outside the assembly. In other words, should not break the code.
Category: Usage
Severity: Warning
Diagnostic Id: CC0060

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions