My CodeRush/Refactor Tools - working with Templates

Join me in exploring AC's VS CodeRush/Refactor Tools for SharePoint Devs. In my series, I introduce the tools and provide an overview in Part 1.

This post is part of a series of articles on my AC’s VS CodeRush/Refactor Tools for SharePoint Devs. The other posts in this series can be found here: AC’s VS CodeRush/Refactor Tools for SharePoint Devs

In Part 1 of this series on these little tools I created for SharePoint developers I gave a bit of an overview of what they are all about and where you can get additional information. In this post I want to spend some time taking a look at some of the templates I think will be used the most.

Before you ask, yes, CodeRush (CR) templates are similar to Visual Studio (VS) snippets, except they have quite a bit more functionality. For example, I can embed functions within CR templates where I can’t do that with snippets. Let’s jump in and see one one of the more commonly used ones (least that I expect).

Creating Feature definition files (feature.xml) files is repetitive. After a few weeks as a SharePoint developer, I expect you’ll be able to do this in your sleep. What do you always have to do? Create a new GUID, give it a title, scope, and mark it’s visibility. There’s new a CR template named fxml (for Feature XML) that once you type it and hit space … well fire off the following animation to see it in action (the “Keys” tool window shows what I’m pressing on the keyboard):

Figure 1: fxml

Figure 1: fxml

Cool? Notice the GUID automatically created. And notice how I’m hitting enter to jump between the different “fields” (indicated with orange boxes).

OK, cool… me like… you like? But wait, there’s more!

Here’s where the power of CR really starts to kick in. What if you had a Feature receiver class in your project? Wouldn’t it be cool if it would automatically fill the ReceiverAssembly & ReceiverClass attributes? Uh-huh… sure would! So, check out the frxml (for Feature Receiver XML) template. Assuming the project is signed and has already been built:

Figure 2: frxml

Figure 2: frxml

Notice how it got the assembly’s strong name (aka: 4-part name)? If the project wasn’t signed and / or built, it would have simply added PublickKeyToken=[REPLACE_THIS] at the end.

You like now? Oh… before I go on, there are a TON of templates… over 45 of them! I created templates for the entire Feature schema, most of the Solution schema, field type definitions and a few others. All are listed, as well as links to screencasts demonstrating each (with a table-of-contents to jump to specific templates) on the main AC’s VS CodeRush/Refactor Tools for SharePoint Devs page linked at the bottom of this post.

Before I go on, let me explain how the templates are named. Each one is created as a mnemonic to make it easier to remember. I fully expect it will take some folks some time to get used to them, but when you think about it, they are quite intuitive. Want to create the contents of a new feature.xml file: fxml. What about a Feature with receivers: frxml. OK, what about an element manifest file: exml. What about adding a site column (element site column) esc, then a new content type ect and a few field references in the content type ectfr. Cool… what about a new manifest.xml solution definition: sxml. And adding assemblies sa with safe control entries sasc as well as a new Feature manifest declaration sfm. Just think about what you’re trying to type and it should be fairly intuitive… or just watch the screencast / read the docs!

As a grand finale, check out the productivity gain once you get used to using these templates. This animation shows me creating a new Feature that contains a Feature receiver, add a new site column definition, and a new content type using the site column:

Figure 3: Part 2

Figure 3: Part 2

There is a much better, and bigger, screencast available on the main page, linked below.

To get more information on the tools including documentation, links to detailed screencasts / demonstrations, and a history, check out the main page:

Let me know what you think! Oh… and I didn’t name this post “part 1 of 5” for some random reason. Over the next four days, I’ll add another post related to these productivity enhancements. :)

This post is part of a series of articles on my AC’s VS CodeRush/Refactor Tools for SharePoint Devs. The other posts in this series can be found here: AC’s VS CodeRush/Refactor Tools for SharePoint Devs
Andrew Connell
Developer & Chief Course Artisan, Voitanos LLC. | Microsoft MVP
Written by Andrew Connell

Andrew Connell is a web & cloud developer with a focus on Microsoft Azure & Microsoft 365. He’s received Microsoft’s MVP award every year since 2005 and has helped thousands of developers through the various courses he’s authored & taught. Andrew’s the founder of Voitanos and is dedicated to helping you be the best Microsoft 365 web & cloud developer. He lives with his wife & two kids in Florida.

Share & Comment