Why ReSharper Is Worth Using (reason #879)

image.png

  I often email the folks at JetBrains (the makers of ReSharper) letting them know that one of their refactors is wrong.  They often email me back letting me know my about my misunderstanding.  I actually enjoy this. Today, was a perfect example but I did not get past the ReSharper feedback form when I realized my code was wrong (sadly missed the exchange with them).  I’m busy writing the SEO save for Silicon Valley Code Camp’s new web site (coming by next week hopefully).  In this case, I’m looking for a trackId passed into the sessions.aspx page. If I find it, then I redirect to a more friendly URL. Here is my code I was going to complain to ReSharper about as incorrectly warning me that my trackId = –1; is … Continue Reading

A Quick Thank you and At-A-Program For Resharper and Refactoring

image.png

I had the following line embedded in an initializer: EmailAlerts = String.IsNullOrEmpty(emailAlerts) ? false : emailAlerts.ToLower().Equals("true"), Resharper says (“Simplify conditional operator”)     I say sure, ReSharper does EmailAlerts = !String.IsNullOrEmpty(emailAlerts) && emailAlerts.ToLower().Equals("true"), Clean, Elegant.  I’ve had some posts like this criticized in the past with comments like “Well, if you can’t do that on your own you shouldn’t be programming”.  My reply: “I could have, I didn’t, It did, and I like it better.   That’s it for now. … Continue Reading

LINQ and “Possible Multiple Enumerations of IEnumerable” Warning / Resharper To the Rescue!

In the most recent version of Resharper 7 from JetBrains, the brilliant team has gone one step above and beyond.  Not only do they show this error which can be quite tricky to both understand and fix, but they now go one step further and offer a fix. For example, look at the below code: var emailDetailInfos = new List<EmailDetailInfo>();using (var db = new SiteDB()){ foreach (var emailDetailId in emailDetailIds) { // first get details about this particular email var emailDetail = db.EmailDetails.FirstOrDefault(a => a.Id == emailDetailId); if (emailDetail != null) { // get all the Details associated including the htmlbody if there is one (that is, images and body) var details = (from ed in … Continue Reading

Deeply Nested Null Checking in C# verses Assert with no nesting

One of the code smells that particularly bothers me (though I often find myself doing it anyhow) is when I defensively program against nulls in C# (though could be any other language).  That is, I do something like the following var rec = getRecord(..); if (rec != null) { var rec1 = getAnotherRecord(..); if (rec1 != null) { rec2 = getAThridRecord(..); if (rec2 != null)... The code gets ugly quick and the nesting does not help the readability, and if anything, hurts it. Today, while using a daily build of Resharper7, I noticed that when I asked resharper to do the null check for me, instead of doing the above, it did the following: var rec = getRecord(..); Debug.Assert(rec != null,"rec != … Continue Reading

Follow

Get every new post delivered to your Inbox

Join other followers: