Posts Tagged ‘Coding Helpers’

Smart Constructor Fields/Properties Chooser dialog improvements

April 9th, 2012 Comments off
NOTE: please take into account the “Versions” field at the bottom of the post, to determine the build number for which the content is applied. Click here to see the latest officially released version.

The Smart Constructor CodeRush feature allows you to add constructors to the current class or structure, and pass type members, like fields and properties for initialization through its parameters. To choose fields and properties that will be passed to a new constructor, the following dialog is used:

CodeRush Smart Constructor dialog

Read more…

The Create Descendant code provider availability change

March 23rd, 2012 Comments off

The Create Descendant and Create Descendant (with virtual overrides) CodeRush code providers are now available not only on the type declaration but on any reference to a type inside source code, for example:

CodeRush Create Descendant available on a reference

It allows to create derived classes without navigating to the declaration of the ancestor class.

Products: CodeRush Pro
Versions: 12.1 and up
VS IDEs: 2008 and up
Updated: Mar/24/2012
ID: U005

Changing an explicit cast-expression to an ‘as’ operator and back

February 16th, 2012 Comments off

Objects can be converted from one type to another, assuming that the types are compatible. Often this is achieved using implicit conversion or explicitly with the cast operator. To perform an explicit casting, there are two approaches used:

  • a cast-expression
  • an ‘as’ operator

Read more…

Code Providers – Create Event Trigger

February 16th, 2012 2 comments

The Create Event Trigger CodeRush code provider generates an event trigger for the specified event. An event trigger is a single method that is used to raise an event. Although it is not strictly necessary to create such a trigger, it is useful, as it makes maintenance of the code simpler.

Read more…

Working with HTML tables using CodeRush

January 17th, 2012 Comments off

Generating any-size HTML tables and navigating between table cells is very easy when you have DevExpress CodeRush installed. To create a new table just type “.t” inside the HTML markup and press the Space bar. This code snippet template will execute the Table Size UI feature of CodeRush, and the following tiny window will appear:

CodeRush Table Size UI window

Read more…

Declaring fields using CodeRush consume-first declaration features

December 16th, 2011 Comments off

Unlike the local variable declarations, fields are simply variables that are declared directly within the code block of a class or a structure. Fields are declared in the type block by specifying the access level of the field, the type of the field and the name of the field. A field may also include a readonly modifier. This type of field can only have its value set directly in its declaration or from within a constructor of its containing class.

Read more…

Declaring enumeration types and its elements in CodeRush

December 14th, 2011 Comments off

An enumeration type is a special set of related constants, each with an integer value. Enumerations are useful for defining states and sequences, particularly when there is a natural progression through those states. Each constant in the enumeration list can be compared and formatted using either its name or value. For example, assume that you have to define a variable whose value will represent a day of the week. There are only seven meaningful values which that variable will ever store. To define those values, you can use an enumeration type.

Read more…

Converting methods to functions or procedures

October 31st, 2011 Comments off

The simplest type of method is one that performs a task without requiring any parameters and without returning any information – let’s call them procedures (or void methods). Methods that use some type as the return value – are functions.

Sometimes, when we declare a method with a return value, we may realize that we don’t actually need this return value, and instead, need a simple void method that does not return anything. On the other hand, we marked a method as void, but may require it to be a function, returning a value.

Read more…