Skip to content

Commit a4bbc38

Browse files
committed
fix
1 parent cd530a8 commit a4bbc38

File tree

2 files changed

+13
-0
lines changed

2 files changed

+13
-0
lines changed

src/Analyzers/CSharp/Analysis/ImplementExceptionConstructorsAnalyzer.cs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -67,6 +67,9 @@ private static void AnalyzeNamedType(SymbolAnalysisContext context, INamedTypeSy
6767

6868
var classDeclaration = (ClassDeclarationSyntax)symbol.GetSyntax(context.CancellationToken);
6969

70+
if (classDeclaration.ParameterList is not null)
71+
return;
72+
7073
DiagnosticHelpers.ReportDiagnostic(context, DiagnosticRules.ImplementExceptionConstructors, classDeclaration.Identifier);
7174
}
7275

src/Tests/Analyzers.Tests/RCS1194ImplementExceptionConstructorsTests.cs

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,16 @@ public C(string message, Exception innerException) : base(message, innerExceptio
3838
{
3939
}
4040
}
41+
");
42+
}
43+
44+
[Fact, Trait(Traits.Analyzer, DiagnosticIdentifiers.ImplementExceptionConstructors)]
45+
public async Task Test_PrimaryConstructor()
46+
{
47+
await VerifyNoDiagnosticAsync(@"
48+
using System;
49+
50+
class MyException (string message) : Exception(message);
4151
");
4252
}
4353
}

0 commit comments

Comments
 (0)