dotnet/roslyn

IDE0016 codefix can change behaviour

オープン

#36,177 opened on 2019/06/05

 (13 件のコメント) (0 件のリアクション) (0 人の担当者)C# (4,257 件のフォーク)batch import
Area-AnalyzersBugFeature - IDE0016help wanted

Repository metrics

Stars
 (20,414 個のスター)
PR merge metrics
 (平均マージ 6d 17h) (30d で 256 merged PRs)

説明

Version Used: 16.1.1+28922.388

Steps to Reproduce:

object _o;
bool _b;
void M(object o)
{
    if (o == null)
        throw new ArgumentNullException(nameof(o));
    _b = true;
    _o = o;
}

IDE0016 fires and wants to change the code to:

object _o;
bool _b;
void M(object o)
{
    _b = true;
    _o = o ?? throw new ArgumentNullException(nameof(o));
}

Expected Behavior:

No change in behaviour.

Actual Behavior:

Potential change in behaviour due to throw being moved after side effecty code.

コントリビューターガイド