Possible variable write not recognized in Parallel.ForEach

Operating system: Windows 11 Pro
Visual Studio version: Visual Studio Professional 2022
SonarLint plugin version:
Programming language you’re coding in: C#
Is connected mode used: No.
Connected to SonarCloud or SonarQube (and which version): No.

Please see the following .NET Fiddle: C# Online Compiler | .NET Fiddle

SonarLint reports S2583 on line 17 for the variable x which is incorrect.

Hi Tyson, welcome to the community.

Indeed, this is a false positive raised when the modification happens in a lambda. We are aware of the limitation at this time, unfortunately.

We will definitely look into it as part of our work to improve our rules.


This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.