microsoft/vs-validation

Add analyzer and code fix provider for Requires.NotNull/Range

AArnott opened this issue · 1 comments

When the caret is positioned on a parameter declaration for a reference type, we should offer a code fix to add:

Requires.NotNull(p1, nameof(p1));

Similarly, when positioned on an integer/float parameter declaration, we can offer a code fix to add:

Requires.Range(p1 >= 0, nameof(p1));

Additionally, flag forms such as this to library calls:

if (arg is null)
{
    throw new ArgumentNullException(nameof(arg));
}