Archive

Archive for the ‘Code Generation’ Category

Coding Helpers – Add Initialization

August 15th, 2012 Comments off

The Add Initialization code provider inserts an initialization of the selected field or auto-implemented property to each constructor of the active type. The code provider is useful when you want to initialize those objects with a different default value:

Read more…

CodeRush INotifyPropertyChanged interface support

July 31st, 2012 2 comments

Since ancient times, CodeRush has supported the INotifyPropertyChanged interface implementation. The interface provides a standard way to notify binding clients of a property value change. It has just one event, with a simple and clear name, PropertyChanged.

The most important part of the support of this interface is connected to the code templates. Once you expand a property template in a class that implements the INotifyPropertyChanged interface, you will see the corresponding code generated. For instance, expanding the ‘ps’ template will produce the following code:

Read more…

CodeRush code generation features for declaring types

June 1st, 2012 Comments off

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

June 1st, 2012 2 comments

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).

Read more…

Specific CodeRush code providers for declaring new classes

June 1st, 2012 Comments off

CodeRush provides code providers for declaring classes, such as:

Read more…

Declare Delegate CodeRush code provider

June 1st, 2012 Comments off

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.

Read more…

Creating interface implementers with CodeRush

June 1st, 2012 2 comments

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)

Read more…

Creating simple templates step by step

April 26th, 2012 Comments off

Once you know recommendations for creating new templates and have the Templates options page open, you can start writing a template expansion starting from plain text. Any plain text typed or pasted into the Expansion area will be expanded as is, for example:

Read more…