Skip to content

Configuration source generator should use ArgumentNullException.ThrowIfNull if it's available #89879

@stephentoub

Description

@stephentoub

If the compilation has ArgumentNullException.ThrowIfNull available, it'd be nice if instead of emitting code like:

public static void BindCore(IConfiguration configuration, ref Tests.MyConfigSection obj, BinderOptions? binderOptions)
{
    if (obj is null)
    {
        throw new ArgumentNullException(nameof(obj));
    }
    ...

it emitted code like:

public static void BindCore(IConfiguration configuration, ref Tests.MyConfigSection obj, BinderOptions? binderOptions)
{
    ArgumentNullException.ThrowIfNull(obj);
    ...

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions