Argument exception parameter (ARCH402)
Key dotnet.exception.argument-exception-parameter · Severity info · Category exception
ArgumentException and its derivatives should include the name of the parameter that is invalid. This makes error messages more useful.
Incorrect
Section titled “Incorrect”public void Process(string name){ if (string.IsNullOrEmpty(name)) throw new ArgumentException("Name is required");}Correct
Section titled “Correct”public void Process(string name){ if (string.IsNullOrEmpty(name)) throw new ArgumentException("Name is required", nameof(name));}Pass the parameter name via nameof(parameter) to the exception. If needed, suppress the rule per project/workspace via except/ignore.