Skip to main content

RCS1255: Simplify argument null check

Properties​

PropertyValue
Default Severitydisabled by default
Minimum language version-

Summary​

Use ArgumentNullException.ThrowIfNull instead of if null check.

Examples​

Example #1​

diagnostic.cs
if (arg is null)
{
throw new ArgumentNullException(nameof(arg));
}
fix.cs
ArgumentNullException.ThrowIfNull(arg);

Applies to​