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

CRLF new line chars are outputted when app is build on Windows environment #162

Open
filzrev opened this issue Feb 6, 2025 · 5 comments

Comments

@filzrev
Copy link
Contributor

filzrev commented Feb 6, 2025

On Windows environment.
Some unit tests that verify stdout failed by CRLF/LF differences.

Additionally, generated files contains both CRLF/LF new line chars.
(It's displayed as MIXED mode on Visual Studio editor)

When running compiled DLLs on non-Windows environment.
It outputting CRLF as new line chars.
(It's confirmed on WSL Ubuntu environment by redirecting stdout to file)

ConsoleApp.Run.g.cs
Image

@neuecc
Copy link
Member

neuecc commented Feb 6, 2025

Some unit tests that verify stdout failed by CRLF/LF differences

What does this mean?
Are you referring to the unit tests in this ConsoleAppFramework repository?

@filzrev
Copy link
Contributor Author

filzrev commented Feb 6, 2025

What does this mean?
Are you referring to the unit tests in this ConsoleAppFramework repository?

Yes, ConsoleAppFramework.GeneratorTests failed to run unit tests on Windows environment.
(dotnet test and VS Test Explorer)

@neuecc
Copy link
Member

neuecc commented Feb 6, 2025

Could it be an environment issue when downloading with git?
The strings output by the Source Generator contain a mix of raw string literals and WriteLine, so depending on the build environment, they could become mixed.
There's almost no practical harm so I left it alone, but maybe we should normalize it before output.

@filzrev
Copy link
Contributor Author

filzrev commented Feb 6, 2025

Could it be an environment issue when downloading with git?

I'm using core.autocrlf=false git settings.
So raw string literals string using LF newline char.

I thought CRLF is appended StringBuilder (that use Environment.NewLine).

There's almost no practical harm so I left it alone, but maybe we should normalize it before output.

Yes. it works on almost use case (console output). So not a high priority issue. (Except for unit tests)

@filzrev
Copy link
Contributor Author

filzrev commented Feb 7, 2025

Currently it seems unit test failed on following cases.

  • On Windows and checkout code with git core.autocrlf = false settings. And run tests.
  • On Windows and checkout code with git core.autocrlf = true settings. And run tests on WSL2 environment.

To support above environments.
It needs following code fixes.

  1. Normalize SourceGenerator's output with ReplaceLineEndings fallback logics.
  2. Normalize unittest's Raw String Literals string with ReplaceLineEndings method.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants