Overview
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 params
parameters.
I built a minimal reproduction which can be found on GitHub. It uses SonarAnalyzer.CSharp
in version 9.15.0.81779
(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:
Why is this a false positive
It’s not legal to simply pass the elements, because a
is an int
but 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).