diff --git a/analyzers/tests/SonarAnalyzer.Test/TestCases/SymbolicExecution/Roslyn/ObjectsShouldNotBeDisposedMoreThanOnce.cs b/analyzers/tests/SonarAnalyzer.Test/TestCases/SymbolicExecution/Roslyn/ObjectsShouldNotBeDisposedMoreThanOnce.cs index adebcfb720f..95956d456e3 100644 --- a/analyzers/tests/SonarAnalyzer.Test/TestCases/SymbolicExecution/Roslyn/ObjectsShouldNotBeDisposedMoreThanOnce.cs +++ b/analyzers/tests/SonarAnalyzer.Test/TestCases/SymbolicExecution/Roslyn/ObjectsShouldNotBeDisposedMoreThanOnce.cs @@ -282,3 +282,16 @@ void CloseTwiceDBConnection(DbConnection connection) connection.Close(); // Compliant - close() in DB connection does not dispose the connection object. } } + +// https://github.com/SonarSource/sonar-dotnet/issues/8946 +public class Repro_8946 +{ + static void Method(T[] array) + { + for (int i = 0; i < array.Length; i++) + if (array[i] is IDisposable d) + { + d.Dispose(); // Noncompliant FP + } + } +}