Visual Studio: Custom code highlighting based on r

2019-04-08 10:21发布

As my application supports some paranoid debug level (every data assignment, every step in the code is written to a log destination), my code is littered with logging calls in some methods, e.g.

logger.Log(LogLevel.Debug, 0, "Initializing i18n...");
Lang.Language = SystemInfo.Language;
Logger.Log(LogLevel.Debug, 0, "Default system language: " + Lang.Language);
string[] languageFiles = Directory.GetFiles(ClientEnvironment.LanguagePath);
Logger.Log(LogLevel.Debug, 0, "Initializing local language files...");

As you can see, there are only two "real" code lines. This makes the code somewhat hard to read. I wonder whether I can specify some custom code formatting rule within Visual Studio to let the logging lines appear in a soft gray text color, instead of the default text color. This would lead to an implicit highlighting of the "real" code lines, resulting in a more readable code.

I need something like:

If statement starts with "logger.Log", set foreground color to gray.

Do you know any plugins which could archieve such a behaviour? Thank you in advance.

1条回答
霸刀☆藐视天下
2楼-- · 2019-04-08 11:00

Edit: This is not an appropriate answer to the poster's question, but I cannot delete it because StackOverflow won't allow the accepted answer to be deleted.

This Visual Studio extension will do just what you want:

You can specify regular expressions for custom output window colorization.

查看更多
登录 后发表回答