Search code examples
visual-studioroslyneditorconfig

What's the difference between dotnet_diagnostics and equivalent rules under dotnet_style_, csharp_ etc.?


For example, in .editorconfig I can require fields to be readonly using both:

# IDE0044: Make field readonly
dotnet_diagnostic.IDE0044.severity = warning

and

dotnet_style_readonly_field = true:warning

Both will show up in the editor, both will cause the issue to be fixed upon running dotnet format. What are the differences between both options?


Solution

  • The compiler is not aware of the option = value:severity syntax, e.g:

    dotnet_style_readonly_field = true:warning
    

    So if you use that, the build will produce warnings/errors only for IDE live analysis. But if you want to enforce code-style on build, you need to use the dotnet_diagnostic.RuleId.severity = severity syntax.