diff --git a/analyzers/tests/SonarAnalyzer.Test/Rules/ClassShouldNotBeEmptyTest.cs b/analyzers/tests/SonarAnalyzer.Test/Rules/ClassShouldNotBeEmptyTest.cs index 23ff7b2e28a..255fec4d4b8 100644 --- a/analyzers/tests/SonarAnalyzer.Test/Rules/ClassShouldNotBeEmptyTest.cs +++ b/analyzers/tests/SonarAnalyzer.Test/Rules/ClassShouldNotBeEmptyTest.cs @@ -64,6 +64,13 @@ public void ClassShouldNotBeEmpty_CSharp10() => .WithOptions(ParseOptionsHelper.FromCSharp10) .Verify(); + [TestMethod] + public void ClassShouldNotBeEmpty_CSharp12() => + builderCS + .AddPaths("ClassShouldNotBeEmpty.CSharp12.cs") + .WithOptions(ParseOptionsHelper.FromCSharp12) + .Verify(); + [TestMethod] public void ClassShouldNotBeEmpty_Inheritance_CS() => builderCS diff --git a/analyzers/tests/SonarAnalyzer.Test/TestCases/ClassShouldNotBeEmpty.CSharp12.cs b/analyzers/tests/SonarAnalyzer.Test/TestCases/ClassShouldNotBeEmpty.CSharp12.cs new file mode 100644 index 00000000000..782bab7df65 --- /dev/null +++ b/analyzers/tests/SonarAnalyzer.Test/TestCases/ClassShouldNotBeEmpty.CSharp12.cs @@ -0,0 +1,10 @@ +using System.Collections.Generic; + +public class TestCaseData(List list, int expectedCount) +{ + public List List { get; } + public int ExpectedCount { get; } +} + +// See https://github.com/SonarSource/sonar-dotnet/issues/9011 +public class CountTestCaseData(List list, int expectedCount) : TestCaseData(list, expectedCount); // Noncompliant - FP