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

editorconfig: Remove unnecessary rules #433

Closed
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 0 additions & 14 deletions .editorconfig
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,6 @@ root = true
charset = utf-8
indent_style = space
indent_size = 4
end_of_line = crlf
trim_trailing_whitespace = true
insert_final_newline = true
csharp_using_directive_placement = outside_namespace:silent
csharp_prefer_simple_using_statement = true:suggestion
csharp_prefer_braces = true:silent
Expand All @@ -20,24 +17,13 @@ csharp_style_expression_bodied_constructors = false:silent
csharp_style_expression_bodied_operators = false:silent
csharp_indent_labels = one_less_than_current

[*.sln]
indent_style = tab

# Xml project files
[*.{config,csproj,njsproj,targets,vcxitems,vcxproj,vcxproj.filters}]
indent_size = 2
end_of_line = crlf
insert_final_newline = false
Copy link
Collaborator

Choose a reason for hiding this comment

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

This will cause EditorConfig-enabled editors to insert a newline, where Visual Studio trims such newlines when modifying those types of files.

It will cause on and off final newline diffs depending on what tool was used to edit such files.

I strongly recommend to keep this one.
To reiterate, it's not about the VS templates only, but the IDE's editing behavior.

Copy link
Collaborator Author

@softworkz softworkz Aug 31, 2024

Choose a reason for hiding this comment

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

his will cause EditorConfig-enabled editors to insert a newline

No, this is not true. If no rule exists for this in editorconfig, then it's the editor's default behavior coming into play. For most editors it's based on auto-detection or defaults of the editor. The editorconfig spec defines no default for this type of rule, so having no rule at all is the most compatible setting.

where Visual Studio trims such newlines when modifying those types of files.

VS doesn't trim. It handles mixed line endings transparently without modifying. Only when adding new lines it will choose a line ending style (from auto-detection or VS options settings).

It will cause on and off final newline diffs depending on what tool was used to edit such files.

No. If this rule isn't present, an editor normally doesn't make any change to it. (VS doesn't)

Copy link
Member

Choose a reason for hiding this comment

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

I think this remark is not about EOL, but about insert_final_newline (newline at end of file). It might be good to keep it as @JunielKatarn suggested.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

If the remark is about newlines at the end of files, then the statement is still incorrect. Visual Studio does not trim any CR or LF at the end of files when editing.

VS leaves everything as is and that's the behavior that we need. On the contrary, the existence of those rules has caused the PR's from @JunielKatarn to include such changes to the end of files which we neither want nor need (assuming that the current state is how we want everything to be).

It's generally important to understand that removing such rules doesn't mean that the opposite would happen. Removing rather means that the editor won't make changes in that regard.

Also important: Visual Studio doesn't need any editorconfig rules at all. It works totally fine without any editorconfig in place.
It's also very unusual to have those EOL and EOF rules when using VS. Never seen that before, it's in none of the templates, nobody does that because there's no need for this in case of VS. It does these things right just out of the box.

Copy link
Member

Choose a reason for hiding this comment

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

I'd say we should leave insert_final_newline = false in. These are specific VS formats. VS never adds final new lines and removes them when found. It is safe and reasonable to leave this setting in the editorconfig, so other code editors won't accidentially insert final new lines when it is their default.


# XML config files
[*.{msbuild,props,targets,ruleset,config,nuspec}]
indent_size = 2
end_of_line = crlf
insert_final_newline = false

# Windows Shell scripts
[*.{cmd,bat,ps1}]
end_of_line = crlf

[*.{cs,vb}]
#### Naming styles ####
Expand Down