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)

image

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 :-)

6 comments:

  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 :)

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

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

    ReplyDelete
  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?

    ReplyDelete
  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.

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

    ReplyDelete