SPDisposeCheck: Do not use for SharePoint 2013

I like many SharePoint developers out there I am user of SPDisposeCheck. My team and I use this as in our Continuous Integration builds as one of our quality checks on to determine if our code is passing the checks we need for a ‘green’ build.

In fact SPDisposeCheck is so valuable in terms of catching issues before they get into any live code from my team I consider it to be, borrowing from Doug Ware’s metaphor, the safety catch on my machine gun.

During beta we discovered that SPDisposeCheck was not working for SharePoint 2013.

Consider this code:

This code leaks like a seive

Now most of you who have done a bit of SharePoint development should be able to see that code has a gaping memory leak and should not pass SPDisposeCheck.

SPDisposeCheck zero issues found

Yeah, that’s not ideal…

But what about static code analysis? Microsoft.Reliability: CA2000 Dispose objects before losing scope is supposed to catch things like this too, right? Unfortunately this memory leak slips right past that check too.

Code analysis no issues found

This still has not been resolved. Yes, if you were doing SharePoint 2013 and thinking that you’re doing the right thing, using SPDisposeCheck, you need to do a code review. Now.

Myself and other SharePoint MVPs who are development focused are doing our best to keep this on the radar within Microsoft.

I for one really hope that we do get another version of SPDisposeCheck that can analyse our .NET 4.5 SharePoint 2013 code to stop developers out there from shoot themselves in the foot and taking down SharePoint servers with memory leaks.

Advertisements
This entry was posted in Best Practice, Development, SharePoint. Bookmark the permalink.

4 Responses to SPDisposeCheck: Do not use for SharePoint 2013

  1. The SharePoint Code Analysis Framework now implements all (still valid) SPDisposeCheck rules directly and supports .NET 4 assemblies. See here http://docs.spcaf.com/v4/SPCAF_VISITORGROUP_RULES_MEMORYDISPOSALGROUP.html

    The SPCop VS extension including all rules will remain free (!).

    More details and download link here http://www.spcaf.com/blog/v4-0-7-1001-beta-2013-09-04/

  2. Pingback: My Twitter and RSS highlights for August 2013 » Christian Heindel – IT Solutions & Consulting

  3. Pingback: SharePoint 2013 Dispose checker | Question and Answer

  4. Pingback: Extensions methods para SharePoint | SharePoint Brasil

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s