Skip to content

Breaking change in linebreak handling in 7.0 RC1 #8008

@SteveSandersonMS

Description

@SteveSandersonMS

Description

I'm unsure if this is an issue in dotnet run or in the underlying runtime/libraries, so please redirect elsewhere if needed. Also, I don't know if this is a deliberate change.

Customer impact

The impact of this change is that existing code that renders to the console produces corrupt output. It seems to be that, in the past, a Unix-style \n was enough to produce normal newline behaviors, whereas this has changed and now it only works on Windows if you output \r\n. Our cross-platform compatibility has been reduced.

Reproduction Steps

  1. Create a new console app (dotnet new console)
  2. Change the contents of Program.cs to be Console.WriteLine("Line1\nLine2");
  3. Run it on Windows in either the Terminal app or the old-school console (i.e., cmd.exe) using the command dotnet run

Expected behavior

In 7.0 preview 7 (I tried 7.0.100-preview.7.22377.5) and earlier, the output is:

Line1
Line2

This is the expected and desired output

Actual behavior

Starting from 7.0 RC1 and still happening with RC2 builds, you get:

Line1
     Line2

Regression?

Yes, worked in 7.0.100-preview.7.22377.5

Known Workarounds

None

Configuration

Windows 11 x64
Works in 7.0.100-preview.7.22377.5
Fails in 7.0.100-rc.1.22431.12 and 7.0.100-rc.2.22463.6

Other information

No response

Metadata

Metadata

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions