Nov
13
2008
0

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

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.

Written by mark in: ReSharper Tip of the Day | Tags: ,
Oct
08
2008
2

ReSharper tip of the Day: Move Code Left and Right

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.

Written by mark in: ReSharper Tip of the Day | Tags: , ,
Oct
06
2008
0

ReSharper Tip of the Day: Agent Smith and Agent Johnson

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.

Written by mark in: ReSharper Tip of the Day | Tags: ,
Sep
25
2008
0

ReSharper Tip of the Day:More Reminders

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.

Written by mark in: ReSharper Tip of the Day | Tags:
Sep
19
2008
0

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

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.
Written by mark in: ReSharper Tip of the Day | Tags:
Sep
08
2008
0

ReSharper Tip of the Day: Add UsingTask

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=""/>>
Sep
03
2008
0

ReSharper 4.1 Released

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

Written by mark in: ReSharper Tip of the Day | Tags:
Sep
03
2008
0

ReSharper Tip of the Day: Refactor This

In a recent post Oleg Stepanov pointed out the mother of all refactoring shortcuts. At any point, you can press Ctrl + Shift + R to see all possible refactorings available under your current context.

What I’ve lacked lately in content, I can make up in screenshots. 

As a side note, this is a the first post written with Google Chrome. So far I really like it. The one thing I’ve found that is slightly odd is that backspace will take me out of my text area and an additional backspace will go back in the browsing history.

Written by mark in: ReSharper Tip of the Day | Tags: , ,
Sep
02
2008
0

ReSharper Tip of the Day: Find Implementers

I realize I haven’t posted a new tip in a while. Maybe the day to day drudgery is leaving me temporarily uninspired. To counteract that, I’ve dug up an old tip I’ve sent out a while ago to my coworkers. 

If want to find which classes extend your class or implement your interface that currently has focus, press Ctrl + End.

This is really handy to flip between the fakes and real classes during testing. When down in the guts of methods, don’t forget that Ctrl + [ will take you back to the enclosing block. 

Sorry about the smudgy obfuscation and oversized image.  Hopefully we’ll have some fresh tips soon.

Written by mark in: ReSharper Tip of the Day | Tags:
Aug
19
2008
0

ReSharper Tip of the Day: Refactor This

The people at JetBrains have their ear to the ground again. After complaining about how introducing a variable via a keyboard combination wasn’t very discoverable, JetBrains came through again with pointing out Ctrl+Shift+R will point out all refactoring available in the current context.

Written by mark in: ReSharper Tip of the Day, Uncategorized | Tags:

Powered by WordPress | Kredit | TheBuckmaker