CTX - Provides list of items describing current context. This includes file name, containing type name, namespace name, etc. (context)
This could be useful:
In string literals that contain references to the current context, i.e. Logger.LogError("Cannot find action ActionNameDerivedFromContext");
As an alternative to code completion where IntelliSense doesn't work properly - for example, in comments when documenting a member with a long name (see example below).
Before expansion
Expansion options
nguid
Insert new GUID
Scope everywhere
Body
$GUID$
Parameters
GUID - Generates new Globally Unique Identifier (GUID) (guid)
join
Join clause in language integrated query
Scope C# 2.0+ queries
Body
join$NAME$in$COL$on$EXPR1$equals$EXPR2$$END$
Parameters
COL - Suggests variables of the specified type. (variableOfType)
NAME - When exectuted in variable declaration (where variable name should stand), suggests name for the variable. (suggestVariableName)
EXPR1 - no macro
EXPR2 - no macro
END - The caret position after the template is applied.
Before expansion
After expansion
from
Language-Integrated Query
Scope C# 3.0+ expressions, C# 3.0+ queries
Body
from$VAR$in$COLLECTION$$END$
Parameters
COLLECTION - Suggests variables of the specified type. (variableOfType)
VAR - When exectuted in variable declaration (where variable name should stand), suggests name for the variable. (suggestVariableName)
END - The caret position after the template is applied.
INDEX - Suggests non-used name which can be used for an index variable at the evaluation point. (suggestIndexVariable)
LIST - Suggests variables of the specified type. (variableOfType)
TYPE - Suggest type for a new variable declared in the template (suggestVariableType)
ITEM - When exectuted in variable declaration (where variable name should stand), suggests name for the variable. (suggestVariableName)
END - The caret position after the template is applied.
Before expansion
After expansion
The template generates a for loop which iterates over an instance of System.Collections.IList. Includes a customizable statement in the loop body with a variable holding container elements.
After you specify the parameters, the caret is positioned so that you can continue coding the loop body.
INDEX - Suggests non-used name which can be used for an index variable at the evaluation point. (suggestIndexVariable)
ARRAY - Suggests variable which type is array type (arrayVariable)
TYPE - Suggest type for a new variable declared in the template (suggestVariableType)
VAR - When exectuted in variable declaration (where variable name should stand), suggests name for the variable. (suggestVariableName)
END - The caret position after the template is applied.
Before expansion
After expansion
The template generates a for loop for iterating over an array in reverse order. Includes a customizable statement in the loop body with a variable holding container elements.
After you specify the parameters, the caret is positioned so that you can continue coding the loop body.
EXPR - Suggests variables of the specified type. (variableOfType)
Before expansion
After expansion
ReSharper automatically suggests a list of all variables in the current scope and, by default, selects the most recently declared one. The descriptive text string (s = in the example above) is automatically synchronized with the name of the selected variable.
out
Print a string
Scope C# 2.0+ statements
Body
System.Console.Out.WriteLine("$END$");
Parameters
END - The caret position after the template is applied.
Before expansion
After expansion
asrt
Make an assertion
Scope C# 2.0+ statements
Body
System.Diagnostics.Debug.Assert($END$);
Parameters
END - The caret position after the template is applied.
Before expansion
After expansion
This template calls the Debug.Assert method, which is used for debugging purposes. After the template expanded, the caret moves between the parentheses so that you can specify a condition.
The template inserts the Debug.Assert method, which checks a condition and displays a message if the condition is false.
thr
throw new
Scope C# 2.0+ statements
Body
thrownew
Before expansion
After expansion
pci
public const int
Scope C# 2.0+ type members
Body
publicconstint
Before expansion
After expansion
pcs
public const string
Scope C# 2.0+ type members
Body
publicconststring
Before expansion
After expansion
psr
public static readonly
Scope C# 2.0+ type members
Body
publicstaticreadonly
Before expansion
After expansion
prop
Property
Scope C# 2.0+ type members
Body
public$TYPE$$NAME${get;set;}
Parameters
TYPE - no macro
NAME - When exectuted in variable declaration (where variable name should stand), suggests name for the variable. (suggestVariableName)
Before expansion
After expansion
ear
Create an empty array
Scope C# 2.0+ statements
Body
$TYPE$[]$NAME$=new$TYPE$[]{};
Parameters
TYPE - no macro
NAME - When exectuted in variable declaration (where variable name should stand), suggests name for the variable. (suggestVariableName)
Before expansion
After expansion
#if (Imported Visual C# Snippets)
Code snippet for #if
Scope C# 2.0+ except strings
Body
#if $expression$$SELECTION$$END$#endif
Parameters
expression - Evaluates to the specified constant value. (constant)
SELECTION - The text selected by the user before invoking the template.
END - The caret position after the template is applied.
#region (Imported Visual C# Snippets)
Code snippet for #region
Scope C# 2.0+ except strings
Body
#region $name$$SELECTION$$END$#endregion
Parameters
name - Evaluates to the specified constant value. (constant)
SELECTION - The text selected by the user before invoking the template.
END - The caret position after the template is applied.
enum (Imported Visual C# Snippets)
Code snippet for enum
Scope C# 2.0+ type members, C# 2.0+ types and namespaces
Body
enum$name${$END$}
Parameters
name - Evaluates to the specified constant value. (constant)
END - The caret position after the template is applied.
else (Imported Visual C# Snippets)
Code snippet for else statement
Scope C# 2.0+ statements
Body
else{$END$}
Parameters
END - The caret position after the template is applied.
~ (Imported Visual C# Snippets)
Code snippet for destructor
Scope C# 2.0+ type members
Body
~$classname$(){$END$}
Parameters
classname - Evaluates to short name of the most inner containing type. (typeName)
END - The caret position after the template is applied.
ctor (Imported Visual C# Snippets)
Code snippet for constructor
Scope C# 2.0+ type members
Body
public$classname$(){$END$}
Parameters
classname - Evaluates to short name of the most inner containing type. (typeName)
END - The caret position after the template is applied.
cw (Imported Visual C# Snippets)
Code snippet for Console.WriteLine
Scope C# 2.0+ statements
Body
System.Console.WriteLine($END$);
Parameters
END - The caret position after the template is applied.
class (Imported Visual C# Snippets)
Code snippet for class
Scope C# 2.0+ type members, C# 2.0+ types and namespaces
Body
class$name${$END$}
Parameters
name - Evaluates to the specified constant value. (constant)
END - The caret position after the template is applied.
Exception (Imported Visual C# Snippets)
Code snippet for exception
Scope C# 2.0+ type members, C# 2.0+ types and namespaces
Body
[System.Serializable]publicclass$newException$Exception:System.Exception{//// For guidelines regarding the creation of new exception types, see// http://msdn.microsoft.com/library/default.asp?url=/library/en-us/cpgenref/html/cpconerrorraisinghandlingguidelines.asp// and// http://msdn.microsoft.com/library/default.asp?url=/library/en-us/dncscol/html/csharp07192001.asp//public$newException$Exception(){}public$newException$Exception(stringmessage):base(message){}public$newException$Exception(stringmessage,System.Exceptioninner):base(message,inner){}protected$newException$Exception(System.Runtime.Serialization.SerializationInfoinfo,System.Runtime.Serialization.StreamingContextcontext):base(info,context){}}
Parameters
newException - Evaluates to the specified constant value. (constant)
struct (Imported Visual C# Snippets)
Code snippet for struct
Scope C# 2.0+ type members, C# 2.0+ types and namespaces
Body
struct$name${$END$}
Parameters
name - Evaluates to the specified constant value. (constant)
END - The caret position after the template is applied.
type - Evaluates to the specified constant value. (constant)
SystemCollectionsGenericIEnumeratorG - Evaluates to the specified constant value. (constant)
propg (Imported Visual C# Snippets)
Code snippet for an automatically implemented property with a 'get' accessor and a private 'set' accessor
Scope C# 2.0+ type members
Body
public$type$$property${get;privateset;}
Parameters
type - Evaluates to the specified constant value. (constant)
property - When exectuted in variable declaration (where variable name should stand), suggests name for the variable. (suggestVariableName)
Attribute (Imported Visual C# Snippets)
Code snippet for attribute using recommended pattern
Scope C# 2.0+ type members, C# 2.0+ types and namespaces
Body
[System.AttributeUsage(System.AttributeTargets.$target$, Inherited = $inherited$, AllowMultiple = $allowmultiple$)]sealedclass$name$Attribute:System.Attribute{// See the attribute guidelines at // http://go.microsoft.com/fwlink/?LinkId=85236readonlystringpositionalString;// This is a positional argumentpublic$name$Attribute(stringpositionalString){this.positionalString=positionalString;// TODO: Implement code here$SELSTART$thrownewSystem.NotImplementedException();$SELEND$}publicstringPositionalString{get;privateset;}// This is a named argumentpublicintNamedInt{get;set;}}
Parameters
name - Evaluates to the specified constant value. (constant)
target - Evaluates to the specified constant value. (constant)
inherited - Evaluates to the specified constant value. (constant)
allowmultiple - Evaluates to the specified constant value. (constant)
do (Imported Visual C# Snippets)
Code snippet for do...while loop
Scope C# 2.0+ statements
Body
do{$SELECTION$$END$}while($expression$);
Parameters
expression - Suggests variables of the specified type. (variableOfType)
SELECTION - The text selected by the user before invoking the template.
END - The caret position after the template is applied.
checked (Imported Visual C# Snippets)
Code snippet for checked block
Scope C# 2.0+ statements
Body
checked{$END$}
Parameters
END - The caret position after the template is applied.
if (Imported Visual C# Snippets)
Code snippet for if statement
Scope C# 2.0+ statements
Body
if($expression$){$SELECTION$$END$}
Parameters
expression - Suggests variables of the specified type. (variableOfType)
SELECTION - The text selected by the user before invoking the template.
END - The caret position after the template is applied.
lock (Imported Visual C# Snippets)
Code snippet for lock statement
Scope C# 2.0+ statements
Body
lock($expression$){$SELECTION$$END$}
Parameters
expression - Suggests variables of the specified type. (variableOfType)
SELECTION - The text selected by the user before invoking the template.
END - The caret position after the template is applied.
mbox (Imported Visual C# Snippets)
Code snippet for MessageBox.Show
Scope C# 2.0+ statements
Body
System.Windows.Forms.MessageBox.Show("$string$");
Parameters
string - Evaluates to the specified constant value. (constant)
using (Imported Visual C# Snippets)
Code snippet for using statement
Scope C# 2.0+ statements
Body
using($resource$){$SELECTION$$END$}
Parameters
resource - Suggests variables of the specified type. (variableOfType)
SELECTION - The text selected by the user before invoking the template.
END - The caret position after the template is applied.