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.

Posted in Best Practice, Development, SharePoint | 2 Comments

Practical Guide to Public Facing sites

This year I presented a second session at the New Zealand  SharePoint Conferences, on “A Practical Guide to Public Facing web sites”. As promised in my session here is the slide deck.

Posted in Conferences, Development, SharePoint | Leave a comment

Writing testable SharePoint code: New Zealand and Australian SharePoint Conferences

This year I was lucky enough to be invited back to present at the New Zealand and Australian SharePoint Conferences, this time on “Writing Testable SharePoint Code”. As promised in my sessions here is the slide deck and, more importantly, the sample code :)

Posted in Conferences, Development, SharePoint, Visual Studio | Leave a comment

Design Manager and Server 2008 R2

I was trying to use the design manager features today and ran into this on my dev server. I’d copied the short cut from the screen and pasted it into the map network folder dialog and got this:

image

 

If you’re trying to do this from Server 2008 R2 you’ll need to do a simple piece of config first; Simply go and add the Desktop Experience Feature and reboot your server!

A nice and easy fix :)

Also make sure you use the http:// path and not the file:// path that you’ll get with right click > copy shortcut ;)

Posted in Uncategorized | Leave a comment

Setting up Visual Studio 2012 for SharePoint 2013

VS2012 Update 1 is great it adds the Microsoft Fakes framework for stubbing out SharePoint dependencies and other really useful tools for SharePoint development. If you’re using Visual Studio 2012 you should be using Update 1; but it doesn’t have the extensions for 2013 development as yet. To get those they need to be installed using the web platform installer.

1) Download and install http://www.microsoft.com/web/downloads/platform.aspx (you should probably do this for all development environments anyway)

2) Launch the Web Platform Installer and search for SharePoint

3) Add install the latest version of the “”Microsoft Office Developer Tools for Visual Studio 2012” (currently it’s Preview 2)

Posted in Development, SharePoint, Tools | Leave a comment

PowerShell: Pause for specific key strokes

Today I needed to add a wait into a Powershell script, given that is a point where the user running the script needs to go do some manual steps on another server I thought it might be a good idea to wait for a specific key press. So off to Bing I go…

There are plenty of great articles on waiting for or getting user input, personally I really like Windows PowerShell Tip of the Week: Pausing a Script Until the User Presses a Key and the User Interaction chapter from the PowerShell Cookbook. After seeing that [Console]::ReadKey() would give me an object which told me about the modifers on the key press (Crtl, Alt and/or Shift) I started thinking about making that key press more specific, say Ctrl + G, so I wrote a function to handle this:

function Pause
{
	param([string] $pauseKey,
			[ConsoleModifiers] $modifier,
			[string] $prompt,
			[bool] $hideKeysStrokes)
			
    Write-Host -NoNewLine "Press $prompt to continue . . . "
    do
	{
		$key = [Console]::ReadKey($hideKeysStrokes)
	} 
	while(($key.Key -ne $pauseKey) -or ($key.Modifiers -ne $modifer))	
	
    Write-Host
}

This function received a bit of inspiration from How to Properly Pause a PowerShell Script which itself is pretty interesting.

Things to note:

Ctrl + C will still cancel the script, you’ll need to use $host.UI.RawUI.ReadKey with the AllowCtrlC option to prevent that, but then accessing the Modifiers is done differently.

$modifers is a simple enum value of ConsoleModifiers if you want to do combinations like Atl+Shift you’ll pass a collection of modifers and do –band operations to see if your conditions are met.

To call the Pause function use something like this:

$modifer = [ConsoleModifiers]::Control
Pause "G" $modifer "Ctrl + G" $true  

And then you’ll see this: image

Posted in Uncategorized | Leave a comment

I’m an MVP for SharePoint Server!

Wahooo!

A couple of weeks ago I got one of the coolest emails I’ve received in my professional career, it read:

Dear Gavin Barron,
Congratulations! We are pleased to present you with the 2012 Microsoft® MVP Award! This award is given to exceptional technical community leaders who actively share their high quality, real world expertise with others. We appreciate your outstanding contributions in SharePoint Server technical communities during the past year.

I’m really happy receive this honour! I’d really like to thank everyone at Intergen for the support they’ve provided over the years and for an environment where community involvement is encouraged. I’d like to personally call out Chris, Chan, Debbie, OJ and Brendan for their personal support and help since I first got involved with this crazy SharePoint thing.

It’s been a heck of a ride so far and with the public preview of Office 2013 announced this morning I’m looking forward to the next few months.

-Gavin

Posted in Personal, SharePoint | Leave a comment