dotnet/roslyn

IDE0059

Aperta

#52.248 aperta il 30 mar 2021

 (1 commento) (0 reazioni) (1 assegnatario)C# (4257 fork)batch import
Area-IDEBugFeature - IDE0059help wanted

Metriche repository

Star
 (20.414 stelle)
Metriche merge PR
 (Merge medio 6g 17h) (256 PR mergiate in 30 g)

Descrizione

Version Used: Visual Studio 2019 v16.8.1 dotnet --list-sdks: 5.0.100 , 5.0.104 csproj.TargetFramework: netcoreapp3.1 or net5.0 csproj.LangVersion: latest

Steps to Reproduce:

public bool Func1()
{
    bool retry = true;
    while (true)
    {
        //...

        try
        {
            var model = new Class1
            {
                FieldOrProperty = 1 //The error disappears, if this line is deleted !
            };
            //...
            return true;
        }
        catch
        {
            //...
        }

        if (!retry) return false;
        retry = false; //IDE0059: Unnecessary assignment of a value to 'retry'
        //...
    }
}

Expected Behavior: No IDE0059

Actual Behavior: IDE0059

Guida contributor