Jun 22, 2010

Implement Interfaces and #Region

This is a quick one for a few guys I was talking with today.

One of the PITA things about Visual Studio 2008 / 2010 is that when you choose to have Visual Studio implement an interface for you it will generate the code inside a #region block.  And why is that bad?  Because regions suck! Feel free to start a religious wars over it, but let me just say that if I can’t see all the code when opening a source file and you make me click or press a hot key just to see a few lines of code it then I’m likely to go postal on you.  With a rotting halibut and a cork.

So, if you want to avoid the ire of the region police then let me suggest a small settings change in Visual Studio.  This one right here: (VS2010 screen shot shown)


Is that obvious enough for you? Good! Now go ahead and make that change and start being nice to your fellow developers.

That will be all :-)


  1. Oh! Removing #Regions from your "view" of the source code would be a perfect Visual Studio 2010 add-in. It's the best of both worlds. You won't ever have to see a collapsed region again :)

  2. I also suffer from region fury! After all... well composed code should not ever need them! ;) - Stonie.

  3. Thanks for this! I previously couldn't find this setting and spent hours implementing interfaces and deleting the regions.

  4. Um, instead of telling others what to do in order to satisfy your pet peeves, why don't you just uncheck that first box in the same dialog?

  5. @Anonymous Where's the fun in that :-) And when I go to someone else's machine... well, the same thing happens. Good point though.

  6. This is just your pet peeve. It is not wrong nor right.