CodeRush

Automatic Code Generation

Code Templates

Code templates are blocks of code that expand from short abbreviations and mnemonics that you type into the editor. CodeRush's template engine represents the state-of-the-art in code template technology, offering unrivaled and unparalleled flexibility and power.

To expand a template, type in the template name and then press Space. Many templates start out simple, but can be made more and more specific with additional modifying mnemonics that you can chain together into a powerful template combo! For example, you can type "m" to declare a void method (or Sub in VB), or "mb" to declare a method that returns a Boolean, or "mb[" to declare a method that returns an array of Booleans. As you see it's very easy to learn templates because of the strong logic and common sense in their structure.

One more thing that makes templates a joy to use is their ability to adapt to context and expand in an intelligent manner; the same template can expand appropriately for different contexts. For instance, you can use the same "mb" alias to declare a Boolean method if you're inside a class, or to invoke a message box if you're inside a method. Context allows templates to use the simplest possible abbreviation in both cases. So instead of having to memorize thousands of crazy abbreviations, you simply learn one or two rules and apply a bit of common sense, and you'll find yourself up and running in no time.

One of the coolest features in CodeRush is the training window, which displays useful hints as well as template verbs so you can be instantly productive. In addition to these hints, the training window presents a template expansion preview. Using this preview you can see the code that will be generated if you press Space to expand the template.

To see a sample template expansion, click the image below.

Incremental Templates - CodeRush by DevExpress

Templates can do more than simply enter text. They can also position the caret, select code, drop markers (for navigation), create text fields or establish links among identifiers (so changes to one result in changes to all). All these are little enhancements work together so you can write code more efficiently and devote more focus to the design and the essence of the problem you're trying to solve. Read on to learn more about these powerful tools you can incorporate into your own templates...

Code Providers

CodeRush includes dozens of Code Providers used to create common code parts based on existing code. The major code providers relate to automatic declaration. They enable you to create a declaration based on a reference to an undeclared class, member, variable, struct etc. In addition, there are conversion code providers, code providers working with loops and conditionals, embedding code providers etc.

Code Providers - CodeRush by DevExpress

The CodeRush context menu contains only code providers available in the current context.

Here is the full list of currently available code providers:

Supported Code Providers

Add AssocatedControlID Attribute Add Contract Add Default Case Branch
Add Else Statement Add Getter Add Initialization
Add Missing Case Statements Add Missing Constructors Add RunAt Attribute
Add Setter Add to Interface Add Validator
Add XML Comments Change Tag Consolidate duplicate code to
Convert to Auto-implemented Property Convert to Function Convert to Integer
Convert to Procedure Convert to Property with Backing Store Create Ancestor
Create Case Blocks from Enum Create Descendant Create Descendant (with virtual overrides)
Create Event Trigger Create Implementer (implicit) Create Implementer (explicit)
Declare Action Declare Attribute Declare Class
Declare Class with Properties Declare Constructor Declare Controller
Declare Delegate Declare Enum Declare Enum Element
Declare Event Declare Event Handler Declare EventArgs Descendant
Declare Field Declare Field (read-only) Declare Getter
Declare Initialized Field Declare Initialized Fields Declare Initialized Properties
Declare Initialized Property Declare Interface Declare Local
Declare Local (implicit) Declare Method Declare Method (abstract)
Declare Properties Declare Property Declare Property (auto-implemented)
Declare Property (with backing store) Declare Setter Declare Struct
Declare View Dispose Fields Embed Selection
Format Item... Implement IDisposable Introduce Setter Guard Clause
Introduce Using Statement Invert Selection Make Member Private
Merge Styles Mirror Code Reference Assembly
Remove Attribute Remove Outer Tag Remove Region Directives
Remove Setter Remove Setter Guard Clause Replace "this" Qualifier with Local Variable
Reverse For Loop Rotate 90 Degrees Seal Class
Set CssClass Spell Checker Split Style
Surround with Tag Surround with UpdatePanel Toggle ViewState
Toggle ViewState (all Controls) Use Equality Operator Use Equals
Use Explicit Typecast Use Identity Operator Use Implicit Typecast
Use IsNullOrEmpty

Cycle Scope Up/Down

You can change the scope of a class or a class member with a single keystroke. Use the ALT+UP or ALT+DOWN shortcuts to change the element scope.

Cycle Scope Up\Down - CodeRush by DevExpress

Duplicate Line

Duplicate Line is useful when you need to create several similar lines in your code. For instance, you are going to declare a number of string fields. You can declare each field manually, but that will take too much time. The other method is to create a single declaration, and duplicate it with Duplicate Line. Place the cursor on the line to be duplicated, and press SHIFT+ENTER. CodeRush will duplicate the line and select the field name in the new line, that will allow you to immediately type the name of the new field.

Duplicate Line - CodeRush by DevExpress

CodeRush includes the following duplications:

DuplicationDescription
FieldDuplicates a field declaration.
Initialized FieldDuplicates an initialized field declaration (bringing the initialization to the new line).
Initialized Integer FieldDuplicates integer fields initialized to an integer value. The initialized value is incremented by one for the duplicated line.
EventDuplicates event declarations.
Method (Interface)Duplicates method declarations when inside an interface.
Property (Interface)Duplicates property declarations when inside an interface.
UsingDuplicates using statements.
if (aa is bb) Matches if-expressions checking to see if object ooo is of type ttt="". Declares a new local variable of type ttt, initialized to ooo (typecast as ttt).
Assignment StatementDuplicates an assignment statement.
Flagged Enum ElementDuplicates an initialized element of an enumeration, doubling the initialized value on the next line.

Intelassist

Intellassist completes text at the caret with an in-scope identifier, and may include other suggestions.

To use Intellassist, just write code as you normally would. When Intellassist senses one or more suggestions matching the code you've entered so far, the best suggestion will be displayed to the right of the caret. You can accept the offered suggestion, or its part (to the next uppercase letter) by pressing ENTER or SHIFT+ENTER appropriately.

Accepting Intellassist suggestions - CodeRush by DevExpress

If more than one entry is suggested, you can cycle forward and backward through the suggestions by pressing the TAB and SHIFT+TAB.

Switching between entries - CodeRush by DevExpress

Smart Constructor

Smart Constructor enables you to add a constructor to an existing class in several keystrokes. In addition, the generated constructor includes initialization of the specified members. An XML documentation stub is generated as well.

To add a constructor to a class just type "cc" within the class body and press Space. If the class contains members, Smart Constructor offers you to choose the ones to be initialized.

Smart Constructor - CodeRush by DevExpress

Smart Parens And Brackets

Smart Parens & Brackets adds a closing paren or bracket, after the opening one is typed, and places a text field between them. The feature is activated if an opening parenthesis or bracket is typed at the end of a an identifier, or if a parenthesis is typed in front of it.

The feature also enables you to quickly enclose an identifier to parens. Just select the needed identifier or another part of code, and type the opening paren.

Smart Parens & Brackets - CodeRush by DevExpress

More from DevExpress
Live Chat
Have a pre-sales question?
Need assistance with your evaluation?
We are here to help.
Chat is one of the many ways you can contact members of the DevExpress Team. We are available Monday-Friday between 7:30am and 4:30pm Pacific Time.
If you need additional product information, require pre-sales assistance, or want help with your order, write to us at info@devexpress.com or call us at
+1 (818) 844-3383.