Archive for the 'ReSharper Tip of the Day' Category


Visual Studio 2010 RC + ReSharper 5.0 + Xunitcontrib all in harmony….finally. 2

madmen_icon

Working on the bleeding edge is painful. Very painful at times. Throwing away our Team City builds because TFS 2010 didn’t support it really hurt. It was a big woops that I regret.

Moving to Visual Studio 2010 Beta was painful too. Visual Studio worked fine, but no ReSharper made it painful. Even in the early days, ReSharper was not stable in 2010, but after a few months, things look good now. ReSharper and VS 2010 are playing nice together.

There is one last pain point. No Xunit.net test runner. Xunitcontrib provides a ReSharper 5.0 build, but I was never able to get it to work…until now. Previously I was getting the same problem seen by others.

The plugin xunit could not be loaded from "C:\program files(x86)\jetBrains\resharper\v5.0\bin\plugins\xunit.dll" or one of its dependencies.  Operation is not supported.  (Exception from HRRESULT: 0×801311515)

I tried the best I could to right-click | Properties | Unblock all the files in the plug-in, but the “Unblock” never worked. I would get the same error. Going back into the properties dialog, the unblock would appear again. It looked like the unblock wasn’t sticking.

After a quick Google search, I found an alternative way to unblock files. Copy the files to a FAT 32 and back. The block is stripped. Sweet! My USB key is FAT 32, and after a quick copy and back. No more errors! ReSharper sees and runs my Xunit.net tests.

Just a quick overview of how I installed the plug-in:

  1. Close Visual Studio.
  2. Copy the contents of the ExternalAnnotations to:
    C:\Program Files (x86)\JetBrains\ReSharper\v5.0\Bin\ExternalAnnotations
  3. Create a folder:
    C:\Program Files (x86)\JetBrains\ReSharper\v5.0\Bin\plugins\xunitcontrib.runner.resharper.5.0
  4. Copy everything else to the USB key.
  5. Copy it to the folder I just created in step #3.
  6. Open Visual Studio and run all my tests.

ReSharper Tip of the Day: Peek at opening brace 1

It has been far to long since the last R#TOTD, so to ease back in, I thought we’d take it slow with this one.

If you’re unfortunate enough to have your methods grow beyond what can fit on a screen, or just happen to have the method scrolled off the top of the screen, you can identify those closing braces with ease. When ReSharper goes to match the opening brace for the current closing brace at the cursor, a pop up with a tooltip appears if that brace happens to be out of view. It is very handy in finding closing namespace and class braces.

image

It gets even better in RubyMine with syntax highlighting and a semi-permanent window (i.e. it will stay visible while you scroll). Even though I’m not a Ruby developer by trade, I still use RubyMine for editing all my JavaScript files. The intellisense is great and you get ReSharper-like context refactorings in JavaScript files.

image

One Click Lorem Ipsum 0

I’m working on layout of new HTML pages and have been adding the Lorem Ipsum filler time and time again. At first I just get a browser window with it open, copy and pasted it whenever I needed, but in keeping the desktop clean of clutter, the browser window was often closed, causing me to search for it, select it, copy, etc. So here’s how to save you time:

  1. Create a toolbox tab for common text.
  2. Select Lorem Ipsum from a file in Visual Studio.
  3. Drag the text to the toolbar.
  4. Done.

Now when you want to inject the lorem ipsum into the text, just click it on the toolbox item.

Even better, for the ReSharper users, make “lorem” a live template for the entire text. Then you just type “lorem” + tab and you get the entire passage.

ReSharper Tip of the Day: Put into ‘using’ construct. 0

There has been some debate if you need every IDisposable should be disposed. From the documentation IDisposable is used to clean up any unmanaged resource.

Use the Dispose method of this interface to explicitly release unmanaged resources in conjunction with the garbage collector.

OK. That’s fine. I totally agree with that until I see DataTable is derived from a class, MarshallByValueComponent, that implements IDisposable. Does that mean DataTable has unmanaged resources? Any way, on to the tip.

ReSharper notices when an object is created that implements IDisposable and it can automatically wrap the usage in a using block. Say you have the following code:

…and want to put it in a using block. Trusty ALT+Enter steps in a gives you the following options:

It is creates a nice using block around the object and all of its usages.

What would really be nice is we could create a warning when we see ourselves using an IDisposible without calling Dispose. That might be more difficult than finding one outside of a using. We could be calling Dispose in a try/finally or somewhere else.

ReSharper tip of the Day: Move Code Left and Right 2

Josh showed us how to slap around our code with CTRL+ALT+SHIFT+UP|DOWN. We can now smack around our markup a little further. In addition to the four fingered up and down bully job, we and take an attribute left or right in the pecking order of the opening tag.

CTRL+SHIFT+ALT+LEFT|RIGHT (right in this case) bumps the attribute over.

If you prefer a more vertical representation of the attributes like the following, the command still works, but less intuitive since left and right actually move it up and down, and up and down move the entire tag up and down.

<CheckBox
     Margin="0,0,0,0"
     Unchecked="DoUnchecked"
     Checked="DoChecked">
     Some Text
</CheckBox>

One last thing to note is you do not need to select the entire attribute. Having the cursor in the attribute you wish to move is enough.

ReSharper Tip of the Day: Agent Smith and Agent Johnson 0

On the advice of a super bright coworker, I installed the Agent Smith and Agent Johnson plugins for R#. Now I’m getting all kinds of new advice and context actions.

ReSharper Tip of the Day:More Reminders 0

I’ve stalled with providing tips for a while. My development at work will pickup and I will soon lots of new tips. As we work into using C# 3.0 I am sure ReSharper will continue to impress. For today though, we have a simple reminder.

Alt+Page Up|Page Down goes to the next ReSharper gutter item.

This just saved me a ton of time. We are currently converting some .Net 2.0 code to target .Net 3.5. In so doing I am going to make use of the new language features. Our domain objects are classes with series of classic properties.

    private string fooberry;
    public string Fooberry{
        get{ return fooberry; }
        set { fooberry = value; }
    }

To convert these to automatic properties I could have copy and pasted {get;set;} after each property name and deleted the rest, but R# made it much easier. Alt+Page Down took me to the next suggest which was to convert to automatic properties. Alt + Enter opened the context window with the first action being convert to auto property. Pressing Enter one last time had it fixed.

    public string Fooberry{ get;set;  }

What made it so effective was I was able to hold down Alt the entire time and press Page Down, Enter, Enter, Page Down, Enter, Enter,etc. until my properties in that file were all changed. Total time to convert 20 properties…10 seconds. Try that with copy and paste. I bet it is a bit higher.

ReSharper Tip of the Day: Reminder, Keyboard Short-cuts Work in Other File Types 0

Just a quick reminder, most keyboard short-cuts work in other files types besides source code. In XML and HTML you can:

  • Ctrl + Shift + / to toggle comments
  • Ctrl + w to expand selection
  • Ctrl + Alt + Shift + Up|Down to move elements up or down.

ReSharper Tip of the Day: Add UsingTask 0

While working in an MSBuild file I notice ReSharper will help you out with using new tasks. If you use one it doesn’t know, it’ll offer to add its UsingTask statement to reference it.

It’ll throw this in at the top of the document.

<UsingTask TaskName="Fooberry" AssemblyName=""/>>

ReSharper 4.1 Released 0

JetBrains released ReSharper 4.1. Read the release notes at JetBrains.

Next Page »