Hi,
The following code gives a warning on the last line
- S4158 - Empty collections should not be accessed or iterated
But the list is not empty.
[Test]
public void TestRule()
{
var lst1 = new List<int>() { 1, 2, };
var lst2 = new List<int>();
lst1.ForEach(i => lst2.Add(i));
lst2.ForEach(i => System.Diagnostics.Debug.WriteLine(i));
}
Environment:
- Visual Studio 17.8.0
- SonarLint 7.4.0
Kind regards,
Valentijn