Skip to content

Commit 9ca3fed

Browse files
Add descriptions to diagnostics
1 parent 4c6ba32 commit 9ca3fed

File tree

1 file changed

+12
-6
lines changed

1 file changed

+12
-6
lines changed

CheckedExceptions/CheckedExceptionsAnalyzer.cs

Lines changed: 12 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -35,39 +35,44 @@ public partial class CheckedExceptionsAnalyzer : DiagnosticAnalyzer
3535
"Exception '{0}' {1} thrown but not handled",
3636
"Usage",
3737
DiagnosticSeverity.Warning,
38-
isEnabledByDefault: true);
38+
isEnabledByDefault: true,
39+
description: "Reports exceptions that are thrown but not caught or declared with [Throws], potentially violating exception safety.");
3940

4041
private static readonly DiagnosticDescriptor RuleIgnoredException = new DiagnosticDescriptor(
4142
DiagnosticIdIgnoredException,
4243
"Ignored exception may cause runtime issues",
4344
"Exception '{0}' is ignored by configuration but may cause runtime issues if unhandled",
4445
"Usage",
4546
DiagnosticSeverity.Info,
46-
isEnabledByDefault: true);
47+
isEnabledByDefault: true,
48+
description: "Informs about exceptions excluded from analysis but which may still propagate at runtime if not properly handled.");
4749

4850
private static readonly DiagnosticDescriptor RuleGeneralThrow = new(
4951
DiagnosticIdGeneralThrow,
5052
"Avoid throwing 'Exception'",
5153
"Throwing 'Exception' is too general; use a more specific exception type instead",
5254
"Usage",
5355
DiagnosticSeverity.Warning,
54-
isEnabledByDefault: true);
56+
isEnabledByDefault: true,
57+
description: "Discourages throwing the base System.Exception type directly, encouraging clearer and more actionable error semantics.");
5558

5659
private static readonly DiagnosticDescriptor RuleGeneralThrows = new DiagnosticDescriptor(
5760
DiagnosticIdGeneralThrows,
5861
"Avoid declaring exception type 'Exception'",
5962
"Declaring 'Exception' is too general; use a more specific exception type instead",
6063
"Usage",
6164
DiagnosticSeverity.Warning,
62-
isEnabledByDefault: true);
65+
isEnabledByDefault: true,
66+
description: "Discourages the use of System.Exception in [Throws] attributes. Prefer declaring more specific exception types.");
6367

6468
private static readonly DiagnosticDescriptor RuleDuplicateDeclarations = new DiagnosticDescriptor(
6569
DiagnosticIdDuplicateDeclarations,
6670
"Avoid duplicate declarations of the same exception type",
6771
"Duplicate declarations of the exception type '{0}' found. Remove them to avoid redundancy.",
6872
"Usage",
6973
DiagnosticSeverity.Warning,
70-
isEnabledByDefault: true);
74+
isEnabledByDefault: true,
75+
description: "Detects multiple [Throws] declarations for the same exception type on a single member, which is redundant.");
7176

7277
private static readonly DiagnosticDescriptor RuleMissingThrowsOnBaseMember = new DiagnosticDescriptor(
7378
DiagnosticIdMissingThrowsOnBaseMember,
@@ -84,7 +89,8 @@ public partial class CheckedExceptionsAnalyzer : DiagnosticAnalyzer
8489
"Base member '{0}' declares exception '{1}' which is not declared here",
8590
"Usage",
8691
DiagnosticSeverity.Warning,
87-
isEnabledByDefault: true);
92+
isEnabledByDefault: true,
93+
description: "Ensures that overridden or implemented members declare exceptions required by their base or interface definitions.");
8894

8995
public override ImmutableArray<DiagnosticDescriptor> SupportedDiagnostics =>
9096
[RuleUnhandledException, RuleIgnoredException, RuleGeneralThrows, RuleGeneralThrow, RuleDuplicateDeclarations, RuleMissingThrowsOnBaseMember, RuleMissingThrowsFromBaseMember];

0 commit comments

Comments
 (0)