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
… well fire off the following animation to see it in action (the “Keys” tool window shows what I’m pressing on the keyboard):
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:
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:
To get more information on the tools including documentation, links to detailed screencasts / demonstrations, and a history, check out the main page:
» AC’s VS CodeRush/Refactor Tools for SharePoint Developers
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. :)