Code Issues – Can implement base type constructors
The Can Implement base type constructor code issue of type hint suggests that you implement the constructors that are missing for the current class, but exist in the ancestor (base) class.
For instance, once you implement your custom exception class derived from the System.Exception, you have to provide the full set of its constructors. Failure to provide all of the constructors of the Exception class can make it difficult to correctly handle exceptions. For example, the constructor with the signature “Exception(string, Exception)” is used to create exceptions that are caused by other exceptions. Without this constructor, you cannot create and throw an instance of your exception descendant that contains an inner exception, which is what managed code should do in such situations.
The first three constructors of the Exception are public by convention. The fourth constructor is protected and implements the custom serialization support, because the Exception class implements the ISerializable interface.
How to fix:
The fix for this code issue is the Add Missing Constructors code provider:
After it is performed – it will leave you with all necessary constructors generated automatically:
A similar and alternative code issue to this one, is the “Base type constructors are not implemented” code issue, which is not a hint, but an error. Also, see the full list of code issues specific to constructors.—– Products: CodeRush Pro Versions: 12.1 and up VS IDEs: any Updated: Nov/12/2012 ID: C092