Skip to content

[9.0] Fix line endings #115413

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

Merged

Conversation

richlander
Copy link
Member

@richlander richlander commented May 8, 2025

  • Bad line endings got into the repo.
  • This creates a unix-style enlistment more challenging to use (git reset --hard doesn't work)
  • Similar to: Fix line ending #114171.

Before this change:

$ git ls-files --eol | grep '\.cs' | grep crlf
i/crlf  w/crlf  attr/text               src/libraries/System.Runtime.Loader/tests/ApplyUpdate/System.Reflection.Metadata.ApplyUpdate.Test.IncreaseMetadataRowSize/IncreaseMetadataRowSize.cs
i/crlf  w/crlf  attr/text               src/libraries/System.Runtime.Loader/tests/ApplyUpdate/System.Reflection.Metadata.ApplyUpdate.Test.IncreaseMetadataRowSize/IncreaseMetadataRowSize_v1.cs
i/crlf  w/crlf  attr/text               src/libraries/System.Runtime.Loader/tests/ApplyUpdate/System.Reflection.Metadata.ApplyUpdate.Test.IncreaseMetadataRowSize/System.Reflection.Metadata.ApplyUpdate.Test.IncreaseMetadataRowSize.csproj

After this change:

$ git ls-files --eol | grep '\.cs' | grep crlf
$

Perhaps this line is wrong?

https://github.com/dotnet/runtime/blob/8ac2c2877ce98d9b28949a3beb717524b5e6e31b/.gitattributes#L30C1-L30C22

Should it be changed to the following?

*.cs text eol=lf diff=csharp

@Copilot Copilot AI review requested due to automatic review settings May 8, 2025 22:01
Copy link
Contributor

@Copilot Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

This PR fixes inconsistent line endings that caused issues for Unix-style enlistments. The changes normalize line endings across several test project files.

  • Updated the .csproj file for ApplyUpdate tests.
  • Normalized line endings in IncreaseMetadataRowSize_v1.cs and IncreaseMetadataRowSize.cs.

Reviewed Changes

Copilot reviewed 3 out of 3 changed files in this pull request and generated no comments.

File Description
System.Reflection.Metadata.ApplyUpdate.Test.IncreaseMetadataRowSize.csproj Adjusted line endings to Unix-style formatting.
IncreaseMetadataRowSize_v1.cs Normalized line endings and preserved code logic/formatting.
IncreaseMetadataRowSize.cs Normalized line endings with no functional changes.

@tomap
Copy link

tomap commented May 9, 2025

Also, the .EditorConfig does not specify the line ending for most files:
https://github.com/dotnet/runtime/blob/release/9.0-staging/.editorconfig#L189

@richlander
Copy link
Member Author

Good point. Let's merge these PRs as-is and then develop a new standard for these configuration files to force LF that can be used as a pattern in other repos. Is there someone who can volunteer to do that?

This isn't the first case I've seen of line ending confusion. It suspect most people are using Windows so they don't notice this.

@vcsjones
Copy link
Member

vcsjones commented May 9, 2025

This looks familiar, and was in #114190 (comment)

But I think that was only fixed for main, not 9.0.

Ultimately, some people have configured their git client to do disable auto crlf and that made its way in. It doesn't matter what gitattributes is set to.

@richlander
Copy link
Member Author

That doesn't stop us from having good configuration and documenting the preferred client config, right?

@vcsjones
Copy link
Member

vcsjones commented May 9, 2025

Should it be changed to the following?
*.cs text eol=lf diff=csharp

That means you would be checking out files locally on Windows with LF, not CRLF line endings and I think that would massively confuse folks that checkout the runtime on Windows.

Also, the .EditorConfig does not specify the line ending for most files:

Likewise, that would be forcing one OS's line ending opinions on another. Changing the editorconfig to LF would mean Windows would prefer using LF locally.

@jkotas
Copy link
Member

jkotas commented May 9, 2025

That doesn't stop us from having good configuration and documenting the preferred client config, right?

We used to have a section in the documentation that talked about how to clone a repo, but we dropped it since it is github 101 topic that is covered much better elsewhere.

Our .gitattributes is setup to make the default git client config to do the right thing. You do not need to worry about line endings if you use vanilla git workflow.

For mistakes like this to happen, one has to use advanced custom configs, like running multiple OSes side-by-side with shared file system or manually copying files between different OSes.

Copy link
Contributor

Tagging subscribers to this area: @dotnet/runtime-infrastructure
See info in area-owners.md if you want to be subscribed.

@jkotas
Copy link
Member

jkotas commented May 9, 2025

Tell mode

@jkotas jkotas added the Servicing-approved Approved for servicing release label May 9, 2025
@jkotas jkotas merged commit be7fae0 into dotnet:release/9.0-staging May 9, 2025
22 of 26 checks passed
@github-actions github-actions bot locked and limited conversation to collaborators Jun 9, 2025
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
area-Infrastructure Servicing-approved Approved for servicing release
Projects
Status: Done
Development

Successfully merging this pull request may close these issues.

5 participants