A property has a setter but no getter
What it finds
A property that can be written but not read surprises callers, who cannot check what they set, and tools that read every property. A method such as SetPassword states the one-way intent more clearly.
From the rule's source, write_only_property.rs.
public class Login{ private string secret; public string Passwordtx0 reports: Password can be set but not read { set { secret = value; } } public string User { get; set; }} 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:write-only-property" = "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:write-only-property] reason="..."tx0 explain tx0/csharp:write-only-property shows the same in the terminal. Found a false positive? Report it.