An argument exception gets a sentence where it takes the parameter name, or a parameter name where it takes the message
What it finds
ArgumentException(string message, string paramName) takes the message first, while ArgumentNullException and ArgumentOutOfRangeException take the parameter name first. Mixing them up puts the sentence into ParamName and the name into the message. The rule reports ArgumentException with nameof(...) as its first argument, and the other two with a first argument that is a string literal containing a space.
From the rule's source, swapped_argument_exception_arguments.rs.
using System; class Guards{ void Check(string name, int count) { if (name == null) throw new ArgumentNullException("name must be set");tx0 reports: the first argument of ArgumentNullException is the parameter name if (count < 0) throw new ArgumentException(nameof(count));tx0 reports: the first argument of ArgumentException is the message if (count > 9) throw new ArgumentOutOfRangeException(nameof(count), "too many"); if (count == 5) throw new ArgumentException("five is not allowed", nameof(count)); }} Turn it on, off or suppress it
The rule runs in every tier. To turn it off for a project, set its level in tx0.toml:
[rules]
"tx0/csharp:swapped-argument-exception-arguments" = "off"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:swapped-argument-exception-arguments] reason="..."tx0 explain tx0/csharp:swapped-argument-exception-arguments shows the same in the terminal. Found a false positive? Report it.