From 59ce4768fac3956df149d3ca2bbf5359678f9ef0 Mon Sep 17 00:00:00 2001 From: Mary Georgiou <89914005+mary-georgiou-sonarsource@users.noreply.github.com> Date: Tue, 28 Feb 2023 15:36:38 +0100 Subject: [PATCH] Add reproducer for #6823 (#6824) * Add repro for issue 6823 * update UT for codefix --- .../TestCases/RedundantInheritanceList.Fixed.cs | 11 +++++++++++ .../TestCases/RedundantInheritanceList.cs | 11 +++++++++++ 2 files changed, 22 insertions(+) diff --git a/analyzers/tests/SonarAnalyzer.UnitTest/TestCases/RedundantInheritanceList.Fixed.cs b/analyzers/tests/SonarAnalyzer.UnitTest/TestCases/RedundantInheritanceList.Fixed.cs index e80865423c4..b907d51a160 100644 --- a/analyzers/tests/SonarAnalyzer.UnitTest/TestCases/RedundantInheritanceList.Fixed.cs +++ b/analyzers/tests/SonarAnalyzer.UnitTest/TestCases/RedundantInheritanceList.Fixed.cs @@ -147,4 +147,15 @@ class X3 : X2, IMyInt // Compliant } struct RedunantInterfaceImpl : IA { } // Fixed + + // Reproducer for FP: https://github.com/SonarSource/sonar-dotnet/issues/6823 + class Foo { } + + interface IBar + { + int Test(); + } + + class Bar : Foo { } // Error [CS0535] + // Fixed } diff --git a/analyzers/tests/SonarAnalyzer.UnitTest/TestCases/RedundantInheritanceList.cs b/analyzers/tests/SonarAnalyzer.UnitTest/TestCases/RedundantInheritanceList.cs index ba904a46ff2..fd6d538e524 100644 --- a/analyzers/tests/SonarAnalyzer.UnitTest/TestCases/RedundantInheritanceList.cs +++ b/analyzers/tests/SonarAnalyzer.UnitTest/TestCases/RedundantInheritanceList.cs @@ -160,4 +160,15 @@ class X3 : X2, IMyInt // Compliant struct RedunantInterfaceImpl : IA, IBase { } // Noncompliant {{'IA' implements 'IBase' so 'IBase' can be removed from the inheritance list.}} // ^^^^^^^ + + // Reproducer for FP: https://github.com/SonarSource/sonar-dotnet/issues/6823 + class Foo { } + + interface IBar + { + int Test(); + } + + class Bar : Foo, IBar { } // Error [CS0535] + // Noncompliant@-1 {{'Foo' implements 'IBar' so 'IBar' can be removed from the inheritance list.}} FP }