From 69a630821a7ede8d254f5e7dd099c0a9ad427322 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?G=C3=A9rald=20Barr=C3=A9?= Date: Tue, 26 May 2026 20:44:36 -0400 Subject: [PATCH] Enable MA0192 by default as suggestion Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> --- README.md | 2 +- docs/README.md | 4 ++-- docs/Rules/MA0192.md | 8 -------- .../configuration/default.editorconfig | 2 +- src/Meziantou.Analyzer/Rules/UseHasFlagMethodAnalyzer.cs | 2 +- 5 files changed, 5 insertions(+), 13 deletions(-) diff --git a/README.md b/README.md index 71e1f443..14973ea2 100755 --- a/README.md +++ b/README.md @@ -210,7 +210,7 @@ If you are already using other analyzers, you can check [which rules are duplica |[MA0189](https://github.com/meziantou/Meziantou.Analyzer/blob/main/docs/Rules/MA0189.md)|Design|Use InlineArray instead of fixed-size buffers|ℹ️|✔️|✔️| |[MA0190](https://github.com/meziantou/Meziantou.Analyzer/blob/main/docs/Rules/MA0190.md)|Design|Use partial property instead of partial method for GeneratedRegex|ℹ️|✔️|✔️| |[MA0191](https://github.com/meziantou/Meziantou.Analyzer/blob/main/docs/Rules/MA0191.md)|Design|Do not use the null-forgiving operator|⚠️|❌|❌| -|[MA0192](https://github.com/meziantou/Meziantou.Analyzer/blob/main/docs/Rules/MA0192.md)|Usage|Use HasFlag instead of bitwise checks|ℹ️|❌|✔️| +|[MA0192](https://github.com/meziantou/Meziantou.Analyzer/blob/main/docs/Rules/MA0192.md)|Usage|Use HasFlag instead of bitwise checks|ℹ️|✔️|✔️| |[MA0193](https://github.com/meziantou/Meziantou.Analyzer/blob/main/docs/Rules/MA0193.md)|Usage|Use an overload with a MidpointRounding argument|ℹ️|✔️|✔️| |[MA0194](https://github.com/meziantou/Meziantou.Analyzer/blob/main/docs/Rules/MA0194.md)|Usage|Merge is expressions on the same value|ℹ️|✔️|✔️| |[MA0195](https://github.com/meziantou/Meziantou.Analyzer/blob/main/docs/Rules/MA0195.md)|Usage|Do not use static fields before they are initialized|⚠️|✔️|❌| diff --git a/docs/README.md b/docs/README.md index 7f1ac787..eba0b082 100755 --- a/docs/README.md +++ b/docs/README.md @@ -190,7 +190,7 @@ |[MA0189](https://github.com/meziantou/Meziantou.Analyzer/blob/main/docs/Rules/MA0189.md)|Design|Use InlineArray instead of fixed-size buffers|ℹ️|✔️|✔️| |[MA0190](https://github.com/meziantou/Meziantou.Analyzer/blob/main/docs/Rules/MA0190.md)|Design|Use partial property instead of partial method for GeneratedRegex|ℹ️|✔️|✔️| |[MA0191](https://github.com/meziantou/Meziantou.Analyzer/blob/main/docs/Rules/MA0191.md)|Design|Do not use the null-forgiving operator|⚠️|❌|❌| -|[MA0192](https://github.com/meziantou/Meziantou.Analyzer/blob/main/docs/Rules/MA0192.md)|Usage|Use HasFlag instead of bitwise checks|ℹ️|❌|✔️| +|[MA0192](https://github.com/meziantou/Meziantou.Analyzer/blob/main/docs/Rules/MA0192.md)|Usage|Use HasFlag instead of bitwise checks|ℹ️|✔️|✔️| |[MA0193](https://github.com/meziantou/Meziantou.Analyzer/blob/main/docs/Rules/MA0193.md)|Usage|Use an overload with a MidpointRounding argument|ℹ️|✔️|✔️| |[MA0194](https://github.com/meziantou/Meziantou.Analyzer/blob/main/docs/Rules/MA0194.md)|Usage|Merge is expressions on the same value|ℹ️|✔️|✔️| |[MA0195](https://github.com/meziantou/Meziantou.Analyzer/blob/main/docs/Rules/MA0195.md)|Usage|Do not use static fields before they are initialized|⚠️|✔️|❌| @@ -788,7 +788,7 @@ dotnet_diagnostic.MA0190.severity = suggestion dotnet_diagnostic.MA0191.severity = none # MA0192: Use HasFlag instead of bitwise checks -dotnet_diagnostic.MA0192.severity = none +dotnet_diagnostic.MA0192.severity = suggestion # MA0193: Use an overload with a MidpointRounding argument dotnet_diagnostic.MA0193.severity = suggestion diff --git a/docs/Rules/MA0192.md b/docs/Rules/MA0192.md index cdffb96a..eaaa14c2 100644 --- a/docs/Rules/MA0192.md +++ b/docs/Rules/MA0192.md @@ -53,11 +53,3 @@ bool M(MyEnum value) return value.HasFlag(MyEnum.Flag1); } ```` - -## Configuration - -This rule is disabled by default. To enable it, add the following to your `.editorconfig` file: - -````editorconfig -dotnet_diagnostic.MA0192.severity = suggestion -```` diff --git a/src/Meziantou.Analyzer.Pack/configuration/default.editorconfig b/src/Meziantou.Analyzer.Pack/configuration/default.editorconfig index e631a31b..27441c4b 100644 --- a/src/Meziantou.Analyzer.Pack/configuration/default.editorconfig +++ b/src/Meziantou.Analyzer.Pack/configuration/default.editorconfig @@ -570,7 +570,7 @@ dotnet_diagnostic.MA0190.severity = suggestion dotnet_diagnostic.MA0191.severity = none # MA0192: Use HasFlag instead of bitwise checks -dotnet_diagnostic.MA0192.severity = none +dotnet_diagnostic.MA0192.severity = suggestion # MA0193: Use an overload with a MidpointRounding argument dotnet_diagnostic.MA0193.severity = suggestion diff --git a/src/Meziantou.Analyzer/Rules/UseHasFlagMethodAnalyzer.cs b/src/Meziantou.Analyzer/Rules/UseHasFlagMethodAnalyzer.cs index a42e33df..6d25940f 100644 --- a/src/Meziantou.Analyzer/Rules/UseHasFlagMethodAnalyzer.cs +++ b/src/Meziantou.Analyzer/Rules/UseHasFlagMethodAnalyzer.cs @@ -17,7 +17,7 @@ public sealed class UseHasFlagMethodAnalyzer : DiagnosticAnalyzer messageFormat: "Use HasFlag instead of bitwise checks", RuleCategories.Usage, DiagnosticSeverity.Info, - isEnabledByDefault: false, + isEnabledByDefault: true, description: "", helpLinkUri: RuleIdentifiers.GetHelpUri(RuleIdentifiers.UseHasFlagMethod));