镜像站点 · 本页由第三方 GitHub 只读镜像提供,非 GitHub 官方站点,不接受任何登录或凭据输入。前往 github.com
Skip to content

VSTHRD114 do not triggered on ternary conditional operator #1537

Closed

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

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions