Skip to content

Platform.IsConsoleRedirectionCheckSupported has an inverted value #656

Closed

Description

@amis92

During the rename from IsWasm to IsConsoleRedirectionCheckSupported in PR #498 the actual meaning of the value was inversed, but the code using it wasn't, which results in the current code being very much contradicting.

  • IsWasm = true when the accessor IsOutputRedirected threw
  • IsConsoleRedirectionCheckSupported = true is now when the exception is thrown, as well.

The code as it is works as expected, but any other person using this Platform API that doesn't check the actual implementation will use it exactly in the opposite way.

(text copied from my #498 (comment))

public static bool IsConsoleRedirectionCheckSupported
{
get
{
if (_isConsoleRedirectionCheckSupported == null)
{
try
{
var check = Console.IsOutputRedirected;
_isConsoleRedirectionCheckSupported = false;
}
catch (PlatformNotSupportedException)
{
_isConsoleRedirectionCheckSupported = true;
}
}
return _isConsoleRedirectionCheckSupported.Value;
}
}

Activity

  1. added
    bug
    on Oct 29, 2019
  2. self-assigned this
    on Oct 29, 2019
  3. added 2 commits that reference this issue on Nov 9, 2019
    dd8b264
    c56ca1f
  4. added a commit that references this issue on Nov 12, 2019
    e0e1ffa
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

bug

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions