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


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

CodeIt.Right Takes Refactoring To The Next Level


Background I’m a big believer in using refactoring tools to help improve the quality of the code I right.  I just added another tool to my arsenal called CodeIt.Right from submain.  I can’t say for sure whether the other tools commonly used will somehow perform the refactoring I’m going to show, but I can say I really like how CodeIt.Right does it.  When I say it takes it to the next level, what I mean is it shows me things I know I should be doing (or in this case I’m fixing code that I got from someplace else.   As it turns out, the place I got it from was Microsoft’s samples for building Windows Store 8 apps.  If you want to find the original code, take a look at the WindowsBlogReader example to find the … 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

A Cool / Unexpected Refactoring around .Net C# Locking Issue

I’m constantly amazed by the insightfulness of ReSharper’s suggested refactorings (ReSharper is a Visual Studio Addin from JetBrains I use with C#). Today, I’ve been working on a threading problem where I’m getting crashes based on what seems like not proper locking across threads (they usually show up as some type of ugly update object or enum error). My code starts like this:   public static List<DbProgressReport> DbProgressReportProperty { get; set; }   … Continue Reading


Get every new post delivered to your Inbox

Join other followers: