Tuesday, June 2, 2009

Refactoring with ReSharper

From: http://peterkellner.net/2008/07/03/code-refactoring-with-resharper/

One of the really nice features I enjoy using in Resharper 4.0 is the refactoring that converts inefficient (and unpleasant to read) syntax into nice efficient code. In this post, I’ll show some refactorings that Resharper (from JetBrains) gives us. There are lots more, but the ones listed below seem to come up the most in my own c# code.




Creates String.Format in C# From “a” + “b” + “c” syntax

From:

var url = wikiURL + "/api/AddPage?apikey_v1=" + apiKey
+ "&page=" + wikiPageName
+ "&name=" + name
+ "&email=" + email;

To:

var url =  string.Format("{0}/api/AddPage?apikey_v1={1}&page={2}&name={3}&email={4}",
wikiURL, apiKey, wikiPageName, name, email);

Create Simple Logical Assignments From my Overly Verbose Code

From:

if (ConfigurationManager.AppSettings["ShowDinnerConfirmation"].ToLower().Equals("true"))
{
TableRowSaturdayDinner.Visible = true;
}
else
{
TableRowSaturdayDinner.Visible = false;
}

To:

TableRowSaturdayDinner.Visible = ConfigurationManager.AppSettings["ShowDinnerConfirmation"].ToLower().Equals("true"); 

Use ?? When I’ve used Simple ? Operator Makes for Simpler Code

From:

string s = context.Request.QueryString["Cache"] == null ? "true" : context.Request.QueryString["Cache"];

To:

string s = context.Request.QueryString["Cache"] ?? "true";


Note
  • current version 4.5.1 compatible with vs2008 and can use on vs2005 no problem
  • Get it ...
  • can refactor html code too easy
  • but when i try refac store procedure code i can't see function for it.
  • it great refactoring for .NET Developer
  • built-in function refactoring in .net this link...

Reference

1 comment:

  1. Thanks for sharing this post. Your work is amazing. You can also check out vstfine Crack for Free. You can also visit the

    Bandicam Crack
    Traktor Pro Crack
    FabFilter Total Bundle Crack
    Adobe Photoshop CC Crack
    Wavelab Pro Crack
    Bulk Image Downloader Crack
    KMPlayer Crack
    EaseUS Data Recovery Wizard Pro Crack
    Knowledge Has No End Limits Keep Sharing Your Knowledge//

    ReplyDelete