dotnet/roslyn

IDE0016 codefix can change behaviour

开放

#36,177 创建于 2019年6月5日

 (13 条评论) (0 个反应) (0 位负责人)C# (4,257 个派生)batch import
Area-AnalyzersBugFeature - IDE0016help wanted

仓库指标

星标
 (20,414 个星标)
PR 合并指标
 (平均合并 6天 17小时) (30 天内合并 256 个 PR)

描述

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.

贡献者指南