We have a .NET 5 console application that runs on Windows/Linux/Mac.
Our console application relies on the classic fore color scheme to highlight info/warning/error in console with fore colors gray/yellow/red. However we cannot gather the terminal back color as explained in Console.BackgroundColor documentation:
Unix systems don't provide any general mechanism to fetch the current console colors. Because of that, BackgroundColor returns (ConsoleColor)-1 until it is set in explicit way (using the setter).
For now we force the console backcolor to be black but this doesn't render nicely when the terminal back color is white:
If we could guess the terminal back color we could adapt our forecolor to the terminal back color (like black fore color if the terminal back color is white and vice-versa). But from answers to this question How to determine a terminal's background color? it looks there is no standard way of getting background color that works on Mac and all Linux.
What is the common way to address this?