dotnet/roslyn

IDE0059

Open

#52,248 opened on Mar 30, 2021

View on GitHub
 (1 comment) (0 reactions) (1 assignee)C# (4,257 forks)batch import
Area-IDEBugFeature - IDE0059help wanted

Repository metrics

Stars
 (20,414 stars)
PR merge metrics
 (Avg merge 6d 17h) (256 merged PRs in 30d)

Description

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

Contributor guide