A public method returns a value through an out parameter
What it finds
out parameters make a method harder to call and to compose: the caller has to declare a variable first, and the call cannot be used in an expression. A tuple or a small result type returns several values directly. The Try... pattern and Deconstruct methods are the accepted uses, and are left alone, as are overrides and extern methods.
From the rule's source, out_parameter.rs.
public class Geometry{ public void Split(string text, out string head)tx0 reports: Split returns head through an out parameter { head = text; } public bool TryParse(string text, out int value) { value = 0; return true; }} 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:out-parameter" = "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:out-parameter] reason="..."tx0 explain tx0/csharp:out-parameter shows the same in the terminal. Found a false positive? Report it.