-
Notifications
You must be signed in to change notification settings - Fork 239
Closed
Labels
False PositiveRule IS triggered when it shouldn't be.Rule IS triggered when it shouldn't be.
Milestone
Description
Description
When a C# method has an array of arrays as params parameter, S3878 is raised when the method is called. e.g. for
public class Repro8163
{
public static void Method(params object[][] array) { }
public static void CallParamsMethod()
{
Method(new[] { new object() }); // Noncompliant - FP
}
}Following the S3878 suggestion to "remove the array creation and simply pass the elements" will result in a compiler error (type mismatch "cannot convert from object to object[]").
Expected behavior
No issue is raised.
Actual behavior
S3878 is raised.
Known workarounds
Move the array creation to a separate variable, then pass that variable as method parameter.
Related information
- Visual Studio version: 17.6.1
- MSBuild / dotnet version: .NET 7
- SonarScanner for .NET version: Sonar Server Version 9.9.1 (build 69595) / SonarLint Version 7.3.0.77872
- Operating System: Windows 10
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
False PositiveRule IS triggered when it shouldn't be.Rule IS triggered when it shouldn't be.