Home > Code Generation > Code Gen – Declare Struct

Code Gen – Declare Struct

November 5th, 2010

Declare Struct code provider generates a structure 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 structure:

CSharp:

CodeRush Declare Struct

Result:

CodeRush Declare Struct

Visual Basic:

CodeRush Declare Struct

Result:

CodeRush Declare Struct

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

CSharp:

CodeRush Declare Struct

Result:

CodeRush Declare Struct

Visual Basic:

CodeRush Declare Struct

Result:

CodeRush Declare Struct

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

CodeRush Declare Struct 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 Class.

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

Similar Posts: