You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
The SetTerminalForegroundRed and ResetTerminalForegroundColor methods of ConsoleExtensions can read the Platform.IsConsoleRedirectionCheckSupported and Console.IsOutputRedirected properties when deciding what to do. However, the value of Console.IsOutputRedirected has no effect in the end, because those methods execute the same code either way:
IsConsoleRedirectionCheckSupported
IsOutputRedirected
SetTerminalForegroundRed
ResetTerminalForegroundColor
true
false
sets Console.ForegroundColor
calls Console.ResetColor()
true
true
sets Console.ForegroundColor
calls Console.ResetColor()
false
not read
does nothing
does nothing
That seems unintentional. If the behavior is correct, then at least the logic could be simplified.
The redundant logic came from #676. Before that, the methods worked like this:
IsConsoleRedirectionCheckSupported
IsOutputRedirected
SetTerminalForegroundRed
ResetTerminalForegroundColor
false
false
sets Console.ForegroundColor
calls Console.ResetColor()
false
true
does nothing
does nothing
true
not read
sets Console.ForegroundColor
calls Console.ResetColor()
except that they also checked for an ITerminal interface by name. The IsConsoleRedirectionCheckSupported property used to return the opposite of what it returns now. Based on that, I think the correct behavior would be:
Activity
KalleOlaviNiemitalo commentedon Sep 13, 2022
The redundant logic came from #676. Before that, the methods worked like this:
except that they also checked for an
ITerminalinterface by name. The IsConsoleRedirectionCheckSupported property used to return the opposite of what it returns now. Based on that, I think the correct behavior would be: