Console Output Invisible for some default background colors
aodennison opened this issue · comments
In my case, my console windows default to ConsoleColor.Gray or ConsoleColor.Red, if I have elevated permissions.
This causes the text after the Version number "by " (in italics below) to be invisible:
Reference: JetBrains.Annotations, Version=2020.3.0.0, Culture=neutral, PublicKeyToken=1010a0d8d6380325
JetBrains.Annotations, Version=2020.3.0.0, Culture=neutral, PublicKeyToken=1010a0d8d6380325
Source: Local, Location: C:\dropbox\2018.11\AOD\ConsoleHelpers\lib\net40\JetBrains.Annotations.dll
2020.3.0.0 by >>> AOD.Common, Version=2020.12.30.29793, Culture=neutral, PublicKeyToken=null <<< This is invisible !!
The simplest suggested fix is to set the colors to the expected defaults, like so:
public ConsoleLogger(bool showMessages)
{
_showMessages = showMessages;
Console.ForegroundColor = ConsoleColor.White;
Console.BackgroundColor = ConsoleColor.Black;
Console.Clear();
}
I may not have picked the best place for this, but it worked for me.
The more general approach is to always set FG & BG colors, to avoid FG == BG.
There is also an issue with using Console.ResetColor(), since this reverts back to my default colors. The result is some empty grey lines in the output. It can be removed from ConsoleVisualizer.Visualize().