Back to Devexpress

String Providers

coderushforroslyn-117798-coding-assistance-custom-template-creation-string-providers.md

latest29.0 KB
Original Source

String Providers

  • Jun 05, 2025
  • 17 minutes to read

String Providers are keywords used in templates. To insert a String Provider, right-click the template editor area and select Insert StringProvider… from the context menu.

Note

String Providers are inserted without their signature. If you need to pass one or more parameters, add them (enclosed in parentheses) after the String Provider name manually.

Use the table of content to quickly navigate to the description of any String Provider.

«?ActiveTagName»

Returns the name of the surrounding XAML tag.

«?AddQuotes(string)»

PositionParameterDescription
1StringThe string to add quotes to.

Returns the string (passed as a parameter) with double quotes added to the beginning and end.

«?Date»

Returns the current date in Short Date String format (for example, 12 / 30 / 16).

«?DateLong»

Returns the current date in Long Date String format (for example, Friday, December 30, 2016).

«?DateTimeNow([format_string])»

PositionParameterDescription
1Format String (optional)An optional format string to be passed to the .NET ToString() call.

Returns the DateTime.Now call result in the specified string format.

«?Day([format_string])»

PositionParameterDescription
1Format String (optional)An optional format string to be passed to the .NET ToString() call on the “day” integer.

Returns the day of the month.

«?DayOfWeek»

Returns the name of the weekday.

«?DecInteger(value)»

PositionParameterDescription
1ValueThe integer value to decrement in hexadecimal (for example, 0xFF) or decimal format.

Decrements an integer (passed as a parameter) in hex or decimal format. The output string is the decremented value in the same format as the input.

«?DefaultNamespace»

Returns the default namespace for the active file using the project’s default namespace and the file’s relative location to the project.

«?DefaultProjectNamespace»

Returns the default project namespace for the active project.

«?DoubleInteger(value)»

PositionParameterDescription
1ValueThe integer value to double in hexadecimal (for example, 0xFF) or decimal format.

Doubles the value of an integer (passed as a parameter) in a hex or decimal format. The output string is the doubled value in the same format as the input value.

«?EnumerableType(name)»

PositionParameterDescription
1NameThe name of the object that implements the IEnumerable interface.

Returns the IEnumerable type name of the specified variable.

«?EventNameFromField(field_name)»

PositionParameterDescription
1Field NameThe field name to convert

Converts a field name (passed as a parameter to this String Provider) to an event name.

Note

Naming style options can be configured on the Editor | <Language> | Naming Conventions options page.

«?FileBase»

Returns the name of the active file (without a path to it and without an extension).

«?FileDrive»

Returns the drive letter of the active file (for example, C:\).

«?FileExtension»

Returns the extension of the active file (for example, .cs).

«?FileName»

Returns the name of the active file, including the absolute path to it.

«?FilePath»

Returns the absolute path to the folder containing the active file.

«?FirstCamelCaseWord(text)»

PositionParameterDescription
1TextThe text containing camel-case sequences.

Returns the first camel-case sequence of characters (the first character of the specified string and all lower-case characters that follow) from the specified string parameter.

«?FormatConstantName(constant_name,[is_private],[is_local])»

PositionParameterDescription
1Constant NameThe constant name to format
2Is Private (optional)Pass “true” if the constant is local.
3Is Local (optional)Pass “true” if the constant is private.

Formats the specified identifier (passed as a parameter to this String Provider) so it matches the style specified for constant declarations.

Note

Naming style options can be configured on the Editor | <Language> | Naming Conventions options page.

«?FormatEnumMemberName(enum_member_name)»

PositionParameterDescription
1Enum Member NameThe enum member name to format.

Formats the specified identifier (passed as a parameter to this String Provider) so it matches the style specified for enum members.

Note

Naming style options can be configured on the Editor | <Language> | Naming Conventions options page.

«?FormatEventName(event_name)»

PositionParameterDescription
1Event NameThe event name to format.

Formats the specified identifier (passed as a parameter to this String Provider), so it matches the style specified for event declarations.

Note

Naming style options can be configured on the Editor | <Language> | Naming Conventions options page.

«?FormatFieldName(field_name,[non-public],[is_static])»

PositionParameterDescription
1Field NameThe field name to format.
2Non-Public (optional)Pass “true” if the field has non-public visibility.
3Is Static (optional)Pass “true” if the field is static.

Formats the specified identifier (passed as a parameter to this String Provider), so it matches the style specified for field declarations.

Note

Naming style options can be configured on the Editor | <Language> | Naming Conventions options page.

«?FormatInterfaceName(interface_name)»

PositionParameterDescription
1Interface NameThe interface name to format.

Formats the specified identifier (passed as a parameter to this String Provider), so it matches the style specified for interface declarations.

Note

Naming style options can be configured on the Editor | <Language> | Naming Conventions options page.

«?FormatLocalName(local_variable_name)»

PositionParameterDescription
1Local Variable NameThe local variable name to format.

Formats the specified identifier (passed as a parameter to this String Provider) so it matches the style specified for local variable declarations.

Note

Naming style options can be configured on the Editor | <Language> | Naming Conventions options page.

«?FormatMethodName(method_name)»

PositionParameterDescription
1Method NameThe method name to format.

Formats the specified identifier (passed as a parameter to this String Provider) so it matches the style specified for method declarations.

Note

Naming style options can be configured on the Editor | <Language> | Naming Conventions options page.

«?FormatNamespaceName(namespace_name)»

PositionParameterDescription
1Namespace NameThe namespace name to format.

Formats the specified identifier (passed as a parameter to this String Provider), so it matches the style specified for namespace declarations.

Note

Naming style options can be configured on the Editor | <Language> | Naming Conventions options page.

«?FormatParamName(parameter_name)»

PositionParameterDescription
1Parameter NameThe parameter name to format.

Formats the specified identifier (passed as a parameter to this String Provider) so it matches the style specified for parameter declarations.

Note

Naming style options can be configured on the Editor | <Language> | Naming Conventions options page.

«?FormatPropertyName(property_name)»

PositionParameterDescription
1Property NameThe property name to format.

Formats the specified identifier (passed as a parameter to this String Provider), so it matches the style specified for property declarations.

Note

Naming style options can be configured on the Editor | <Language> | Naming Conventions options page.

«?FormatTypeName(type_name)»

PositionParameterDescription
1Type NameThe type name to format.

Formats the specified identifier (passed as a parameter to this String Provider), so it matches the style specified for type declarations.

Note

Naming style options can be configured on the Editor | <Language> | Naming Conventions options page.

«?FormatTypeParameterName(type_parameter_name)»

PositionParameterDescription
1Type Parameter NameThe type parameter name to format.

Formats the specified identifier (passed as a parameter to this String Provider), so it matches the style specified for type parameter declarations.

Note

Naming style options can be configured on the Editor | <Language> | Naming Conventions options page.

«?GenerateOnPropertyChangedCall(property)»

PositionParameterDescription
1PropertyThe property name.

Returns the corresponding OnPropertyChanged method call for the specified property name. Returns an empty string if the OnPropertyChanged method is missing from the active type.

Note

The class in which this String Provider was invoked should implement the INotifyPropertyChanged interface.

«?Get(variable)»

PositionParameterDescription
1VariableThe name of the variable to get a value for. This should be the same variable name passed to the Set string provider earlier, or if you are working with dynamic templates, it should match the name of the variable on the list created in the Template Name Variables options page.

Returns the value of the specified variable. For more information about using variables in templates, review the Using Variables topic.

«?GetIteratorName(name,type_name)»

PositionParameterDescription
1NameThe name of a collection to iterate through.
2Type NameThe type of the elements to iterate through.

Returns an iterator variable name based on the name of a collection to iterate through.

«?GetPropertySuffix(field_name)»

PositionParameterDescription
1Field NameThe name of the field to check.

Returns property name suffix if the specified field name conflicts with the property name obtained from the PropertyNameFromField String Provider.

«?GetTypeSuffix(name)»

PositionParameterDescription
1Type NameThe name of the type for which to return the type suffix.

Returns the type suffix that should be added right after a numeric literal to specify its type. For instance, “U” for UInt32 (the full literal is “42U”).

«?GetUniqueXamlName(base_name)»

PositionParameterDescription
1Base NameThe string on which to base the generated name. If this string ends with a number, that number will be replaced with a number that makes the name unique.

Returns a unique XAML name identifier based on the specified “Base Name” parameter. If the Base Name ends with a number, that number will be replaced with a number that makes the identifier unique.

«?GetUserFirstName»

Returns “First Name” value from the IDE | User Info options page.

«?GetUserInfo(key)»

PositionParameterDescription
1KeyThe key on the IDE

Returns a value from the IDE | User Info options page.

«?GetUserInitials»

The info is taken from the IDE | User Info options page. The “First Name” and “Middle Name” rows are considered.

«?GetUserLastName»

Returns “Last Name” value from the IDE | User Info options page.

«?GetUserMiddleName»

Returns “First Name” value from the IDE | User Info options page.

«?Hour([format_string])»

PositionParameterDescription
1Format String (optional)An optional format string passed to a ToString() call on the “hour” integer.

Returns the hour for the current time.

«?IncInteger(value)»

PositionParameterDescription
1ValueThe integer value to increment in hexadecimal (for example, 0xFF) or decimal format.

Increments an integer (passed as a parameter) in a hex or decimal format. The output string is the incremented value, in the same format as the input value.

«?InitialCap(text)»

PositionParameterDescription
1TextThe text to initial-cap.

Uppercases the first letter of the string passed as a parameter to this String Provider.

«?InitialLow(text)»

PositionParameterDescription
1TextThe text to change. The first letter of this text will be changed to lower-case, and that result will be returned.

Lowercases the first letter of the string passed as a parameter.

«?InitialValueFromType(name)»

PositionParameterDescription
1NameThe full name of the type (e.g., System.Boolean) to get the initial value for.

Returns an initial value based on a full type name passed to it.

«?InvertBoolean(boolean_value)»

PositionParameterDescription
1Boolean ValueThe Boolean value to invert. One of “true”, “True”, “false”, or “False”.

Returns the logical opposite of the specified Boolean constant passed as a parameter: true becomes false, and False becomes True.

«?LongestSelectedCodeLine»

Returns the length of the longest code line in the active selection, ignoring leading and trailing white space.

Note

A TextView must have focus when invoking this String Provider.

«?LongestSelectedLine»

Returns the length of the longest line in the active selection. Leading and trailing white space is included in the line length calculation.

Note

A TextView must have focus when invoking this String Provider.

«?LowerCase(text)»

PositionParameterDescription
1TextThe text to lowercase.

Lowercases the specified text (passed as a parameter to this String Provider).

«?Member»

Returns the name of the member at the caret (for example, property, method, and so on).

«?Method»

Returns the name of the method at the caret.

«?Minute([format_string])»

PositionParameterDescription
1Format String (optional)An optional format string passed to a ToString() call on the “minute” integer.

Returns the minutes for the current time.

«?Month([format_string])»

PositionParameterDescription
1Format String (optional)An optional format string passed to a ToString() call on the “month” integer.

Returns the current month.

«?Namespace»

Returns the active namespace name.

«?NamespaceFullName»

Returns the full name of the active namespace (for example, DevExpress.CodeRush.Features.CSharp.Strings).

«?NearestLocalOfType(full_name)»

PositionParameterDescription
1Full NameThe full name of the type (for example, System.Boolean).

Returns the name of the nearest local variable of the specified type.

«?NewGuid([format])»

PositionParameterDescription
1Format (optional)The format of the GUID to be generated.

Generates and returns new string GUID. This string provider accepts an optional format string. If a format string is not specified, then the “B” format is used.

«?Paste(remove_semicolon)»

PositionParameterDescription
1Remove SemicolonSet this parameter to true to delete a semicolon in the end of the text.

Returns the text on the clipboard.

«?PasteArrayBaseType»

Returns the base type name of the array on the clipboard.

«?PasteFirstLine»

Returns the first line of the clipboard text.

«?PasteType»

Returns the full type name on the clipboard.

«?PrefixField»

Returns the prefix associated with field variables for the active language based on the “Instance Private Fields” settings.

Note

Naming style options can be configured on the Editor | <Language> | Naming Conventions options page.

«?PrefixLocal»

Returns the prefix associated with local variables for the active language based on the “Local Variables” settings.

Note

Naming style options can be configured on the Editor | <Language> | Naming Conventions options page.

«?PrefixMethod»

Returns the prefix associated with methods for the active language based on the “Methods” settings.

Note

Naming style options can be configured on the Editor | <Language> | Naming Conventions options page.

«?PrefixParam»

Returns the prefix associated with parameters for the active language based on the “Parameters” settings.

Note

Naming style options can be configured on the Editor | <Language> | Naming Conventions options page.

«?PrimitiveDefaultValue(name)»

PositionParameterDescription
1NameThe full name of the type for which the primitive initial value is returned (for example, System.Boolean).

Returns a primitive initial value based on a full type name passed to it.

«?ProjectFileName»

Returns the path to the current project file.

«?ProjectName»

Returns the name of the current project.

«?ProjectRelativeFilePath»

Returns the path (relative to the project file) for the active file.

«?ProjectRelativeFileName»

Returns the file path and name (relative to the project file) for the active file.

«?PropertyNameFromField(field_name)»

PositionParameterDescription
1Field NameThe field name to convert.

Converts a field name (passed as a parameter to this String Provider) to a property name.

Note

Naming style options can be configured on the Editor | <Language> | Naming Conventions options page.

«?PropertyNameFromLocal(local_variable_name)»

PositionParameterDescription
1Local Variable NameThe name of a local variable to convert.

Converts a local name (passed as a parameter to this String Provider) to a property name.

Note

Naming style options can be configured on the Editor | <Language> | Naming Conventions options page.

«?PropertyNameFromParam(parameter_name)»

PositionParameterDescription
1Parameter NameThe parameter name to convert.

Converts a parameter name (passed as a parameter to this String Provider) to a property name.

Note

Naming style options can be configured on the Editor | <Language> | Naming Conventions options page.

«?RemoveQuotes(string)»

PositionParameterDescription
1StringString to remove quotes from.

Returns the string passed as a parameter without double quotes.

«?Repeat(string,length)»

PositionParameterDescription
1StringThe sequence of characters to repeat.
2LengthThe desired length of the assembled string.

Creates a string that repeats the specified sequence up to a specified maximum length.

«?ReturnType»

Returns the active member’s return type, or the name of the active Type, Structure or Interface if the caret is not inside a member.

«?ScopeConstant»

Returns the default scope (private, public, and so on) for constants (configured on the Editor | <Language> | Scope Options options page. Refer to the Scope topic for details).

«?ScopeEvent»

Returns the default scope (private, public, and so on) for events (configured on the Editor | <Language> | Scope Options options page. Refer to the Scope topic for details).

«?ScopeField»

Returns the default scope (private, public, and so on) for fields (configured on the Editor | <Language> | Scope Options options page. Refer to the Scope topic for details).

«?ScopeMethod(is_abstract)»

Returns the default scope (private, public, and so on) for methods (configured on the Editor | <Language> | Scope Options options page. Refer to the Scope topic for details).

PositionParameterDescription
1Is AbstractDefines if a member is abstract and if the scope cannot be private.

Returns default scope (private, public, and so on) for properties (configured on the Editor | <Language> | Scope Options options page. Refer to the Scope topic for details).

«?ScopeNestedType»

Returns the default scope (private, public, and so on) for nested types (configured on the Editor | <Language> | Scope Options options page. Refer to the Scope topic for details).

«?ScopeProperty(is_abstract)»

PositionParameterDescription
1Is AbstractDefines if a member is abstract and if the scope cannot be private.

Returns default scope (private, public, and so on) for properties (configured on the Editor | <Language> | Scope Options options page. Refer to the Scope topic for details).

«?ScopeType»

Returns default scope (private, public, and so on) for types (configured on the Editor | <Language> | Scope Options options page. Refer to the Scope topic for details).

«?Second([format_string])»

PositionParameterDescription
1Format String (optional)An optional format string passed to a ToString() call on the “seconds” integer.

Returns the number of seconds for the current time.

«?Semicolon»

Returns a semicolon if needed.

«?Set(variable_name,value)»

PositionParameterDescription
1Variable NameThe name of the variable to set. This same variable name, when passed to the Get string provider, will return the last string value set to this variable.
2valueThe string to assign to a Variable Name. This value will be returned from the next call to the Get String Provider with the Variable Name passed as a parameter. For more information about using variables in templates, review the Using Variables topic.

Sets a variable to a specified string for later use through the Get String Provider. Returns an empty string.

«?SimpleName(name)»

PositionParameterDescription
1NameThe full simple name of the member.

Returns the simple name based on the full member name passed to it.

«?SimpleStaticTypeName(name)»

PositionParameterDescription
1NameThe full simple type name.

Returns the simple type name based on the full type name passed to it.

«?SimpleTypeName(name)»

PositionParameterDescription
1NameThe full simple type name.

Returns the simple type name based on a full type name passed to it.

«?SolutionFileName»

Returns the full path to the solution file.

«?SolutionName»

Returns the name of the current solution.

«?Substring(text, startIndex, length)»

Calculates a substring from the text passed as a first parameter. Other parameters are starting index and an optional length.

PositionParameterDescription
1TextThe text to calculate the substring from. This parameter is obligatory.
2StartIndexStart index to calculate the substring. This parameter is obligatory.
3LengthLength of the substring. This parameter is optional.

«?SuffixField»

Returns the suffix associated with field variables for the active language based on the “Instance Private Fields” settings.

Note

Naming style options can be configured on the Editor | <Language> | Naming Conventions options page.

«?SuffixLocal»

Returns the suffix associated with local variables for the active language based on the “Local Variables” settings.

Note

Naming style options can be configured on the Editor | <Language> | Naming Conventions options page.

«?SuffixMethod»

Returns the suffix associated with methods for the active language based on the “Methods” settings.

Note

Naming style options can be configured on the Editor | <Language> | Naming Conventions options page.

«?SuffixParam»

Returns the suffix associated with parameters for the active language based on the “Parameters” settings.

Note

Naming style options can be configured on the Editor | <Language> | Naming Conventions options page.

«?TestFramework»

Returns the name of the test framework supported in the active project (for example, NUnit, xUnit, VSUnitTesting).

«?TextCommandBegin»

Returns the start character for a CodeRush Text Command («).

«?TextCommandEnd»

Returns the end character for a CodeRush Text Command (»).

«?Time»

Returns the time in the Short Time String format (for example, 4:24 PM).

«?TimeLong»

Returns the time in the Long Time String format (for example, 4:24:59 PM).

«?Type»

Returns the name of the type under the caret.

«?TypeFullName»

Returns the full name of the active type under the caret.

«?TypeKind»

Returns the keyword for the current type.

«?UpperCase(text)»

PositionParameterDescription
1TextThe text to change.

Uppercases the specified text (passed as a parameter to this String Provider).

«?UserName»

Returns the user name of the logged in user.

«?XmlDocCommentBegin»

Returns XML comment delimiters (///).

«?XMLMultilineDocCommentBegin»

Return XML Multiline Doc Comment Begin delimiter (/**).

«?XMLMultilineDocCommentEnd»

Returns XML Multiline Doc Comment End delimiter (*/).

«?Year([format_string])»

PositionParameterDescription
1Format String (optional)An optional format string passed to a ToString() call on the year integer.

Returns the current year.