-
Notifications
You must be signed in to change notification settings - Fork 508
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
SA1516 Elements should be separated by blank line - Razor Class Library - csproj file #3738
Comments
I am having difficulty understanding what it is you want. Could you try to explain more what you experience and what it is you would like to achieve? Maybe post some screenshots and/or a link to a repo to show the problem? |
Please see screenshots below...
|
These rules/anlyzers should only execute on what the compiler thinks is c# code, so they should never fire inside csproj files. Can you provide a link to a repository where this happens? |
One hypothesis could be that Visual Studio uses the project file name in the error list if SA1516 is reported without a location. Don't know why that would happen, though. If you rebuild and look in the output view, what does it look like when the warning is reported? Can you post a part of the output? |
Regarding suppressing it, if the diagnostic is reported without a location as I speculated above, then I don't think that you can suppress those warnings without turning off the entire rule in that project. This can be done in an .editorconfig file or a ruleset file, if you would like. But this behaviour is caused by something weird, so it would be good if we could find the root cause instead, so you don't have to turn it off. |
I cannot send you the repo link due to my employers privacy rules... I agree that it would be better to fix than suppress. My mistake, its not a Razor Class Library project, its the Blazor Server project. I did recreate in a new Blazor Server .Net 7 or 8 project.
Attached is the simple recreated Blazor server app that demo's the issue. |
I made a small change to trigger SA1516 and this is what I got in the build output:
The second mention of SA1516 is the one which I caused myself. This one points to a specific file and line. The first one, which was being triggered before my change, has no location in the output. Will continue by trying to understand why this happens. |
If you want to use any newer language construct, you really should use one of the beta versions, since 1.1.118 is from 2019. |
Updating to 1.2.0-beta.507 "fixed" it, meaning the warning with the missing location disappears. There has been a number of bug reports on SA1516 related to file scoped namespaces and top-level statements. None exactly like this as far as I can see, but close enough since we seem to have fixed this case as well. Feel free to close this if upgrading works in your real project as well. |
Yes, the 1.2.0-beta.507 "fixed" it. I need to check with our architect if he will allow a beta package. Do you have an ETA of an official release of this latest beta? Thank you very much! |
Unfortunately not. See for example #3500 and #3420 (comment), but the general reasoning is that beta releases should not be a problem since this is only a development dependency. |
Duplicate of #3242 |
"SA1516 Elements should be separated by blank line" shows warnings for csproj file of a "Razor Class Library " project
This does not occur for regular Blazor project or xUnit Test project.
Cannot find a way to suppress this warning for just the csproj file and/or prevent Stylecop from firig this warning against the csproj file in a "Razor Class Library " project
The text was updated successfully, but these errors were encountered: