Skip to content

Commit 1ff1786

Browse files
authored
Fix analyzer RCS1194 (#1733)
1 parent 17226c3 commit 1ff1786

3 files changed

Lines changed: 16 additions & 0 deletions

File tree

ChangeLog.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
1010
### Fixed
1111

1212
- Fix enum contained flags check for partial matches in [RCS1258](https://josefpihrt.github.io/docs/roslynator/analyzers/RCS1258) ([PR](https://github.com/dotnet/roslynator/pull/1740) by @ovska)
13+
- Fix analyzer [RCS1194](https://josefpihrt.github.io/docs/roslynator/analyzers/RCS1194) ([PR](https://github.com/dotnet/roslynator/pull/1733))
1314

1415
## [4.15.0] - 2025-12-14
1516

src/Analyzers/CSharp/Analysis/ImplementExceptionConstructorsAnalyzer.cs

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

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

70+
#if ROSLYN_4_0
71+
if (classDeclaration.ParameterList is not null)
72+
return;
73+
#endif
74+
7075
DiagnosticHelpers.ReportDiagnostic(context, DiagnosticRules.ImplementExceptionConstructors, classDeclaration.Identifier);
7176
}
7277

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)