Skip to content

VSTHRD114 do not triggered on ternary conditional operator #1537

@letarak

Description

@letarak

Bug description

null Task value in ternary operator do not trigger violation

Repro steps

static Task First(bool flag)
{
    return flag
        ? null
        : Task.CompletedTask;
}

static Task Second(bool flag) =>
    flag
        ? null
        : Task.CompletedTask;

static Task Third(bool flag)
{
    if (flag)
    {
        return null;
    }
    else
    {
        return Task.CompletedTask;
    }
}

Expected behavior

Expect that all three methods violate the rule

Actual behavior

Only Third violate

  • Version used: 17.14.15

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