Skip to content
This repository has been archived by the owner on Dec 21, 2023. It is now read-only.

Format C# files with spaces and POSIX compliance #52

Merged
merged 2 commits into from
Apr 20, 2021

Conversation

aaronfranke
Copy link
Contributor

This PR is split into 3 commits:

  • The first commit formats C# files for POSIX compliance, with a newline at EOF and correct line endings. This improves compatibility with tools that expect POSIX compliance, and GitHub shows a "No newline at end of file" warning if the newline at EOF is missing. Additionally, some tools will automatically fix these problems (I have my editors configured for this when possible), so this makes it easier to use those tools on this project without generating diffs. In this commit I also added a .gitattributes file so that Git should automatically fix line ending problems in the future.

  • The second commit replaces tabs with 4 spaces. The C# indent style is to use 4 spaces, plus the .editorconfig already says to do this, but some files were using tabs, or had an inconsistent style. For example, I see this if I open src/Microsoft.Maui.Graphics/Color.cs on GitHub configured to show tabs as 8 characters wide:

Screenshot from 2021-04-03 14-58-23

  • The third commit removes trailing space characters. Trailing space characters do nothing and should be deleted. Also, as with the first commit, when possible I have my editors configured to delete trailing whitespace, so this makes it easier to use those tools on this project without generating diffs.

I considered opening an issue first, but I figured it was easier to just open a pull request. There is already a .editorconfig that says to use spaces, so I know it's desired, yet many files in this repo aren't doing that.

I didn't format non-.cs files in this PR, since .cs files are the bulk of this repo, it makes sense to do the .cs ones separately from the rest. I can format other files in a future PR if desired.

@rmarinho
Copy link
Member

we use tabs not spaces :)

@aaronfranke
Copy link
Contributor Author

@rmarinho Then the .editorconfig should be updated, and the files that use spaces should be converted to tabs. I can do this if the project maintainers say it's desired.

@jonlipsky
Copy link
Contributor

@aaronfranke If would be great if you'd like to contribute that change to the .editorconfig file.

@aaronfranke aaronfranke force-pushed the format branch 3 times, most recently from 7c2cb70 to 2f98f9d Compare April 16, 2021 21:16
@aaronfranke
Copy link
Contributor Author

@jonlipsky Done.

@jonlipsky
Copy link
Contributor

@aaronfranke I took another PR before yours, so now there are some conflicts. Care to resolve the conflicts so I can get your contribution in ASAP?

@aaronfranke aaronfranke force-pushed the format branch 2 times, most recently from eb28f84 to cbbe2fd Compare April 20, 2021 21:08
@aaronfranke
Copy link
Contributor Author

@jonlipsky Done.

Copy link
Contributor

@jonlipsky jonlipsky left a comment

Choose a reason for hiding this comment

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

Thanks so much for this!

@jonlipsky jonlipsky merged commit 0e9a4cd into dotnet:main Apr 20, 2021
@aaronfranke aaronfranke deleted the format branch April 20, 2021 23:49
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants