SharePoint Dispose Checker – Even more useful than expected
By now you have probably heard that the SharePoint Dispose Checker has been released. It's an excellent tool for checking you are disposing of your SharePoint objects correctly!
I downloaded it this morning as soon as I read about it just to see if I have really been as conscientious as I thought I had. 
Turns out, according to the output from the tool that I have done a pretty good job of cleaning up after myself. In the 10,000 lines of code mostly devoted to interrogating the SharePoint structure there were only 15 issues raised and all but 2 were false positives – darn those UserProfile personal site objects!
What did surprise me was that the false positives were actually quite useful in bringing to light some areas of the code that were less than perfect. For example, where I had used two instances of the same site in the same code block where one would have sufficed or where although objects were disposed of in a finally block, there were instances where exceptions further up in the code could have lead to one of several objects not being disposed correctly. It also highlighted some areas where although there was a disposal in the finally block the code looked much neater if it was replaced with a using block.
I'd recommend that you run the tool over your code no matter how careful you are for the review value alone.
I'm going to put this into my projects build events – and if I get really keen perhaps I'll parse the output to remove the known false positives automatically.
I wonder why it won't run against the assemblies in the ISAPI directory… 
This entry was posted
on Thursday, January 29th, 2009 at 3:53 pm and is filed under Uncategorized.
You can follow any responses to this entry through the RSS 2.0 feed.
You can leave a response, or trackback from your own site.
SharePoint Dispose Checker – Even more useful than expected
By now you have probably heard that the SharePoint Dispose Checker has been released. It's an excellent tool for checking you are disposing of your SharePoint objects correctly!
I downloaded it this morning as soon as I read about it just to see if I have really been as conscientious as I thought I had. 
Turns out, according to the output from the tool that I have done a pretty good job of cleaning up after myself. In the 10,000 lines of code mostly devoted to interrogating the SharePoint structure there were only 15 issues raised and all but 2 were false positives – darn those UserProfile personal site objects!
What did surprise me was that the false positives were actually quite useful in bringing to light some areas of the code that were less than perfect. For example, where I had used two instances of the same site in the same code block where one would have sufficed or where although objects were disposed of in a finally block, there were instances where exceptions further up in the code could have lead to one of several objects not being disposed correctly. It also highlighted some areas where although there was a disposal in the finally block the code looked much neater if it was replaced with a using block.
I'd recommend that you run the tool over your code no matter how careful you are for the review value alone.
I'm going to put this into my projects build events – and if I get really keen perhaps I'll parse the output to remove the known false positives automatically.
I wonder why it won't run against the assemblies in the ISAPI directory… 
This entry was posted
on Thursday, January 29th, 2009 at 3:53 pm and is filed under Uncategorized.
You can follow any responses to this entry through the RSS 2.0 feed.
You can leave a response, or trackback from your own site.