Using VS2010 I like the feature where I can set up a region and then click on the square in the border area of the text editor and have it compressed down to one line. I have the same feature available when I have a class. One click in the box and the height of the class goes to one row.
#region ModelState not valid
else
{
ModelState.AddModelError("", "Data Entry error");
return View("CreateEdit", vm);
}
#endregion
However it seems like overkill to have #region everywhere in my code. Is there a way that I can make VS2010 give me the ability to compress down the size of any code block surrounded by braces?
Another slightly related question. Can I change it so that by default the code blocks surrounded by braces don’t have an empty brace on a line. Rather that the brace goes on the same line after for example an “if statment”?
Nope, that’s what #region is there for. Although it can sometimes look a little ugly, you can reduce the perception of lots of regions by making their description the comment for the section of code that follows, so you’re actually improving the documentation of your code at the same time.