List of template macros
When you apply code templates, JetBrains Rider initializes template parameters with some values. To calculate these values, it uses template macros, which can retrieve a lot of useful data based on the surrounding context, For instance, current filename, current solution name, containing namespace, clipboard content, and so on. Even more, macros can invoke code completion actions, guess and suggest types, variables, tags, and more.
Here is the full list of template macros provided by JetBrains Rider:
Expression | Description | Details |
---|---|---|
| Guess element type of collection represented by variable | Analyzes code and guesses type of element of a collection. Macro parameters:
|
| Suggest name for an index variable | Suggests non-used name which can be used for an index variable at the evaluation point. |
| Current file name without extension with all non-alphanumeric replaced with underscores | Evaluates current file name without extension with all non-alphanumeric replaced with underscores |
| Name of the primary file without extension with all non-alphanumeric replaced with underscores | Evaluates primary file name without extension with all non-alphanumeric replaced with underscores |
| Suggest an array variable | Suggests variable which type is array type |
| Insert reference to type | Evaluates to the selected type name. Macro parameters:
|
| Value of another variable with the first letter in upper case | Capitalizes string value (i.e. changes case of the first letter to upper) Macro parameters:
|
| Clipboard content | Evaluates to current textual clipboard content |
| Execute basic completion | Show basic code completion list at the point where the variable is evaluated |
| Execute smart completion | Show smart code completion list at the point where the variable is evaluated |
| Execute type completion | Show type completion list at the point where the variable is evaluated |
| Constant value | Evaluates to the specified constant value. Macro parameters:
|
| Containing type member name | Evaluates to short name of the most inner containing type member (e.g. method or property). |
| Containing type name | Evaluates to short name of the most inner containing type. |
| Containing type reference | Evaluates to reference of the most inner containing type. |
| Provides list of items describing current context | Provides list of items describing current context. This includes file name, containing type name, namespace name, etc. |
| Date and time when the file was created in specified format | Evaluates file creation date and time Macro parameters:
|
| Current date in specified format | Evaluates current date Macro parameters:
|
| Current date and time in specified format | Evaluates current date Macro parameters:
|
| Containing namespace | Evaluates name of the containing namespace |
| Value of another variable with the first character in lower case | Decapitalizes string value (i.e. changes case of the first letter to lower) Macro parameters:
|
| Default namespace | Gets default namespace for the current project |
| Default namespace for current file | Gets default namespace for the current file |
| Current file name | Evaluates current file name |
| Current file name without extension | Evaluates current file name without extension |
| Full user name of the current user | Evaluates full name of the current user |
| Guess element type for expected collection type | Guess element type if a collection type is expected at this point |
| Guess type expected at this point | Guess type expected at this point |
| New GUID | Generates new Globally Unique Identifier (GUID) |
| Current line number | Evaluates to number of the line macro is evaluated at. |
| Comma-delimited list of values | Displays the specified list of values. Macro parameters:
To add the comma ( |
| Current project output assembly name | Evaluates output assembly name for the current project |
| Suggest parameter of type | Suggests parameters of the specified type. Macro parameters:
|
| Name of the current project | Evaluates current project name |
| Current solution name | Evaluates current solution name |
| Value of another variable, where spaces will be replaced with '_' | Changes spaces to '_' (i.e. "do something useful" into "do_something_useful" Macro parameters:
|
| Suggest enumerable variable | Suggests visible variable that can be enumerated (that is, used in foreach loop as collection) |
| Suggest name for a variable | When executed in variable declaration (where variable name should stand), suggests name for the variable. |
| Suggest variable of type | Suggests variables of the specified type. Macro parameters:
|
| Suggest type for a new variable | Suggest type for a new variable declared in the template |
| Current file name in upper case with all non-alphanumeric replaced with underscores | Evaluates current file name in upper case with all non-alphanumeric replaced with underscores |
| Short name of the current user | Evaluates current user name |
| DependencyProperty type | Evaluates to dependency property type specific to current framework |
| Full tag name | Inserts full name of containing tag |
| Suggests XML attribute name by tag | Suggests XML attribute name used in the same tags in current document |
| Suggests XML attribute name | Suggests XML attribute name used in current document |
| Suggests XML tag name | Suggests XML tag name used in current document |
| Tag name | Inserts name of containing tag without namespace |
| Tag namespace | Inserts namespace of containing tag |
| Cast to the required type (if the cast is necessary) | Inserts (if required) cast to the type which is expected at the left side of assignment expression. |
| File header | Inserts the file header specified in the ReSharper options. |
| Suggests attribute name by tag | Suggests attribute name used in the same tags in current document |
| Suggest attribute value | Suggest attribute value for current html tag attribute |
| Suggest tag name | Suggest tag name used in current document |
| ASP.NET Masterpage content generator | Generate content for masterpage content placeholders at the point where the variable is evaluated |
| ASP.NET MVC Action | Show completion list with available ASP.NET MVC Actions at the point where the variable is evaluated |
| ASP.NET MVC Controller | Show completion list with available ASP.NET MVC Controllers at the point where the variable is evaluated |
| Insert runat="server" if server-side tag selected | Insert runat="server" if server-side tag selected |
| Substitute Unreal template macros | Substitute Unreal template macros |
| Containing type name with const | Evaluates to the short name of the most inner containing type with a const specifier. |
| Newline in the documentation and enum-to-string templates | Evaluates to a newline in the documentation and enum-to-string templates |
| Containing function parameter list | Evaluates to a comma-separated list of the parameter names of the containing function. |
| Enum to string: enumerator name | Duplicates the containing template line for each enumerator and evaluates to the name of the enumerator. |
| Enum to string: enumerator name as a string | Duplicates the containing template line for each enumerator and evaluates to a string with the name of the enumerator. |
| Enum to string: enum name | The name of the enum that the action is invoked on. |
| File header | Inserts the file header specified in the ReSharper options. |
| Documentation: function parameter type with name | Duplicates the containing template line for each function parameter and evaluates to the parameter type with name |
| Documentation: function parameter name | Duplicates the containing template line for each function parameter and evaluates to the parameter name |
| Documentation: function parameter type | Duplicates the containing template line for each function parameter and evaluates to the parameter type |
| Documentation: function return value | Keeps the containing template line only if the function return type is non-void |
| Documentation: template parameter name | Duplicates the containing template line for each template parameter and evaluates to the template parameter name |
| Documentation: macro parameter name | Duplicates the containing template line for each macro parameter and evaluates to the macro parameter name |
| Documentation: function return type | Evaluates to the function return type |
| Documentation: entity short name | Evaluates to the short name of the entity that is being documented |
| Documentation: entity qualified name | Evaluates to the qualified name of the entity that is being documented |
| Precompiled header file include directive | Evaluates to an include directive for the precompiled header file or to an empty string if the project does not use precompiled headers. |