Back to Devexpress

Common Templates

coderushforroslyn-115918-coding-assistance-code-templates-common-templates.md

latest3.2 KB
Original Source

Common Templates

  • Jan 31, 2023
  • 2 minutes to read

CodeRush includes powerful library of code templates. This library contains shortcuts for the most common code constructions. The tables below show most useful templates.

Important

Visual Studio IntelliSense has priority over CodeRush templates. For information on how to prioritize a CodeRush template over Visual Studio IntelliSense , refer to the following topic section: Expand a Template Instead of Visual Studio IntelliSense.

Types Creation

TemplateExpansionContext
cClass with default constructorExpands on an empty line, in a namespace, class, or struct.
iInterfaceExpands in a namespace body.
sStruct declarationExpands in namespace, class or struct.
ePublic enumExpands on an empty line, in a namespace, class, or struct.
aAbstract classExpands on an empty line, in a namespace, class, or struct.
dDelegateExpands on an empty line, in a namespace, class, or struct.
xException class descendant declaration.Expands on an empty line, in a namespace, class, or struct.
tTest fixtureExpands outside a class.
tTest methodExpands in a class on an empty line.
ccCreate constructorExpands in a class on an empty line.

Members and Variables

Template[1]Expansion
V or vVariable (parameter, local, and field)
N or nNew Instance
O or oRead-only Fields
M or mMethods
P or pProperties
R or rRead-only properties
W or wWrite-only properties
A or aAuto-implemented properties
tType Reference
qConstants
cClass

Note

You can find the detailed information on the member declaration templates in the Members Declaration article.

If/Else

TemplateExpansion
ifif statement
ifnif not…
lElse
lfElse if…

Try

TemplateExpansion
tctry/catch
tftry/finally
tcftry/catch/finally

Flow

TemplateExpansion
forFor loop
feFor Each
wWhile loop
dwDo While
swSwitch
seSelect
tneThrow new exception
uUsing statement
bBegin/end block

Note

You can use the following tips:

  • Shift + Space suppresses template expansion.
  • t , f, and n for true , false and null.
  • r , rt , rf , and rn return values.

The full list of templates is available in the code templates configuration options.

Footnotes

  1. Uppercase letters expand to static members.

See Also

Custom Template Creation