Is there an EditorConfig setting for simplifying boolean evaluations in if statements? e.g.
// prefer:
if (thingy)
// over:
if (thingy == true)
and
// prefer:
if (!thingy)
// over:
if (thingy == false)
Is there an EditorConfig setting for simplifying boolean evaluations in if statements? e.g.
// prefer:
if (thingy)
// over:
if (thingy == true)
and
// prefer:
if (!thingy)
// over:
if (thingy == false)
You can configure the corresponding analyzer with this in your .editorconfig:
dotnet_diagnostic.IDE0100.severity = warning
See https://learn.microsoft.com/en-us/dotnet/fundamentals/code-analysis/style-rules/ide0100
There isn't such a setting in EditorConfig. Note that EditorConfig isn't really a static analysis tool, but a configuration setting for formatting files with regard to indentation, tabs vs spaces etc.
AFAIK, there is no such built-in VS editor config. Usually, you would use either StyleCop, or Resharper and alike for code style rules and refactorings like that.
For Visual Studio one of the cleaner solutions would be to use a plugin. Personally I use Resharper.
Take a look at the Resharper plugin from Jetbrains.
https://www.jetbrains.com/resharper/
Docs on their code generation features here: https://www.jetbrains.com/resharper/features/code_generation.html
Docs on their code style and formatting features here: https://www.jetbrains.com/resharper/features/code_formatting.html
Add the .editorconfig in your solution path and if you're using VSCode, install official C# plugin. To enable .editorconfig validation just go to settings (ctrl/command + ,) > "Extensions" > "C# configuration" > Check "Omnisharp: Enable Editor Config Support". Also, make sure option "Format: Enable" is checked.
If you want to actually make build fail, you could use Microsoft.CodeAnalysis.CSharp.CodeStyle NuGet package in the project you want to validate code style. This will generate build failure if the code is not compliant to .editorconfig. More informations in about this issue.