Skip to content

"Add null check" quickfix should support generating ArgumentNullException.ThrowIfNull() calls #61181

@Eli-Black-Work

Description

@Eli-Black-Work

The "Add null check" quickfix in Visual Studio doesn't have an option for generating a null check using ArgumentNullException.ThrowIfNull().

Consider the following code:

public string Example(object name)
{
    return name.ToString();
}

The "Add null check" quickfix looks like this:
add null check quickfix

I'd like for the quickfix to also have an option for generating a call to ArgumentNullException.ThrowIfNull(), so that the resulting code looks like this:

public string Example(object name)
{
    ArgumentNullException.ThrowIfNull(name);

    return name.ToString();
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    Area-IDEFeature Requesthelp wantedThe issue is "up for grabs" - add a comment if you are interested in working on it

    Type

    No type

    Projects

    Status

    Completed

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions