Posted by: the author | August 22, 2013

Code Regions

Today, I was watching a Channel 9 video about Visual Studio 2013 for Web Developers (found here).  There’s a lot of great stuff in it, but one thing in the beginning of the video that stood out to me was that you can do code regions in JavaScript.  Who knew, right?  Here’s how:

//#region SomeCoolName

function someCoolFunctionName() {
// Some cool function stuff
}

//#endregion

Simply enough for me.  However, you’ll need the Web Essentials 2012 extension for it, which is found here: http://vswebessentials.com/

Okay, so that’s for JavaScript.  We already should all know how to do it in C#.  I’m a huge fan of keeping code neat and organized.  So, I was actually kind of surprised to not see support for regions in XAML code.  Just a little digging for that one day, earlier this year, led me to this: http://visualstudiogallery.msdn.microsoft.com/3c534623-bb05-417f-afc0-c9e26bf0e177

A simple example from that site shows this:

<!– Region (Any Text You Want) –>
Your Code
<!– EndRegion –>

Ah, now that’s what I wanted.  It worked great when I took over a project with a pretty structured layout in a Grid element.  Grouping things into regions certainly helped organize all of that. 🙂

Advertisements

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

Categories

%d bloggers like this: