From c0f6258bb7e6240cf6871d8611d02e6196f5c63b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Sven=20H=C3=BCbner?= Date: Mon, 1 Aug 2022 06:11:37 +0200 Subject: [PATCH] add severity configuration to README --- README.md | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/README.md b/README.md index 5b19200..2e3fb9c 100644 --- a/README.md +++ b/README.md @@ -45,6 +45,24 @@ It will just do The Right Thing™. See the test samples for [switch statement](https://github.com/shuebner/ClosedTypeHierarchyDiagnosticSuppressor/blob/main/ClosedTypeHierarchyDiagnosticSuppressor.Tests/SwitchStatementSuppressorTests.cs) and [switch expression](https://github.com/shuebner/ClosedTypeHierarchyDiagnosticSuppressor/blob/main/ClosedTypeHierarchyDiagnosticSuppressor.Tests/SwitchExpressionSuppressorTests.cs) to see what is supported. I may add more documentation and examples in this README soon. +## Treating non-exhaustive switches as errors + +In your project, enable IDE0010 (for switch statements) and IDE0072 (for switch expressions, not strictly necessary because we have CS8509 anyway) like this: +```csproj + + + true + +``` + +In your `.editorconfig` configure the severity of the exhaustiveness diagnostics: +``` +[*.cs] +dotnet_diagnostic.IDE0010.severity = error +dotnet_diagnostic.IDE0072.severity = error +dotnet_diagnostic.CS8509.severity = error +``` + # Development Experience If you set diagnostic severity to error for diagnostics that may be suppressed by a diagnostic suppressor like this one, you may have to take additional action for a good development experience.