Archive
Coding Helpers – Reverse For Loop
When working with arrays and lists enumerating all of its items we usually create a for loop statement as follows:
CodeRush code generation features for declaring types
The following code declaration features are available in CodeRush for generating new type declarations (in alphabetical order). Click on the name to learn more about a specific code provider.
Create Ancestor
Creates an ancestor class for an active type. Active type becomes a descendant of the created ancestor class.
Create Descendant
Creates a descendant class providing overrides for abstract members.
Read more…
Declare Attribute CodeRush code provider
Attributes provide a powerful method of associating declarative information by decorating elements of the code, such as types, methods, properties, parameters and assemblies. Once an attribute is associated with a program entity, it can be queried at run time and used in various cases, for example, associating a help document with program entities (via the Help attribute), or marking an item as out of date (via the Obsolete attribute).
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.
Declare Delegate CodeRush code provider
A delegate is a special kind of object that holds a reference to a method. Once a delegate is assigned a method, it behaves exactly like that method. It can have parameters and a return value. Using a delegate allows the programmer to encapsulate a reference to a method inside a delegate object.
Creating interface implementers with CodeRush
A class that implements an interface should implement all members of that interface. Members of implemented interfaces can be declared in two ways: implicit or explicit. That is why there are two versions of the Create Implementer code provider in CodeRush:
- Create Implementer (implicit)
- Create Implementer (explicit)
Generating the Switch/Select statement for enumeration variables
CodeRush with Refactor! Pro provides a code provider that allows you to easily generate a switch (C#) or Select (VB) statement for all elements of the enumeration of the active identifier of the enumeration type. The Create Case Blocks from Enum code provider shows a part of the resulting code before applying it. It is possible to apply the code provider on a local variable or a parameter: