Code Issues – Base type constructors are not implemented
The Base type constructors are not implemented code issue is an alternative code issue to the “Can implement base type constructors“. The different between these two is in their type – one is an error and another one is a hint. When the current type doesn’t implement non-default constructors from a base type the “Base type constructors are not implemented” error is shown.
Consider the following example, where you can see this code issue:
Here we have two classes – Person and Customer. The Person class has a single constructor that takes one parameter of type string. The Customer class, on the other hand, doesn’t have any constructors, and the compiler will generate the default one – a public constructor with no parameters. This default constructor will call the default constructor of the base class, which simply doesn’t exist, and the source code won’t compile in this case. Thus, we have to implement at least missing constructors from the base class – the code issue is shown in this case:
How to fix:
- Apply the Add Missing Constructors code provider:
See the full list of code issues specific to constructors.
—– Products: CodeRush Pro Versions: 12.1 and up VS IDEs: any Updated: Nov/19/2012 ID: C093