问题
Is there any way to make visual studio dim or hide/show on demand logging lines of my code?
We use a lot of logging in our project and it's harder to read code like this.
I would like it to be like this, for example:
回答1:
I use this. Hoping one day they will add color customization and line selection regex options as well:
https://marketplace.visualstudio.com/items?itemName=ElmarXCV.GrayLogLines
回答2:
Unobtrusive Code extension worked for me for Visual Studio 2019. It dims the opacity of log lines (and comments, which I disabled - I enjoy reading my comments). He did a quick update for the nuget package, and it works great.
https://marketplace.visualstudio.com/items?itemName=niklaskallander.UnobtrusiveCode
回答3:
There is no way to do this from the standard Visual Studio IDE. In order to do this you would need to define a custom extension which recognized lines like this, tagged them with a specific format and have that format be colored a lighter color in the IDE
回答4:
a "hackier" way would be to wrap all logging in a preprocessor directive like
#if DEBUG
Log.Info(........)
#endif
Visual-Studio will "dim" the code inside. and have some kind of config header where you
#define DEBUG 0
Not the prettiest but its nice if you don't want debug code compiled into your Release binary
回答5:
why don't you put your section within #region tag.
E.G:
#region Put some region name here for your reference Your Code / Comment / Whatever #endregion
来源:https://stackoverflow.com/questions/15209471/dim-hide-logging-lines-of-code-in-visual-studio