An argument exception names a parameter that the method does not have
What it finds
ArgumentNullException, ArgumentOutOfRangeException and ArgumentException carry the name of the parameter at fault, which tools and callers read. A name that is not a parameter of the method, often left over from a rename, points them at nothing. nameof keeps the name in step. For ArgumentException, whose message comes first, the name is its second argument.
From the rule's source, argument_exception_name.rs.
using System; class Orders{ void Place(string customer, int quantity) { if (customer == null) { throw new ArgumentNullException("customerName");tx0 reports: customerName is not a parameter of this method } if (quantity < 1) { throw new ArgumentOutOfRangeException(nameof(quantity)); } throw new ArgumentException("bad order", "order");tx0 reports: order is not a parameter of this method } int Limit { set { if (value < 0) throw new ArgumentOutOfRangeException("value"); } }} 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:
[rules]
"tx0/csharp:argument-exception-name" = "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:argument-exception-name] reason="..."tx0 explain tx0/csharp:argument-exception-name shows the same in the terminal. Found a false positive? Report it.