Archive for June, 2006

What does ReSharper really add to Visual Studio refactorings?

Monday, June 26th, 2006

Ok, ReSharper has all these productivity features, but what does it really add to Visual Studio, you ask? As far as refactorings go, ReSharper not only provides more of them than Visual Studio does, but also improves existing ones. This developer’s blog post explains in detail how the task of Encapsulating fields as properties is definitely more convenient with ReSharper than without.

Also, another EAP build is out, featuring noticeable improvements in performance. Catch this link from Gabriel Lozano-Morán - The .NET Aficionado: ReSharper 2.0.253 available

For the latest ReSharper builds and discussions, visit ReSharper Forums any time.

Technorati tags: , , ,

ReSharper 2.0 help available online

Friday, June 23rd, 2006

Some of you will find it easier to read ReSharper help online instead of loading it in Visual Studio together with all the MSDN content ;)

And by the way, on the Docs and Demos page you can also find the Default Keymap, as well as ReSharper overview which contains all the major features of the 2.0 release.

Technorati tags:

dotTrace Profiler 2.0 further improves performance profiling

Monday, June 19th, 2006

First, just a few opening words for our first post about dotTrace Profiler. The currently released dotTrace Profiler (Version 1.1.2) offers convenient and robust performance profiling of .NET Framework 1.1 and 2.0 applications, including ASP.NET applications. What is more interesting, though, is that dotTrace 2.0 is in the works and it’s going to include memory profiling, snapshot comparisons, integration with Visual Studio, and many other cool features. Tune in to our .NET Tools blog to keep up-to-date with its latest developments! You are also welcome to visit the dotTrace Early Access Program for a working preview of version 2.0.

While the major feature added in dotTrace 2.0 is memory profiling, we haven’t abandoned improving the performance part. Here we dip into one of the new features added in this area: collapsing filtered calls. In general, this feature helps you quickly estimate how much time was spent on complex call trees.

For example, let’s take a look at a CPU snapshot from dotTrace which displays profiling data for the code sorting of an ArrayList.

Click this thumbnail for the full dotTrace screenshot

It clearly shows that a single call to ArrayList.Sort method generates a pretty complex call tree (according to QuickSort algorithm) at the points where our comparer is called. So, we see a long list of Compare method calls (click the image to open the full screenshot). The problem here is that we would like to know how much time in total the comparison took (or just sum up time for all of the calls to the Compare method).

As it stands now, in dotTrace 1.x you can open the call in a separate tab, then go to Plain View and see the statistics for the Compare method.

Well, with dotTrace 2.0 things get much simpler. See the small icon The icon that collapses filtered calls at the line for Sort method call (the highlighted line on the screenshot above)? It appears for topmost filtered nodes and is used to collapse all filtered calls underneath it into a single node. If you click the icon on the snapshot, the view is transformed into the following:

Filtered calls are now collapsed

Now the entire tree of underlying dynamics of QuickSort has been transformed into a single node under which all calls to the Compare method are placed. As a result, it’s is now much easier to understand how much time was spent on comparing elements.

Technorati tags: , ,

Quick-Fixes help generate switch blocks

Wednesday, June 14th, 2006

This post is just a simple tip that barely begins to touch on the added convenience of ReSharper’s on-the-fly code analysis and the usefulness of Quick-Fixes.

The following example was lifted off ReSharper Early Access Program newsgroup where users can discuss their experience with the latest builds of ReSharper. By the way, we’re about to release a bugfix update, so don’t change the channel.

Consider the following setup. You need a switch statement for an enum variable.

Writing a switch statement

As soon as you type the braces of the switch block, a Quick-Fix becomes available which can generate the appropriate switch labels for you. You could ask, “What is there to fix?” as you are meaning to supply them by hand, anyway. Programming by intention or not, the Quick-Fix is there and it can save you some time, so why not use it?

Press Alt + Enter to bring up the available quick-fixes (just one in this case), then select the right one:

Press Alt + Enter for available quick-fixes

Immediately after, the case stubs are generated for you. All values of the enumerated type are included and a break statement is supplied for you to add to.

The switch labels are generated

There are lots of this kind of things available in Quick-Fixes and Context Actions (new in ReSharper 2.0). We’re going to talk about those pretty soon.

Please send in your suggestions for post topics and requests for tips and tricks. We’ll listen.

Technorati tags: , , ,

Ctrl Alt V for Variable

Thursday, June 8th, 2006

Nowadays it’s an open secret that refactoring is indispensible for creating clear, well-structured code. This change is reflected in the fact that in 2005, we saw several refactorings introduced in Visual Studio, including Rename, Extract Method, Encapsulate Field, and a couple of others.

However, this was not the first time that powerful and flexible refactorings were made available to C# developers. ReSharper’s rich set of refactorings, which keeps growing steadily from one release to the next, adds great value to Visual Studio.

Here is one of the sweet refactorings you’ll want to have at your disposal in C# and ASP.NET: Introduce Variable.

Introduce Variable lets you quickly create a variable from any expression. All usages of the expression are instantly replaced with the newly declared variable. Here’s a basic example:

  1. Select an expression from which to make a new variable.
    Before the refactoring


  2. Press Ctrl + Alt + V to bring up the refactoring dialog, then provide the necessary details for the new variable. Select the “Replace all occurrences” option (occurrences are neatly highlighted in the editor as soon as this dialog opens) - if that’s what you want to do, of course.
    Introduce Variable dialog


  3. After you click Continue, the code looks like this:
    After the refactoring



Ok, so that’s how you can use the refactoring on an existing piece of code. Another way is to introduce a variable on the go. If you type an expression, and then it hits you that it should be declared as a variable (or a constant), just introduce it as one and keep typing.

Here’s a simplified example (if we forget for a second that we already have System.Math.PI available…)

Before:
Before the refactoring

Dialog:
Introduce constant

After:
After the refactoring

With ReSharper you can introduce other things, too: Introduce Parameter and Introduce Field. More on that later.

P.S. Don’t mind the typo (that is, if you spotted one) - it will be fixed in the upcoming bugfix release.

Technorati tags: , , ,

What is your favorite feature in ReSharper?

Monday, June 5th, 2006

To be perfectly honest, it’s impossible to choose a single most valuable feature in ReSharper. Some say it’s on-the-fly error highlighting, some hail the versatile refactorings, while many go crazy for smart name code completion. Well, different strokes for different folks. For now, I would like to focus on one neat little feature that will save you tons of time regardless of your coding style: Go to Type.

The idea is simple. To navigate to any type, all you need is its name.

Press Ctrl + N and start entering the type’s name. You will see the list of matching types in your solution:

Go to type by name

The list is filtered as you enter more letters. Once you see the desired type, select it to navigate to its declaration.

You can further accelerate this process with one or more wildcard options:

  • CamelCase search is supported in Go to Type. If you insert upper case letters in the search box, the filtered names are allowed to skip any number of lower case letters but must include the upper case ones in the order specified in the search string.

    Go to type using CamelCasing

    In the example above, the search string includes some upper case letters as well as some lower case ones. Alternatively, you can enter only upper case letters, resulting in very precise filtering. For instance, to go to LabelDeclarationStub, enter LDS:

    Navigate faster with CamelCasing
  • Insert * (asterisk) to represent 0 or more characters.

    Use wildcards for advanced type name search
  • Insert + (plus sign) to represent 1 or more characters.

    Use wildcards for advanced search
  • Insert ? (question mark) to represent 0 or 1 characters.

    Find types by name using wildcard search


Go to type and enjoy it!

Would you like to tell us about your favorite feature in ReSharper? Leave your comment below :)

Technorati tags: ,

JetBrains .NET Tools Blog is Here!

Thursday, June 1st, 2006

JetBrains ReSharper 2.0 is out (yay!) and so we’re launching a new JetBrains .NET Tools blog.

We’re going to collect interesting bits and pieces of information related to .NET productivity tools, primarily JetBrains ReSharper and JetBrains dotTrace Profiler. You will also learn about some of the more intriguing and beneficial features of these useful applications as we highlight them in the blog.

Here’s what’s going to come your way very soon:

  • Tips & Tricks. Everything you always wanted to know about ReSharper and dotTrace but were afraid to ask! This category will include some of the more inconspicuous, yet extremely useful features of our .NET tools. Go exploring and you’ll be sure to discover some hidden treasures.
  • News and Events. Announcements and news will be published in the blog. Significant .NET events and other developments will not go unnoticed either.
  • Links and Opinions. When someone else writes or says something of interest about ReSharper or dotTrace, you’ll see it here. Many current developers are hooked on ReSharper, and we’re only happy to let them say it in their own words.
  • How-To’s. Taking further the idea of Tips and Tricks section, we’ll write about actual development scenarios where serious challenges were tackled and overcome with ReSharper’s and/or dotTrace’s help.


You’re very welcome to comment and participate in JetBrains .NET Tools Blog. See you there!

Technorati tags: , ,