Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Console Output Invisible for some default background colors #74

Open
aodennison opened this issue Dec 30, 2020 · 0 comments
Open

Console Output Invisible for some default background colors #74

aodennison opened this issue Dec 30, 2020 · 0 comments

Comments

@aodennison
Copy link

aodennison commented Dec 30, 2020

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().

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant