roslyn: C# compiler does not provide a warning about unused lambda variables

For the code:

    void SomeMethod()
    {
        void localFunction()
        {
        }

        Func<int> lambda = () =>
        {
            return 1;
        };
    }

compiler provides a warning for the unused local function but does not for the unused lambda. I expect they should be consistent. Those compiler diagnostics is used in roslyn-analyzers.

About this issue

  • Original URL
  • State: closed
  • Created 9 years ago
  • Comments: 24 (22 by maintainers)

Most upvoted comments

@agocke We’re targeting warning waves to release along with C# 8.0.

@ivanbasov I would encourage you to provide feedback in support of dotnet/roslyn-analyzers#459 and/or dotnet/roslyn-analyzers#461.

In any case, making this a warning now could potentially break somebody’s code, so IMO, the bar for making suggested change would be fairly high