When using a tuple as a parameter in a method, S1172 pops even if the tuple is used in the method.
Code example:
void UpdateControlsOnSignalChanged((InputsOutputs adress, bool state)? e) // <= False positive here
{
var call = new IPCQuery(nameof(DiagnosticsAPI.SignalChanged))
{ Data = (e?.adress, e?.state) };
_pollingPublisher.Send(call);
}
if the tuple passed as a parameter is used in the method, S1172 shouldn't pop.
S1172 pops no matter what is the usage of the tuple passed as a parameter.
Suppress the warning locally.
Hi @Thieum ,
thank you for reporting this. We're able to reproduce the issue. Minimum reproducible scenario looks like this:
object TupleArgument((string adress, bool state)? e) // Noncompliant FP
{
return new { Data = (e?.adress, e?.state) };
}
Interesting thing is that FP is not raised with public method.
public object PublicTupleArgument((string adress, bool state)? e) // Compliant for public method
{
return new { Data = (e?.adress, e?.state) };
}
Hey,
I see this is marked as merged, but I still see the issue?
// a & b are marked with S1172
public void Test(string a, string b)
{
Test2((a, b));
}
public void Test2((string, string) a)
{
Test(a.Item1, a.Item2);
}
@yfital I might be wrong but I think it's juste the repro (failing test) that has been merged, not the fix.
@Thieum you're right.
@yfital the title of the merged PR was Add repro for S1172 FP. So we have documented FP in our code base but the issue is not fixed yet.
This will be fixed in #3255