Hi, I observed this false positive for
S3878 using the new C#12 collection expression feature (including a spread operator use) to pass arguments to a function taking
I built a minimal reproduction which can be found on GitHub. It uses
SonarAnalyzer.CSharp in version
22.214.171.124779 (currently most recent) and the latest version
10.2.0.77238 of SonarLint also reports it.
Here’s the gist of it in two screenshots:
It’s not legal to simply pass the elements, because
a is an
bs is an
int, so we have to use the collection expression with the spread operator or the pre-C#12 equivalent linq expression (which does not report S3878).