-
Notifications
You must be signed in to change notification settings - Fork 510
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
SA1518 fails whether there is a newline character or not #3887
Comments
The init script fails for me (something with "yarn"), so I haven't been able to try it properly. But I notice that the Error List tab points to different projects in your two screenshots. Seems like the CodeFixes project gets the wrong stylecop settings for some reason and the AssemblyInfo file is shared by many projects. |
Very good eye. :) I hadn't noticed that. I have only one Stylecop.json in my whole repo, and all relevant projects get it. And it has no policy regarding file endings either. Command line build produces no warnings. |
If the stylecop.json doesn't set "newlineAtEndOfFile", then we default to using the "insert_final_newline" setting, which you have in your top .editorconfig file. This means that SA1518 should behave as if you had newlineAtEndOfFile set to "require" in your stylecop.json file. And it seems to do so for all projets except CodeFixes. I don't see exactly the same behavior as you, but it is similar. I can't get SA1518 to trigger at all in the CodeFixes project, regardless of AssemblyInfo has a new line at the end or not. I managed to debug a stripped down version of your repo yesterday and saw that the correct value was not received when trying to read "insert_final_newline". If I remove the AssemblyInfo link and add another file without newline, SA1518 triggers in that file. If I add AssemblyInfo back again, it doesn't trigger in any of the files. At this point, I am inclined to blaim Roslyn, but I will try to dig a little bit more. |
@AArnott I see you are using Visual Studio Preview. When I open the same solution in VS 17.11.3, this problem doesn't occur. In fact, now I don't see a warning when a new line is missing at the end. |
I still experience the same thing in VS 17.11.3 and could reproduce it outside StyleCop.Analyzers, so I created an issue in the Roslyn repo. |
StyleCop.Analyzers: 1.2.0.556
SA1518 is claiming exactly one code file in my solution is not allowed to end with a newline character.
This is odd in itself, because I have a policy that all code files should end with a newline character, so I don't know why this file is not allowed to:
Even more confusing is that "correcting" this by removing the newline character produces the same diagnostic but with a contrary message, saying I must end the file with a newline character:
Repro:
Then open the
src\AssemblyInfo.cs
file.The text was updated successfully, but these errors were encountered: