-
Notifications
You must be signed in to change notification settings - Fork 5.3k
Description
Description
Code:
var line = Console.In.ReadLine();
Console.WriteLine($"Got: {line}");
Console.WriteLine((line is null));
line = Console.In.ReadToEnd();
Console.WriteLine($"Got: {line}");
Console.WriteLine((line is null));
When run on net6, I can hit ^D for both ReadLine and ReadToEnd to get this output:
Got:
True
Got:
False
So far, so good.
When the same code is built for .net7, I can hit ^D all day and it is never recognized. If I enter some text for the ReadLine then some text for ReadToEnd and hit ^D (on its own line), still ignored.
If I comment out the ReadLine case and build, I can pipe a file into it successfully for both .net6 and .net7.
This seems specific to .net7.
Running .net7RC1 on MacOs. Happens when run in MacOS Terminal, iTerm2, and the integrated VSCode terminal.
Configuration
Works on .net6 GM
Does not work on .net7RC1. I started with RC1 so don't know if it was broken in prior pre-releases.
MacOS Monterrey 12.6 (also failed on 12.5).
Arm64 Mac Studio.
I don't believe it is specific to this OS/architecture.
Regression?
I started with .net7RC1 and do not know if the bug existed in prior pre-releases.
I use this console input method quite often in my tools since .net5 and this is the first change in behavior.
Other information
This was straight out of 'dotnet new console -n Bug':
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<OutputType>Exe</OutputType>
<TargetFramework>net7.0</TargetFramework>
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable>
</PropertyGroup>
</Project>
For the .net6 tests, I changed the TargetFramework to net6.0.
My workaround when I have to paste from email or whatever into my tool is to pipe from cat:
cat | tvgLookup -
The bug is specific to reading from the terminal.