A parameter is assigned in the first statement of its method, before its value is ever read

tx0/csharp:parameter-overwritten-unreadrecommendedwarningreliability/logicdepth fastbug

What it finds

When a method begins by assigning a by-value parameter without reading it, the argument the caller passed is thrown away. Either the parameter is not needed, or the assignment was meant for another variable. The rule reports such an assignment when it is the first statement of a method, constructor or local function and its value does not mention the parameter. Setting it to null is left alone: that is meant to drop a reference, even where it has no effect.

From the rule's source, parameter_overwritten_unread.rs.

Example from the rule's tests
class Paging{    int Page(int size, int index)    {        size = 20;tx0 reports: the parameter size is overwritten before its value is read        return size * index;    }     int Clamp(int size)    {        size = size < 1 ? 1 : size;        return size;    }}
Highlighted lines are the ones tx0 reports, with its message under each; the other lines are left alone.

Turn it on, off or suppress it

The rule runs from the recommended tier up. To turn it on in a lower tier, give it a level in tx0.toml:

tx0.toml
[rules]
"tx0/csharp:parameter-overwritten-unread" = "warning"

To keep one finding, suppress it with a reason. tx0 suppress ID --reason "..." writes the comment on the line before the code:

// tx0: ignore[tx0/csharp:parameter-overwritten-unread] reason="..."

tx0 explain tx0/csharp:parameter-overwritten-unread shows the same in the terminal. Found a false positive? Report it.