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

Extra blank line added to file each time csharpier runs on this file #1426

Closed
edyoung opened this issue Jan 3, 2025 · 3 comments · Fixed by #1427
Closed

Extra blank line added to file each time csharpier runs on this file #1426

edyoung opened this issue Jan 3, 2025 · 3 comments · Fixed by #1427
Milestone

Comments

@edyoung
Copy link

edyoung commented Jan 3, 2025

Input:

A file with a namespace, some blank lines, and a comment, eg:

test.cs:

namespace Ev2Deploy.Models.Kubernetes.ATS.PublicCloud.Regions.Canary;





//public class EUS2EUAP : CanaryRegionBase

Run dotnet csharpier test.cs

Output:

same file, with an additional blank line between namespace and comment

namespace Ev2Deploy.Models.Kubernetes.ATS.PublicCloud.Regions.Canary;






//public class EUS2EUAP : CanaryRegionBase

Rerunning csharpier again usually, but not 100%, adds another blank line, so the gap gets bigger and bigger. I think it is deterministic but there's some factor I don't quite understand which defines whether an extra line is added - CRLF vs LF maybe?

If I use the Visual Studio extension and 'reformat with csharpier' it adds an extra line every time.

Expected behavior:

I assume we'd want 1 blank line between namespace and comment.

Csharpier version 0.30.4

@belav
Copy link
Owner

belav commented Jan 3, 2025

This was fixed in #1408 which went out in 0.30.4 but if you were testing it on the playground that was still at 0.30.2 because the deploy was failing. Playground is up to date now.

Is there more in the file that is causing the issue? The logic to fix the issue is a bit of a hack and I imagine there could be other ways file ending comments cause an extra blank line.

@belav
Copy link
Owner

belav commented Jan 3, 2025

I take that back, my hack only works if the file starts with a single blank line above the comment, with your file there is more than one so it continues to add new lines.

@edyoung
Copy link
Author

edyoung commented Jan 4, 2025

Thanks a lot!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
2 participants