-
Notifications
You must be signed in to change notification settings - Fork 237
Closed
Labels
False PositiveRule IS triggered when it shouldn't be.Rule IS triggered when it shouldn't be.
Milestone
Description
Description
S3878 should not be raised if the params argument is called by its name, which requires the value of it to be passed as an array. There are times params argument should be called by its name, as when there are other arguments with default values on them.
Repro steps
public void MethodWithParams(
int intParam = 5,
string stringParam = "abc",
params double[] doubleArgs)
{
// Does something
}
public void CallMethodWithParams()
{
// To rely on the default value of stringParam in the call, one has to
// use name of doubleArgs params parameter when calling MethodWithParams. And when params parameters
// are used by their name in the call, they have to be passes in as arrays. Otherwise code doesn't compile
// Rule S3878 should not be raised when the params argument is being called by its name.
this.MethodWithParams(intParam:5, doubleArgs:new double[] { 0.2, 0.3, });
// another case, relies on both intParam and stringParam's default values
// but provides values for doubleArgs
this.MethodWithParams(doubleArgs: new double[] { 0.2, 0.3, });
}Expected behavior
S3878 should not be raised when the method is calling the params argument by its name.
Actual behavior
S3878 does not make distinction on whether the params argument was being called by name or not.
Known workarounds
None
sm-g
Metadata
Metadata
Assignees
Labels
False PositiveRule IS triggered when it shouldn't be.Rule IS triggered when it shouldn't be.