A property's setter never uses value, so the assigned value is lost
What it finds
A set accessor that does not read value drops what the caller assigns; usually the assignment to the backing field reads another variable by mistake. Setters that throw, that are empty on purpose with a comment, or that belong to an explicit interface implementation are left alone.
From the rule's source, setter_ignores_value.rs.
class Customer{ private string name; private string city; public string Name { get => name; set { name = city; }tx0 reports: the setter of Name never uses value } public string City { get => city; set => city = value; } public int Version { get => 1; set { throw new System.NotSupportedException(); } }} Turn it on, off or suppress it
The rule runs from the strict tier up. To turn it on in a lower tier, give it a level in tx0.toml:
[rules]
"tx0/csharp:setter-ignores-value" = "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:setter-ignores-value] reason="..."tx0 explain tx0/csharp:setter-ignores-value shows the same in the terminal. Found a false positive? Report it.