dotnet/roslyn

IDE0059 - Unneccessary assignment is not reported if lambda is used in method

Aperta

#38.376 aperta il 29 ago 2019

 (0 commenti) (4 reazioni) (0 assegnatari)C# (4257 fork)batch import
Area-IDEConcept-Continuous ImprovementFeature - IDE0059IDE-CodeStylehelp wanted

Metriche repository

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

Descrizione

Version Used: VS16.3 Preview 2

Steps to Reproduce:

using System;

namespace TestNamespace
{
    public class TestClass
    {
        public void TestMethod()
        {
            var r = new Random();
            DoSmth(() => true);
        }

        private void DoSmth(Func<bool> func) => func();
    }
}

Expected Behavior: IDE0059 should be triggered for r.

Actual Behavior: IDE0059 is not triggered. If you comment out DoSmth(() => true);, IDE0059 is triggered as expected.

Guida contributor