sonar-dotnet
sonar-dotnet copied to clipboard
Rule idea: Replace protected parameterless empty constructor with abstract class
Follow up of #8795
Suggest the exact opposite from what was originally suggested: If there's a parameterless protected constructor without any public/internal constructors, suggest making the class abstract to make the contract clear.
Ask to remove the constructor only if it's empty.
This would also trigger in a case like this, right?
class MyClass
{
protected MyClass()
{
}
public MyClass Factory()
{
return new MyClass();
// do some setup
}
}
I think there needs to be another condition.
Maybe not instantiated inside as well... Does such a thing have a reason not to be sealed?