How to hide tracking code in Visual Studio IDE C #?

As I begin to put more tracing in my code, I understand that it adds a lot of mess. I know that Visual Studio allows you to hide and detect the code, however I would like the group code to be in the tracking code, and then hide it and detect it as desired when I read the code. I suppose he could do this either for each file, or for each class, or for each function.

Is there any way to do this? What are you guys doing?

Adding some clarification

The hidden view of the function allows you to do this, except that when the code is hidden, you cannot determine whether its trace is or not. You also cannot say “hide all trace code” and “show all trace code”, which is useful when reading a function depending on what you are trying to do.

+6
c # visual-studio code-readability tracing
source share
2 answers

Did you consider #region ?

  int x = 3; x++; #region Trace // ... #endregion x += 2; 

VS will automatically allow you to expand or hide the region.

0
source share

I would advise you not to hide it. If the template code that gets to the scene where it should be hidden so that you can see the "real" code, it is better to find a better way to separate the problems.

This is often true for trace / debug code. Something I recently looked at is to use the AOP framework to inject debug instructions into other classes. Take a look at PostSharp , shows how to do it.

+1
source share

All Articles