λ1003: Use this method with argument names
Methods such as Match and Switch should be called with named arguments.
Cause
A method annotated with [UseWithArgumentNames] is called and at least one argument is passed positionally.
This applies to Match and Switch on Option<T>, Either<L, R>, Result<T> and EitherOrBoth<L, R>.
Calls inside expression trees (for example an Expression<Func<...>> passed to Entity Framework) are exempt,
because named arguments are not supported there.
Reason for rule
The arguments of Match and Switch are all functions of a similar shape. Without names it is easy to
confuse which branch handles which case, and swapping two branches often compiles without error.
Naming the arguments (none:, some:, left:, right:, ok:, error:) documents the intent at the call site
and makes the order of the branches irrelevant.
How to fix violations
Add the parameter name to every argument. A code fix is available.
Examples
Disallowed
static string Example(Option<int> option)
=> option.Match(() => "none", value => value.ToString());
Allowed
static string Example(Option<int> option)
=> option.Match(
none: () => "none",
some: value => value.ToString());