-
Notifications
You must be signed in to change notification settings - Fork 4k
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
IDE information diagnostics displayed in the VS Code problems pane do not surface via dotnet build #60620
Comments
@johnnyreilly Does adding |
That removes the IDE0052 message from the Prior to .NET 6 the docs suggest this was intentional. But as of .NET 6 it ought not to be. To be clear: I'm hoping to see IDE0052 surfaced in my build output, but I do not |
@johnnyreilly Ok, I think I understand what happened in your case. Can you try The problem is very likely that you got the warning in one build, and the build was cached. So the warning doesn't appear again. You can also delete Please let me know if this fixed your problem. |
@Youssef1313 , does he also need to do a |
For me
So only one of the following should be needed:
|
I'm definitely seeing them as well with these settings. My output:
|
So I got this working! And I turned it into a blog post - as I found it quite hard to discover how to do this and was keen to make it easier for one and all! https://blog.johnnyreilly.com/2022/04/06/eslint-your-csharp-in-vs-code-with-roslyn-analyzers @Youssef1313 your point here was useful:
There is one thing that still foxes me. The Roslyn Analyzers in VS Code surface information messages like Do these information diagnostics exist in some kind of category? So in the same way that I can put this in an dotnet_analyzer_diagnostic.category-Style.severity = error And dial up style diagnostics to errors, can I do a blanket upgrade to the information diagnostics, the likes of IDE0052, IDE0090 etc to be Or is there a list somewhere of the information lints that Roslyn Analyzers surface which I could use as a reference? |
Ahh, so it was working in build, but not in the context of VSCode/OmniSharp without the OmniSharp setting. Or are you still not seeing it without any VS Code/OmniSharp in the workflow? |
So with the OmniSharp settings set, I see information diagnostics in the "problems" panel of VS Code. And I really value the information diagnostics that show up. I'd like them to show up in the build output too. However, the only way to do that now, is to spy on the information diagnostics showing up in VS Code, make a note of their code, and manually add it to the I'd like to find a way to either:
|
That is very interesting. If you look at the output in my blog post, you'll see that the https://blog.johnnyreilly.com/2022/04/06/eslint-your-csharp-in-vs-code-with-roslyn-analyzers I'll put together a reproduction repo with a devcontainer and share it when I get a moment |
Actually - that's incorrect. I'm having exactly the same experience as you, but your animated GIF moved so swiftly I misread it as surfacing the information diagnostics by default in the build. But actually you've got it dialed up to a warning as we were discussing earlier. Here's a repo repro which should allow anyone to replicate my experience: https://github.com/johnnyreilly/roslyn-analyzers-reproduction (though as I say @timheuer - it seems like we're having the same experience already) Let me restate the problem to solve as it's evolved with my understanding over the course of this thread. (and thanks all for the pointers - it's been super helpful ❤️ ) Restating the problemWhen using VS Code I experience informational diagnostics in the problems pane of VS Code. But if we run Microsoft (R) Build Engine version 17.1.0+ae57d105c for .NET
Copyright (C) Microsoft Corporation. All rights reserved.
Determining projects to restore...
All projects are up-to-date for restore.
AnalyseThis -> /workspaces/roslyn-analyzers-reproduction/bin/Debug/net6.0/AnalyseThis.dll
Build succeeded.
0 Warning(s)
0 Error(s)
Time Elapsed 00:00:08.20 This information is not present. Informational diagnostics are not surfaced in the build by default (or maybe ever?) If I added the following to my dotnet_diagnostic.IDE0052.severity = warning I could dial up each individual So there's this manual syncing effort require to spy on the information diagnostics showing up in VS Code, make a note of their codes, and manually add them to the The problem I'm trying to solve is this; I'd like to find a way to either:
|
Thanks @johnnyreilly I think this is a matter of how OmniSharp is surfacing diagnostics irrespective of |
@johnnyreilly These analyzers are not one-size fits all and it really should take some thought to turn the severity up and make it a requirement for your team. With that said,
Are you proposing a
I believe that |
Oh wow - there's so much good information here! Thank you @JoeRobich! |
Completely agree @JoeRobich - this is more about learning what's possible. So much more than I realised it turns out!
Thanks for this. I was surprised that
Upon experimenting the command is:
Essentially losing the hyphen. I've updated the blog post to include this.
Ah this is great. Essentially I didn't know about the categories of analyzers. They're documented here and I've updated the blog post to reflect this Given that IDE0052 is part of # Default severity for analyzer diagnostics with category 'CodeQuality' (escalated to build errors)
dotnet_analyzer_diagnostic.category-CodeQuality.severity = error I probably don't want to do this in general - but it's good to know what's possible.
Totally does - this is gold dust! Again I've updated the blog post to reflect. I've also credited folk in here who've provided some very useful assistance; thank you! ❤️ 🌻 |
Closing as resolved - thanks all! |
Follow on from discussion here: #6195 (comment)
6.0 (going by the SDK):
Steps to Reproduce:
dotnet new webapi -o AnalyseThis
AnalyseThis.csproj
to:Run
dotnet build
Expected Behavior:
Surface IDE messages like this in the build output:
Actual Behavior:
IDE messages not surfaced in build output:
I understand that it was previously by design that this was not surfaced, but if I read the docs correctly, things have changed. And as of .NET 6, the rules should be surfaced by
dotnet build
. However, I haven't managed to achieve that - it's possible I'm doing it wrongI took that it was desired behaviour from here: https://docs.microsoft.com/en-us/dotnet/core/project-sdk/msbuild-props#analysislevel
Maybe I'm doing something wrong? or there's a bug?
cc @JohnMarkHowell
The text was updated successfully, but these errors were encountered: