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.KeyAvailable throws when input isn't redirected on Windows 7 x86 #43015

Closed
ViktorHofer opened this issue Oct 4, 2020 · 2 comments
Closed

Comments

@ViktorHofer
Copy link
Member

[xUnit.net 00:00:03.88]     ReadKey.KeyAvailable [FAIL]
[xUnit.net 00:00:03.88]       System.InvalidOperationException : Cannot see if a key has been pressed when either application does not have a console or when console input has been redirected from a file. Try Console.In.Peek.
[xUnit.net 00:00:03.88]       Stack Trace:
[xUnit.net 00:00:03.89]         /_/src/libraries/System.Console/src/System/ConsolePal.Windows.cs(278,0): at System.ConsolePal.get_KeyAvailable()
[xUnit.net 00:00:03.89]         /_/src/libraries/System.Console/src/System/Console.cs(153,0): at System.Console.get_KeyAvailable()
[xUnit.net 00:00:03.89]         /_/src/libraries/System.Console/tests/ReadKey.cs(21,0): at ReadKey.KeyAvailable()

Additional logging:

 fileTypeOutput 'input': 2
 IsInputHandleRedirected: False

The docs state that fileType 2 means:

The specified file is a character file, typically an LPT device or a console.

I would assume that in such a case an InvalidOperationException shouldn't happen. Also this seems to be specific to Windows 7 x86.

cc @eiriktsarpalis

@ViktorHofer ViktorHofer added this to the Future milestone Oct 4, 2020
@ghost
Copy link

ghost commented Oct 4, 2020

Tagging subscribers to this area: @eiriktsarpalis, @jeffhandley
See info in area-owners.md if you want to be subscribed.

@adamsitnik
Copy link
Member

dotnet/announcements#226

@adamsitnik adamsitnik reopened this Jul 7, 2022
@adamsitnik adamsitnik closed this as not planned Won't fix, can't repro, duplicate, stale Jul 7, 2022
@ghost ghost locked as resolved and limited conversation to collaborators Aug 6, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

4 participants