diff --git a/analyzers/tests/SonarAnalyzer.UnitTest/Rules/RedundancyInConstructorDestructorDeclarationTest.cs b/analyzers/tests/SonarAnalyzer.UnitTest/Rules/RedundancyInConstructorDestructorDeclarationTest.cs index 1589efedc4f..008e1cdba46 100644 --- a/analyzers/tests/SonarAnalyzer.UnitTest/Rules/RedundancyInConstructorDestructorDeclarationTest.cs +++ b/analyzers/tests/SonarAnalyzer.UnitTest/Rules/RedundancyInConstructorDestructorDeclarationTest.cs @@ -51,6 +51,12 @@ public void RedundancyInConstructorDestructorDeclaration_CSharp10() => .WithOptions(ParseOptionsHelper.FromCSharp10) .Verify(); + [TestMethod] + public void RedundancyInConstructorDestructorDeclaration_CSharp12() => + builder.AddPaths("RedundancyInConstructorDestructorDeclaration.CSharp12.cs") + .WithOptions(ParseOptionsHelper.FromCSharp12) + .Verify(); + [TestMethod] public void RedundancyInConstructorDestructorDeclaration_CodeFix_CSharp9() => codeFixBuilderRemoveBaseCall.AddPaths("RedundancyInConstructorDestructorDeclaration.CSharp9.cs") diff --git a/analyzers/tests/SonarAnalyzer.UnitTest/TestCases/RedundancyInConstructorDestructorDeclaration.CSharp12.cs b/analyzers/tests/SonarAnalyzer.UnitTest/TestCases/RedundancyInConstructorDestructorDeclaration.CSharp12.cs new file mode 100644 index 00000000000..fb7c019fb9a --- /dev/null +++ b/analyzers/tests/SonarAnalyzer.UnitTest/TestCases/RedundancyInConstructorDestructorDeclaration.CSharp12.cs @@ -0,0 +1,15 @@ +// https://github.com/SonarSource/sonar-dotnet/issues/8092 +namespace Repro_8092 +{ + namespace PrimaryParameterlessConstructor + { + class AClassWithBody() { } // FN + class AClassWithoutBody(); // FN + struct AStructWithBody() { } // FN + struct AStructWithoutBody(); // FN + record ARecordWithBody() { } // FN + record ARecordWithoutBody(); // FN + record struct ARecordStructWithBody() { } // FN + record struct ARecordStructWithoutBody(); // FN + } +}