Clean up whitespace related issues in entire project #126
Add this suggestion to a batch that can be applied as a single commit. This suggestion is invalid because no changes were made to the code. Suggestions cannot be applied while the pull request is closed. Suggestions cannot be applied while viewing a subset of changes. Only one suggestion per line can be applied in a batch. Add this suggestion to a batch that can be applied as a single commit. Applying suggestions on deleted lines is not supported. You must change the existing code in this line in order to create a valid suggestion. Outdated suggestions cannot be applied. This suggestion has been applied or marked resolved. Suggestions cannot be applied from pending reviews. Suggestions cannot be applied on multi-line comments. Suggestions cannot be applied while the pull request is queued to merge. Suggestion cannot be applied right now. Please check back later.
When merged, this pull request will clean up all text files. It removes trailing whitespace, converts line endings to LF, adds a .gitattribute file and improves the existing .editorconfig file.
The reason to remove unneeded whitespace is to avoid confusing diffs and merge conflicts. Many modern and popular text editors remove trailing whitespace automatically. If 2 or more contributors submit PRs that edit the same file (e. g. 2 code examples for one chapter, both editing the .md), their editors could both automatically trim the whitespace, resulting in merge conflicts down the line.
During the cleanup process, I noticed that all C# source files have been commited with CRLF (Windows) line endings, rather than LF like all other files in the repository. The files also have a UTF-8 Byte Order Mark (BOM), which is generally discouraged. According to The Unicode Standard - 2.6 Encoding Schemes:
Therefore, I converted the files to have LF line endings for consistency and removed their BOMs. I also added a .gitignore file with a rule that should force .cs files to always have LF line endings in the repository.
Lastly, I edited the existing .editorconfig file to account for more file types.