apm-agent-dotnet icon indicating copy to clipboard operation
apm-agent-dotnet copied to clipboard

dotnet format creates different line endings on Windows vs Linux (and macOS)

Open gregkalapos opened this issue 4 years ago • 3 comments

More details on the original problem: https://github.com/elastic/apm-agent-dotnet/pull/560#issuecomment-543239630

Turned out that we had some files with windows style line ending (CRLF) and some with linux/macOS style ending (LF). My theory is that this triggered the bug above described in the comment which is that dotnet format on macOS and Linux mixed line endings within a single file - so prior to dotnet format we had different files with different line endings, now we have different line endings within a single file.

After changing all line endings to LF in the whole repo the dotnet format bug went away. In #566 everything is LF and running dotnet format on macOS, Linux, and Windows does not reformat anything and our code style check command also passes.

gregkalapos avatar Oct 17 '19 16:10 gregkalapos

~~I'm having this bug too. I just added this to my CI (Drone) and experienced the same results.~~

DefinitelyADev avatar Oct 23 '20 19:10 DefinitelyADev

Correction the issue I witnessed was also related to git pulling the repo with LF file endings in windows. The issue was fixed by changing end_of_line to lf in the .editorconfig file, running the tool and pushing. But there should be a parameter or to at least have consistent line endings and not a specific one.

DefinitelyADev avatar Oct 26 '20 18:10 DefinitelyADev

It behaves similarly on Windows in files with LF line endings, when the file has CRLF it's without a problem, but when the file has LF then often after running dotnet format it gets the mixed line endings. Not every file, but it's consistent, when some file has this issue, it gets the mixed line endings every time I run dotnet format.

david-sevcik avatar May 23 '22 19:05 david-sevcik