Skip to content

feat(editorconfig): add support for insert_final_newline - #1764

Closed
cybercyst wants to merge 1 commit into
belav:mainfrom
cybercyst:floomis/feat/add-support-for-insert-final-newline-editorconfig
Closed

feat(editorconfig): add support for insert_final_newline#1764
cybercyst wants to merge 1 commit into
belav:mainfrom
cybercyst:floomis/feat/add-support-for-insert-final-newline-editorconfig

Conversation

@cybercyst

Copy link
Copy Markdown

Currently csharpier insists in always adding a new line.

I found that there are existing issues that have been closed regarding this:

Currently this causes a bit of problems in my workflow. The organization I work for sets .editorconfig with insert_final_newline set to false. This causes my PRs to often fail when linting is run, as dotnet format respects the .editorconfig file, and since the files have newlines, dotnet format --verify-no-changes fails.

I personally agree that we should have newlines, but I'm not in a position to change how the orginization I work for sets their configurations.

@cybercyst
cybercyst force-pushed the floomis/feat/add-support-for-insert-final-newline-editorconfig branch from 1bb7dad to 06dae66 Compare November 28, 2025 20:12
@belav

belav commented Nov 28, 2025

Copy link
Copy Markdown
Owner

CSharpier is not going to support this option. You are welcome to fork it if you can't convince your organization to change.

@belav belav closed this Nov 28, 2025
@cybercyst

Copy link
Copy Markdown
Author

I'm disappointed, but thanks for reviewing! Also thanks for Csharpier. It is an incredibly useful tool!

}

return "\n";
var fileHasClrfEnding = code.Contains("\r\n");

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

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

I believe the reason the old code is the way it is - this version is cleaner, but in a case with a file that does not have \r\n this will search the entire file. The current version of the code should only search the first line of text.

@belav

belav commented Dec 2, 2025

Copy link
Copy Markdown
Owner

Thanks for being understanding! I was going to adopt the one change I commented on just now but then realized why the code is the way it is.

@robv8r

robv8r commented Jul 5, 2026

Copy link
Copy Markdown

CSharpier is not going to support this option. You are welcome to fork it if you can't convince your organization to change.

May I please ask why? I'm honestly curious and don't want to miss a learning opportunity.

Just to recap

If I correctly understand the intent of the PR, the author would like CSharpier to support the following .editorconfig snippet and remove any trailing newlines from XML files:

[*.xml]
insert_final_newline = false

If I correctly understand the above quoted response, CSharpier is not going to support the above option.

Questions

  • Is the above snippet not a recommended approach? If so, why?
  • Is there a different reason CSharpier chose not to support xml files "without final new lines"
  • Is there a different way of accomplishing this? (Supporting XML files "without final new lines")

Thanks
--rob

@belav

belav commented Jul 6, 2026

Copy link
Copy Markdown
Owner

@robv8r

CSharpier ends all files with a single new line. It is a standard practice - https://www.google.com/search?q=why+should+I+end+a+file+with+one+new+line

CSharpier will not add any options beyond the few that it already has. If someone doesn't like the way it does things they are welcome to fork it or not use it.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants