diff --git a/analyzers/tests/SonarAnalyzer.Test/TestCases/SymbolicExecution/Roslyn/NullPointerDereference.cs b/analyzers/tests/SonarAnalyzer.Test/TestCases/SymbolicExecution/Roslyn/NullPointerDereference.cs index 05c89bd4719..bc32f9affa7 100644 --- a/analyzers/tests/SonarAnalyzer.Test/TestCases/SymbolicExecution/Roslyn/NullPointerDereference.cs +++ b/analyzers/tests/SonarAnalyzer.Test/TestCases/SymbolicExecution/Roslyn/NullPointerDereference.cs @@ -2108,3 +2108,20 @@ void Foo(object o, int i) Console.WriteLine(n.ToString()); // Compliant } } + +// https://github.com/SonarSource/sonar-dotnet/issues/8907 +// https://github.com/SonarSource/sonar-dotnet/issues/8908 +class Repro_8907_8908 +{ + private void Foo(string[] values) + { + if (values == null) + { + Console.WriteLine("Oops!"); + } + if (5 < values.Count()) // FN, will throw when values is null + { + _ = values[5].ToString(); // Noncompliant FP, we do not learn NotNull from LINQ methods + } + } +}