Closed Nowak-Kacper closed 6 months ago
From the whitespace errors it appears to be trying to fixup indentation by replacing characters with tabs. Is it possible there are mixed spaces and tabs? Also, are the line numbers accurate?
One more error example, maybe it will bring something new. (233,4): error WHITESPACE: Fix whitespace formatting. Replace 5 characters with '\n\t\t\t'. (234,14): error WHITESPACE: Fix whitespace formatting. Replace 5 characters with '\n\t\t\t'. (242,47): error WHITESPACE: Fix whitespace formatting. Replace 7 characters with '\n\n\t\t\t'. (244,10): error WHITESPACE: Fix whitespace formatting. Replace 5 characters with '\n\t\t\t'. (246,44): error WHITESPACE: Fix whitespace formatting. Replace 7 characters with '\n\n\t\t\t'. (248,13): error WHITESPACE: Fix whitespace formatting. Replace 5 characters with '\n\t\t\t'. In file all indents are ok, locally i can not reproduce this error.
Declare files that will always have CRLF line endings on checkout. */.cs text eol=crlf
So we are always checking these files out with windows line endings. Does your .editorconfig also specify end_of_line=crlf
for *.cs files? Otherwise, the formatter will default to the platform specific line ending.
Currently not, previously I had it but there was more errors than now, should I bring it back? If yes, how should I update some files on git to crlf format? By running git ls-files --eol
I see some files are in lf.
I tried to run git add --renormalize .
with eol set to crlf in .gitattributes and .editorcong but it overwrites only files in crlf format, and seems to be ignoring the lf files.
how should I update some files on git to crlf format?
You can try these steps https://docs.github.com/en/get-started/getting-started-with-git/configuring-git-to-handle-line-endings#refreshing-a-repository-after-changing-line-endings
Already done this, just to be sure I did it again today, but some files are still in lf format.
Part of output from git ls-files --eol
i/mixed w/crlf attr/
i/crlf w/crlf attr/
i/crlf w/crlf attr/
i/mixed w/crlf attr/
i/crlf w/crlf attr/
i/lf w/crlf attr/
i/lf w/crlf attr/
i/lf w/crlf attr/
i/crlf w/crlf attr/
i/lf w/crlf attr/
i/lf w/crlf attr/
i/lf w/crlf attr/
i/crlf w/crlf attr/
i/lf w/crlf attr/
i/lf w/crlf attr/
i/crlf w/crlf attr/
Not saying this is the issue, just something I noticed after looking at a few .gitattributes files (see https://grep.app/search?q=.cs+text+eol). You could simplify yours by removing the directory separators.
# Set the default behavior, in case people don't have core.autocrlf set.
- */ text=auto
+ * text=auto
# Declare files that will always have CRLF line endings on checkout.
- **/*.cs text eol=crlf
+ *.cs text eol=crlf
Not sure how much more help I can be. In the absence of an end_of_line settings in the .editorconfig, dotnet-format will default to using the environment newline for line endings, which may not match your .gitattributes configuration. So, if you are not letting git automatically handle line endings you will want to configure your .editorconfig to match.
Also note that you want to make this change:
-*.cs text eol=crlf
+*.cs text=auto eol=crlf
⚠️ I would not recommend setting eol
in .gitattributes or end_of_line
.editorconfig. These lines are an immediate configuration red flag for me.
Closing this issue as we've seen no reply to the request for more information. If you are able to get the requested information, please add it to the issue and we will retriage it.
Also note that you want to make this change:
-*.cs text eol=crlf +*.cs text=auto eol=crlf
⚠️ I would not recommend setting
eol
in .gitattributes orend_of_line
.editorconfig. These lines are an immediate configuration red flag for me.
Can you provide an example of your preferred configuration? sharwell
Hi everyone, as in title dotnet format whitespace --verify-no-changes fails in lines where "/" char is. I am running command with git workflow so it might be related to this.
Error: Program.cs(6,3): error WHITESPACE: Fix whitespace formatting. Replace 4 characters with '\n\t\t'. Program.cs(12,1): error WHITESPACE: Fix whitespace formatting. Replace 2 characters with '\t\t'.
This is the content of my .gitattributes file: