Merging CodeRush Templates (via Export and Import)

When a new version of CodeRush is released, it’s quite often the case that there are new templates included with it.

So why when you’ve completed the install, are these templates not always immediately available?

Well put simply, it’s because we don’t want to damage or break any Template customizations that you might have created yourself.

As you are no doubt aware by now, CodeRush is one of the most configurable products on the market. In this spirit, we allow you to add your own Templates or even customise the ones we offer you out of the box. If we were to overwrite these changes each time we installed, we’d upset people pretty quickly.

Since we don’t like to upset people, we choose instead to not overwrite your templates with our own stuff unless you ask us to.

This post is designed to show you how to merge your own custom Templates, with any new ones we might be shipping in a new release.

Step 0 – Always work within a ‘Custom’ folder

Yes there’s a step zero. This isn’t so much a step, rather more of a mind-set for when you’re creating templates of your own. We don’t force you to create templates in any particular way, but we do suggest that when you create new templates, that you do so inside of a new top level folder called ‘Custom’. By placing your Templates in this folder you are creating a single parent for all of your templates which will greatly ease the management of them in situations like merging.

Step 1 - Export your custom TemplatesTemplateContextMenu

  • Open up the Templates options page (Ctrl+Shift+Alt+OEditor\Templates)
  • Right-click the Custom folder (The one you always put your custom templates in) and choose Export Folder. Save the resultant file somewhere safe.
  • Repeat for each language where you have created Templates of your own.

Step 2  - Force CodeRush to rebuild your templates from defaults

  • Choose DevExpress\About
  • Click Settings
  • Dig into the Editor\Templates folder.
  • Delete (or move if you’re feeling more cautious) the files in this folder.
  • Switch back to VS
  • Return to the Templates options page again
    • Note: All of the templates will have been rebuilt from (new) defaults (without your custom templates)

Step 3 – Reimport your Custom Templates

  • Select in turn each language for which you exported a file in step 1.
    • Right-click the template tree and pick Import Templates
    • Select the previously exported file which pertains to your currently selected language.
    • Click Ok and note how the Custom folder returns to the template tree.
  • Repeat for each language

You have now merged the new templates with your own customizations, and are done.

You should be able to see your own custom templates, and any new ones shipped with the most recent version of CodeRush.

4 comment(s)
SimonMartin

Ahh, I'd wondered what had happened to a customisation I'd made to a unit test template.

Is there any way to automate the above process, that's a lot of faffing about in order to keep my templates. I would have thought that the vast majority of people would want to keep their customisations between versions so it ought to be more streamlined than this.

3 December, 2010
Rory Becker - DevExpress

"Automate the above". I assume you mean, backup "custom", rebuild everything else and import custom again.

If you mean exactly this, then I guess a plugin could be written, but there are a lot of places where it could go wrong or be used out of context.

- What if someone were to use the tool without having first ensured their customizations are placed under "custom"?

- What if they have additional customizations to our templates (Like yourself) ?

That said if you think there is a specific process which might ease this process, feel free to suggest it in our Support Center ( http://www.devexpress.com/sc/ ). We're always happy to look at improving our UX :)

As for functionality beyond this: it's worth remembering that this procedure is really targeted at the basic template builder. There are also those that customize our templates.

Any changes that they make would not be saved by this procedure, and these should be backed up or moved to the custom folder before starting.

Importing these back is also more complicated, since you'll have to appreciate where they should be restored to.

3 December, 2010
Rory Becker - DevExpress

"I'd wondered what had happened to a customisation I'd made to a unit test template"

I should reiterate... You have to perform this procedure manually in order to have any changes happen. So your unit test template shouldn't have disappeared / been damaged unless you chose to delete the files without first backing them up.

3 December, 2010
SimonMartin

Yeah, the "custom" area should be retained between versions, the new templates etc should be installed and everything else upgraded - but anything I've done to modify / personalise the product should brought along (as far as possible and then a note to warn me if something couldn't be migrated).

I've seen a few posts, from yourself and others, that recommend creating a "Custom" folder, so would have thought that it would be reasonable to assume many people would be following that advice. However why not have a "Custom" folder created as part of the install and tell people to create their customisations in there, so you're guiding them into 'best practices', of course they'd be free to create whatever makes sense to them, but I would have thought most people will simply go with what's provided. Certainly, if it's made clear that any customisations made in this area will be preserved, I'd argue that 99% of people would simply stick with the "Custom" folder approach.

The template I customised was for unit testing, I wanted [methodname]_[conditionOfTest]_[Results]. I customised the built in template on advice, but it would be better (to my mind) to have my customised template in "Custom" overriding the pre-packaged template (which I think is the principle of open for extension and closed for modification).

4 December, 2010

Please login or register to post comments.