Specific CodeRush code providers for declaring new classes
CodeRush provides code providers for declaring classes, such as:
- Declare Class to declare a simple class without members,
- Declare Struct to declare a structure without members,
- Declare Attribute to declare an attribute class,
- Create Descendant and Create Descendant (with virtual overrides) to declare descendant classes,
- Create Ancestor to declare base classes,
- Create Implementer to declare a class that implements an interface.
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:
the code provider will produce the following class after it is applied:
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”:
or on the type argument that must be an EventArgs descendant, for example:
The following result will be produced in the last case: