ReSharper 5.0 Hidden Gem – Patterns Catalogue

Have I mentioned that I love ReSharper? While patiently waiting for the 5.0 release to RTM, the team at JetBrains have shipped the Beta 2 release (build 1618). This is a very stable, very good improvement over the previous nightly builds.

One of the things that improved the most with this release is the SSR – Structural Search and Replace. It’s a new feature, allowing you to specify code patterns to be added as hints, errors or warnings to the ReSharper code analysis, as well as specifying a replacement pattern.

Here is an example of this feature, taken from the JetBrains .NET Tools blog:

Adding the following pattern:

Will add a new quick-fix action:

The patterns can also be imported/exported as XML files, allowing easy sharing between co-workers.

In order to create a new pattern, select Patterns Catalogue from the Tools submenu of ReSharper menu.

Press Add Pattern.

 

We can add either a search only pattern, or a search and replace pattern. Let’s add a pattern to turn NUnit Asserts into fluent NUnut Assert syntax:

  • Add Assert.AreEqual($expected$, $actual$) in the “Search Patten” window.
  • Press “Add Placeholder”, select argument, and type expected in the name. Do the same for actual.
  • In “Replace Pattern”, type Assert.That($actual$, Is.EqualTo($expected$)).
  • Choose Pattern severity, I selected “Show as suggestion”.
  • Fill in the description texts.

The final result should look like this:

Press Save and close the Pattern Catalogue dialog.

You will now be able to turn this:

into this:

Happy coding!

posted @ Thursday, February 25, 2010 11:06 PM

Print

Comments on this entry:

# re: ReSharper 5.0 Hidden Gem – Patterns Catalogue

Left by casinos de jeux VIP at 6/16/2010 1:32 PM
Gravatar
Structural Search and Replace is a new feature, allowing you to specify code patterns to be added as hints, errors or warnings Thanks for such a beautifully composed, informative article.I think your work to this is really great .
I really appreciate your work to this site....Thanks...

# re: ReSharper 5.0 Hidden Gem – Patterns Catalogue

Left by casinos de jeux VIP at 6/16/2010 1:32 PM
Gravatar
This article gives the light in which we can observe the reality. this is very nice one and gives in
depth information.Valuable information for all.I will recommend my friends to read this for sure... Thanks.....

Your comment:



 (will not be displayed)


 
 
 
Please add 7 and 8 and type the answer here:
 

Live Comment Preview:

 
«September»
SunMonTueWedThuFriSat
2930311234
567891011
12131415161718
19202122232425
262728293012
3456789