ReSharper 2021.2 Help

List of Template Macros

When you apply code templates, ReSharper 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 ReSharper:

Expression

Description

Details

guessElementType()

Guess element type of collection represented by variable

Analyzes code and guesses type of element of a collection.

Macro parameters:

  • variable- reference to another parameter in the template

suggestIndexVariable()

Suggest name for an index variable

Suggests non-used name which can be used for an index variable at the evaluation point.

    getAlphaNumericFileNameWithoutExtension()

    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

      getAlphaNumericMainFileNameWithoutExtension()

      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

        arrayVariable()

        Suggest an array variable

        Suggests variable which type is array type

          fixedTypeName()

          Insert reference to type

          Evaluates to the selected type name.

          Macro parameters:

          • type- type

          capitalize()

          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:

          • another variable- reference to another parameter in the template

          clipboard()

          Clipboard content

          Evaluates to current textual clipboard content

            complete()

            Execute basic completion

            Show basic code completion list at the point where the variable is evaluated

              completeSmart()

              Execute smart completion

              Show smart code completion list at the point where the variable is evaluated

                completeType()

                Execute type completion

                Show type completion list at the point where the variable is evaluated

                  constant()

                  Constant value

                  Evaluates to the specified constant value.

                  Macro parameters:

                  • Constant value- text string

                  typeMember()

                  Containing type member name

                  Evaluates to short name of the most inner containing type member (e.g. method or property).

                    typeName()

                    Containing type name

                    Evaluates to short name of the most inner containing type.

                      typeRef()

                      Containing type reference

                      Evaluates to reference of the most inner containing type.

                        context()

                        Provides list of items describing current context

                        Provides list of items describing current context. This includes file name, containing type name, namespace name, etc.

                          getCreationTime()

                          Date and time when the file was created in specified format

                          Evaluates file creation date and time

                          Macro parameters:

                          • format- text string

                          getCurrentDate()

                          Current date in specified format

                          Evaluates current date

                          Macro parameters:

                          • format- text string

                          getCurrentTime()

                          Current date and time in specified format

                          Evaluates current date

                          Macro parameters:

                          • format- text string

                          getCurrentNamespace()

                          Containing namespace

                          Evaluates name of the containing namespace

                            decapitalize()

                            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:

                            • another variable- reference to another parameter in the template

                            getDefaultNamespace()

                            Default namespace

                            Gets default namespace for the current project

                              fileDefaultNamespace()

                              Default namespace for current file

                              Gets default namespace for the current file

                                getFileName()

                                Current file name

                                Evaluates current file name

                                  getFileNameWithoutExtension()

                                  Current file name without extension

                                  Evaluates current file name without extension

                                    getFullUserName()

                                    Full user name of the current user

                                    Evaluates full name of the current user

                                      guessExpectedElementType()

                                      Guess element type for expected collection type

                                      Guess element type if a collection type is expected at this point

                                        guessExpectedType()

                                        Guess type expected at this point

                                        Guess type expected at this point

                                          guid()

                                          New GUID

                                          Generates new Globally Unique Identifier (GUID)

                                            lineNumber()

                                            Current line number

                                            Evaluates to number of the line macro is evaluated at.

                                              list()

                                              Comma-delimited list of values

                                              Displays the specified list of values.

                                              Macro parameters:

                                              • Comma-delimited list of values- text string

                                              To add the comma (,) as a value to the list, escape it with the backslash (\).

                                              getOutputName()

                                              Current project output assembly name

                                              Evaluates output assembly name for the current project

                                                parameterOfType()

                                                Suggest parameter of type

                                                Suggests parameters of the specified type.

                                                Macro parameters:

                                                • type- type

                                                getProjectName()

                                                Name of the current project

                                                Evaluates current project name

                                                  getSolutionName()

                                                  Current solution name

                                                  Evaluates current solution name

                                                    spacestounderstrokes()

                                                    Value of another variable, where spaces will be replaced with '_'

                                                    Changes spaces to '_' (i.e. "do something useful" into "do_something_useful"

                                                    Macro parameters:

                                                    • another variable- reference to another parameter in the template

                                                    enumerableVariable()

                                                    Suggest enumerable variable

                                                    Suggests visible variable that can be enumerated (that is, used in foreach loop as collection)

                                                      suggestVariableName()

                                                      Suggest name for a variable

                                                      When executed in variable declaration (where variable name should stand), suggests name for the variable.

                                                        variableOfType()

                                                        Suggest variable of type

                                                        Suggests variables of the specified type.

                                                        Macro parameters:

                                                        • type- type

                                                        suggestVariableType()

                                                        Suggest type for a new variable

                                                        Suggest type for a new variable declared in the template

                                                          getUpperCaseAlphaNumericFileName()

                                                          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

                                                            getUserName()

                                                            Short name of the current user

                                                            Evaluates current user name

                                                              dependencyPropertyType()

                                                              DependencyProperty type

                                                              Evaluates to dependency property type specific to current framework

                                                                fullTagName()

                                                                Full tag name

                                                                Inserts full name of containing tag

                                                                  suggestXmlAttributeNameByTag()

                                                                  Suggests XML attribute name by tag

                                                                  Suggests XML attribute name used in the same tags in current document

                                                                    suggestAttributeName()

                                                                    Suggests XML attribute name

                                                                    Suggests XML attribute name used in current document

                                                                      suggestXmlTagName()

                                                                      Suggests XML tag name

                                                                      Suggests XML tag name used in current document

                                                                        tagName()

                                                                        Tag name

                                                                        Inserts name of containing tag without namespace

                                                                          tagNamespace()

                                                                          Tag namespace

                                                                          Inserts namespace of containing tag

                                                                            castToLeftSideType()

                                                                            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.

                                                                              fileheader()

                                                                              File header

                                                                              Inserts the file header specified in the ReSharper options.

                                                                                suggestAttributeNameByTag()

                                                                                Suggests attribute name by tag

                                                                                Suggests attribute name used in the same tags in current document

                                                                                  suggestAttributeValue()

                                                                                  Suggest attribute value

                                                                                  Suggest attribute value for current html tag attribute

                                                                                    suggestTagName()

                                                                                    Suggest tag name

                                                                                    Suggest tag name used in current document

                                                                                      AspMasterpageContentGenerator()

                                                                                      ASP.NET Masterpage content generator

                                                                                      Generate content for masterpage content placeholders at the point where the variable is evaluated

                                                                                        AspMvcAction()

                                                                                        ASP.NET MVC Action

                                                                                        Show completion list with available ASP.NET MVC Actions at the point where the variable is evaluated

                                                                                          AspMvcController()

                                                                                          ASP.NET MVC Controller

                                                                                          Show completion list with available ASP.NET MVC Controllers at the point where the variable is evaluated

                                                                                            runAtServer()

                                                                                            Insert runat="server" if server-side tag selected

                                                                                            Insert runat="server" if server-side tag selected

                                                                                              substituteUnrealMacro()

                                                                                              Substitute Unreal template macros

                                                                                              Substitute Unreal template macros

                                                                                                constTypeName()

                                                                                                Containing type name with const

                                                                                                Evaluates to the short name of the most inner containing type with a const specifier.

                                                                                                  cppExpandableTemplateNewline()

                                                                                                  Newline in the documentation and enum-to-string templates

                                                                                                  Evaluates to a newline in the documentation and enum-to-string templates

                                                                                                    cppFunctionParameterList()

                                                                                                    Containing function parameter list

                                                                                                    Evaluates to a comma-separated list of the parameter names of the containing function.

                                                                                                      cppEnumToStringEnumerator()

                                                                                                      Enum to string: enumerator name

                                                                                                      Duplicates the containing template line for each enumerator and evaluates to the name of the enumerator.

                                                                                                        cppEnumToStringEnumeratorName()

                                                                                                        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.

                                                                                                          cppEnumToStringEnum()

                                                                                                          Enum to string: enum name

                                                                                                          The name of the enum that the action is invoked on.

                                                                                                            cppFileheader()

                                                                                                            File header

                                                                                                            Inserts the file header specified in the ReSharper options.

                                                                                                              cppFunctionParameter()

                                                                                                              Documentation: function parameter type with name

                                                                                                              Duplicates the containing template line for each function parameter and evaluates to the parameter type with name

                                                                                                                cppFunctionParameterName()

                                                                                                                Documentation: function parameter name

                                                                                                                Duplicates the containing template line for each function parameter and evaluates to the parameter name

                                                                                                                  cppFunctionParameterType()

                                                                                                                  Documentation: function parameter type

                                                                                                                  Duplicates the containing template line for each function parameter and evaluates to the parameter type

                                                                                                                    cppFunctionReturnValue()

                                                                                                                    Documentation: function return value

                                                                                                                    Keeps the containing template line only if the function return type is non-void

                                                                                                                      cppTemplateParameterName()

                                                                                                                      Documentation: template parameter name

                                                                                                                      Duplicates the containing template line for each template parameter and evaluates to the template parameter name

                                                                                                                        cppMacroParameterName()

                                                                                                                        Documentation: macro parameter name

                                                                                                                        Duplicates the containing template line for each macro parameter and evaluates to the macro parameter name

                                                                                                                          cppFunctionReturnType()

                                                                                                                          Documentation: function return type

                                                                                                                          Evaluates to the function return type

                                                                                                                            cppEntityShortName()

                                                                                                                            Documentation: entity short name

                                                                                                                            Evaluates to the short name of the entity that is being documented

                                                                                                                              cppEntityQualifiedName()

                                                                                                                              Documentation: entity qualified name

                                                                                                                              Evaluates to the qualified name of the entity that is being documented

                                                                                                                                cppPchIncludeDirective()

                                                                                                                                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.

                                                                                                                                  Last modified: 21 October 2021