As I'm starting to put more tracing in my code, i'm realizing it adds a lot of clutter. I know Visual Studio allows you to hide and reveal code, however, i'd like to be able group code into "tracing" code and then hide it and reveal at will as i'm reading the code. I suppose it could do this either per file or per class or per function.
Is there any way to do this? What do you guys do?
Adding some clarification
The hide current feature kind of allows you to do this except that when the code is hidden, you can't tell if its tracing or not. You also can't say "hide all tracing code" and "reveal all tracing code" which is useful when reading a function depending on what you are trying to do.
The #Region directive enables you to collapse and hide sections of code in Visual Basic files. The #Region directive lets you specify a block of code that you can expand or collapse when using the Visual Studio code editor. The ability to hide code selectively makes your files more manageable and easier to read.
Navigate Forward/Backward Ctrl+–/Ctrl+Shift+– If you've moved from one location to another you can use the keyboard sequence <Ctrl>+– to move to the previous location and then you can return using Ctrl+Shift+–.
I'd advise against hiding it. If there's boilerplate code that's getting to the stage where it needs to be hidden away so that you can see the "real" code, then it's better to find a better way to seperate the concerns.
This is often true of tracing/debug code. Something I've looked at recently was to use a AOP framework to inject debug statements into other classes. Have a look at PostSharp, The example demonstrates how to do exactly that.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With