Home > Code Generation > Specific CodeRush code providers for declaring new classes

Specific CodeRush code providers for declaring new classes

June 1st, 2012

CodeRush provides code providers for declaring classes, such as:

There are two additional specific code providers that declare classes:

  • Declare Class with Properties
  • Declare EventArgs Descendant

The Declare Class with Properties declares a class with properties (auto-implemented) initialized to the parameters passes to the constructor. That is, if you type a constructor call to an undeclared class that takes several parameters, for example:

CodeRush Declare Class with Properties preview

the code provider will produce the following class after it is applied:

CodeRush Declare Class with Properties result

All parameters are linked together for fast renaming. Properties are renamed in sync with parameters.

The Declare EventArgs Descendant is a dedicated code provider to declare classes that descend from the System.EventArgs class. It is available on the type reference to an undeclared class, whose name ends with the “EventArgs”:

CodeRush Declare EventArgs Descendant simple preview

or on the type argument that must be an EventArgs descendant, for example:

CodeRush Declare EventArgs Descendant event handler preview

The following result will be produced in the last case:

CodeRush Declare EventArgs Descendant event handler result

—–
Products: CodeRush Pro
Versions: 12.1 and up
VS IDEs: 2008 and up
Updated: Sep/21/2012
ID: C166

Similar Posts: