Is there a way to get VS2010 to expand or contract try blocks inside my methods?

My code has many attempts, catch, finally blocks. Unlike methods, when I am in VS2010, I cannot expand or contract these areas to hide content during development, except for adding regions.

try { vm.R... vm.Qu.. vm.T... vm.D... vm.Fil.. vm.Type.. vm.St.. } catch (Exception e) { log(e); return Content(ExceptionExtensions.GetFormattedErrorMessage(e)); } 

Is there a method that programmers use to organize code inside try blocks, or do I just need to live with these larger blocks of code.

+6
source share
2 answers

Without actually changing the code, the only thing I know is to use the exposition. You can β€œhide” the selection, which basically creates a section of the schema that you can expand and collapse in the same way as a class, namespace, method, #if block, etc. To do this:

  • Select the lines you want to collapse.
  • Choose Edit \ Crop> Hide Selection (or Ctrl + M , Ctrl + H using the C # keyboard layout)

Now the selection is collapsed, and you can expand it and re-collapse it anytime you want, as a method. (e.g. with a +/- glyph on the left or with Ctrl + M , M )

+16
source

For really clean code, try Extract Methods so that your blocks are smaller. And, if it is really necessary, you will get automatic code folding from Visual Studio.

+1
source

Source: https://habr.com/ru/post/925271/


All Articles