Home > Code Generation > Code Gen – Declare Class

Code Gen – Declare Class

November 5th, 2010

Declare Class code provider generates a class for the current type reference to a non-existent type. If the type reference on the editor caret creates a new instance of a non-existent type that takes some arguments, the appropriate constructor is generated for the new class.

CSharp:

CodeRush Declare Class

Result:

CodeRush Declare Class

Visual Basic:

CodeRush Declare Class

Result:

CodeRush Declare Class

Otherwise, if there are no arguments passed, the default public parameterless constructor is declared:

CSharp:

CodeRush Declare Class

Result:

CodeRush Declare Class

Visual Basic:

CodeRush Declare Class

Result:

CodeRush Declare Class

A marker will be dropped after Declare Class is performed at the source text caret position to easily get back and continue code editing:

CodeRush Declare Class marker

Also, text fields will be created for the constructor parameters, if any, to easily rename them, according to your preference (see the sample above).

A similar code provider is Declare Struct.

—–
Products: CodeRush Pro and CodeRush Xpress
Versions: 10.1 and up
VS IDEs: any
Updated: Nov/05/2010
ID: C032

Similar Posts: