What I like about the dotnet
CLI is that you can run $ dotnet build --no-incremental
, and you always get a list of all the warnings in your project. I use that for making sweeping changes, and such, on projects. Output of that can be piped to unix tools, for further processing.
I'd like to also get that for the 'suggestions' that you get in Visual Studio. Is that possible, and how?
What I mean by suggestions are the "messages" you get in the "Error List..." in Visual Studio (see below). The compiler calls this "Information that does not indicate a problem" (DiagnosticSeverity.Info
), EditorConfig calls these suggestions (EditorConfigSeverityStrings.Suggestion
).
A minimal reproduction for this, is to create a new console application, and add a new class with a private field, but don't make it readonly
(see below)! This will trigger IDE044
(as in the screenshot), but it won't show up when running $ dotnet build --no-incremental
. If you override the severity via the .editorconfig
file, then the suggestion does show up, but obviously as warning.
public class Class1
{
private string Foo = "bar";
}
.editorconfig
[*.cs]
# IDE0044: Add readonly modifier
dotnet_diagnostic.IDE0044.severity = warning
I'm looking for something "out of the box", so something like $ dotnet build ...
. However, if that's not possible, I'd be fine to use a 3rd party global tool, like the Roslynator Command-Line Interface (I did try that path, but didn't manage to get that to work).
I'm well aware that you could write a custom tool, on top of the Roslyn API, but I think that's quite brittle, as you need to cater for all the intricacies of package restore, finding MSBuild, and so on. I think this is really something that should be available out of the box, or otherwise deserves an issues on a project upstream.
I don't know it that works out to you, but you can use the ErrorLog
property on the project to output all diagnostics to a SARIF file.