dotnet / roslynator

Roslynator is a set of code analysis tools for C#, powered by Roslyn.

Home Page:https://josefpihrt.github.io/docs/roslynator

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

`RCS1256`: Allow null-checks on virtual method overrides

RenderMichael opened this issue · comments

Product and Version Used:
Roslynator 4.12.2

Steps to Reproduce:

using System;

class Base
{
    protected virtual void M(string? str) { }
}

class Derived : Base
{
    protected override void M(string? str)
    {
        ArgumentNullException.ThrowIfNull(str);
        // process str
    }
}

Actual Behavior:
Warns on ArgumentNullException.ThrowIfNull(str);

Expected Behavior:
In my opinion, no warning - we're locked into the nullable argument because of the virtual method.