Fork me on GitHub
TypeName ArgumentExceptionAnalyzer
Check Id CC0002
Category Usage
Severity Warning

Cause

The string passed as the ‘paramName’ argument of ArgumentException constructor must be the name of one of the method arguments.
It can be either specified directly or using the nameof() operator (C#6 only)

Example

public async Task Foo(int a, int b)
{
    throw new ArgumentException("message", "c");
}

Code fix

A code fix will be presented to you that will transform the code. You can choose from any of the arguments available:

public async Task Foo(int a, int b)
{
    throw new ArgumentException("message", "a");
}

Code fix

Related rules

None

See also

TBD