Monday, January 28, 2013

ReSharper Shortcuts Every Sitecore Developer Must Know

If you support a Sitecore installation, you need to be on very comfortable terms with a decompiler. There are several reasons why:

  • Sitecore has a very rich configuration surface, and it's good to be able to see what a setting does before you change it
  • Things go wrong, and it's helpful to be able to figure out why.
  • Sitecore code provides models for how to do things, both on the back-end, and in the client
So you need to be able to look at the code, but which tool should you use? I recommend ReSharper, for the ease with which it lets you navigate the Sitecore API and your solution. Here are my favorite navigation tricks:

Go to type (Control-T)

Control-T is the soul of ReSharper. With a couple of keystrokes, you can go to any class in your solution. Add to this nice bells and whistles like camel case interpretation (type "pfu" to jump to a class named PrintFormatUtility) and namespace interpretation (have a YourCompany.Library and a YourCompany.Web version of PrintFormatUtilty? Type "web pfu" or "li pfu" to disambiguate). In short, ReSharper lets you navigate your solution at the speed of thought.

These features become all the more powerful when applied to an external library you are supporting. I discovered this a while back while doing research for a talk on Clones. Control-T "Sitecore clones" gave me a quick view of all classes that have "Clone" in the name:



Go to symbol (Alt-Shift-T)

Go to symbol does for properties and method names what Control-T does for classes, and the tool has the nice feature that you can switch from the one to the other without losing what is in your textbox. Here are some of the properties named Database in the Sitecore API, all a single click away.


Go to definition (F12)

F12 ships with Visual Studio, but with ReSharper, this will take you from a reference in your project to the implementation in a referenced library, so a reference to Sitecore.Data.Items.Item will take you to the implementation.


Go to usages (Control-Alt-Shift-F12)

Go to usages provides a breakdown of all uses of a class or member both in the library DLLs or in your solution. This one has a slightly more complex interface than the other commands, to allow you to fine tune your search, limiting it, for example, to library methods or your solution code:

And here is the output:

Go to base class/implementation (Alt-Home/Alt-End)

These two may be my favorite of the lot. They make it very easy to traverse interfaces and implementations, both at the class and member level. And they are especially helpful for Pipeline processors, allowing you to see all implementing Pipeline processors, whether they be in Sitecore's solution or yours. Here are all the implementations of the HttpRequestPipeline:



Go to member (Alt-\)

Finally, once you go to these library classes, it's handy to have Control-\ to jump to any method withing the class, and you can use "ctor" to jump to the constructor.

No comments:

Post a Comment