Skip to content

Fix S3878 FP: When input array is collection expression with spread operator #8510

@mary-georgiou-sonarsource

Description

Description

S3878 should not raise an issue for collection expression with the spread operator. The [a, .. array] expression below is equivalent to array.Prepend(a).ToArray() and cannot be replaced with a,...,array as it's a compile error.

Repro steps

const int a = 1;
int[] array = [2, 3];
Method([a, .. array]);  // Noncompliant FP

void  Method(params int[] args) { } 

Metadata

Metadata

Labels

False PositiveRule IS triggered when it shouldn't be.

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions