Skip to content

RCS1256: Allow null-checks on virtual method overrides #1456

Open
@RenderMichael

Description

@RenderMichael

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions