CodeRush – Common StringProviders

StringProviders are little bits of dynamic that (Along with TextCommands and Aliases), can be injected into otherwise static Templates in order to increase their usefulness.

Essentially they represent string returning functions, and like string functions they are unrestricted in the logic they can use to construct and return these strings. Examples include, but are not limited to, Environ vars, DateTime, Web services and even data from the file system.

In this post, we’re going to show you a selection of those StringProviders available to you out of the box.

To use any StringProvider in a template, simply add the text “«?MyStringProvider» to your template replacing “MyStringProvider” with the name of the provider you wish to use. If parameters are required, you should add brackets inside the » and place the params inside these.  Thus: “«?MyStringProvider(SomeParam)»

Note: The « and » can be produced by holding down the ALT key and typing either 0171 or 0187 on your numeric keyboard.

Simple StringProviders

This first batch of StringProviders are very simple and emit strings exactly as their names suggest:

StringProvider Outputs
«?Date» The current date in short date format (i.e. 19/11/2010)
«?DateLong» The current date in long date format (i.e. 19 November 2010)
«?DateTimeNow» The current date in formatted as dd/MM/yyyy HH:mm:ss. (19/11/2010 15:25:55)
«?UserName» The full username of the current user. i.e. Alpha-7\Rory.Becker
«?Paste» The contents of the clipboard as a string.

Some StringProviders draw information from the context in which they find themselves in.
These next few StringProviders base their results on the active file.

StringProvider Outputs
«?FileBase» The base name of the active file without path or extension.
«?FileDrive» The drive of the active file (ie ‘C:\’ )
«?FileExtension» The extension of the active file (ie ‘.cs’)
«?FileName» The name of the active file including the path.
«?FilePath» The path of the active file.


Some StringProviders can also take parameters:

StringProvider Parameter Outputs
«?DateTimeNow(Param)» A format String The current date formatted using the passed format
«?FormatFieldName(Param)» The string to format The string formatted as a Field (based on CodeRush settings)
«?FormatLocalName(Param)» The string to format The string formatted as a Local (based on CodeRush settings)
«?FormatParamName(Param)» The string to format The string formatted as a Param (based on CodeRush settings)

This can lead to some interesting combinations. You could use the «?Paste» StringProvider to sensibly feed 3 of the above StringProviders and thus avoid having to ask the user to indicate the  variable in question. Of course the clipboard might not contain anything sensible, but this can be checked for through the use of the “Editor\Clipboard\*” contexts.

The User Guide

In my current copy of CodeRush (The 10.2 RC), I count 90 StringProviders. This number may vary before full release, and there may be some in there which have been provided by 3rd party plugins.  In any case, I think you’ll agree that this should provide more than enough to be going on with.

If you’d like to see a full list of StringProvider provided by your copy of CodeRush, you can do so by using our user guide. (Available via DevExpress\User Guide)


If you Type “String Providers” into the search bar at the top you will be taken to a page which provides a dynamically generated list of all StringProviders currently registered with the DXCore. Each should have an accompanying explanation of the string they’re expected to produce.


Looking through this list, you should soon find yourself very comfortable with the wide array of available StringProviders.

In a future tutorial, we’ll show you just how to create your own StringProvider, use it in a Template and even have it show up in the user guide.

Free DevExpress Products - Get Your Copy Today

The following free DevExpress product offers remain available. Should you have any questions about the free offers below, please submit a ticket via the DevExpress Support Center at your convenience. We'll be happy to follow-up.
No Comments

Please login or register to post comments.