I’ve created a static analysis ruleset for SPDisposeCheck!
SPDisposeCheck is a valuable tool developed by a small team within Microsoft Premier Support led by Roger Lamb that inspects an assembly to ensure that SharePoint API objects are properly disposed. Failure to properly dispose SharePoint API objects can cause memory leaks. The SPDisposeCheck tool can be downloaded here:
http://download.microsoft.com/download/B/4/D/B4D279A0-E159-40BF-A5E8-F49ABDBE95C7/SPDisposeCheck.msi
The source and compiled versions are available on CodePlex:
http://spdisposecheckstatic.codeplex.com/
Here are the steps to get this up and running on your SharePoint projects:
Copy the SPDisposeCheck SPDisposeCheckRules.dll and the SPDisposeCheck.exe to your local static analysis rules folder.
Example: C:\Program Files\Microsoft Visual Studio 9.0\Team Tools\Static Analysis Tools\FxCop\Rules
Open a SharePoint project and select Project Properties. Select the Code Analysis tab. You should see a new ruleset available called SPDisposeCheck Rules.
If you select Enable Code Analysis on Builds and Treat Warnings as Error for the SPDisposeCheck ruleset, developers should see any SPDispose errors on build for any code added to the solution.
January 9, 2010 at 2:58 am
Many thanks for the information. I appreciate it. You have a very nice website.
January 13, 2010 at 12:51 am
Hi – just a brief note to say kudos for this entry. Very informative.
February 25, 2010 at 2:20 am
[…] even more usefull: SPDisposeCheck using Static Analysis in TFS ( 2010 […]
March 27, 2010 at 2:46 am
I’ve just rebuilt that project for VS2010 and it’s working fine for 2010 projects 😉
January 27, 2014 at 2:08 pm
[…] wonderful RulSset has been originally created by Stephen Vick, I just tweaked it a little bit to make it work with Visual Studio […]