Currently, the S3900 rule does not raise an issue if the parameter of the method is assigned a new value before it's dereferenced:
public void Method(object o)
{
o = Unknown();
o.ToString(); // Compliant - o no longer has the value which was passed to the method
}
private object Unkown() => null;
This currently works for simple assignments, but not for coalescing assignments, tuple deconstructions, and when the parameter is passed as ref parameter to another method.
[ ] Coalescing assignment:
public void CoalescingAssignment(object o)
{
o ??= Unknown();
o.ToString(); // Noncompliant - FP
}
Description
Currently, the S3900 rule does not raise an issue if the parameter of the method is assigned a new value before it's dereferenced:
This currently works for simple assignments, but not for coalescing assignments, tuple deconstructions, and when the parameter is passed as ref parameter to another method.
[ ] Coalescing assignment:
[ ] Null-coalescing:
[ ] Ternary operator:
[ ] String reassignment via compound concatenation (see also #7111)
[ ] Tuple deconstruction:
private object Unkown() => null;
Some of the tests needed are also in #7039
Related information