Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

CS0219 Not Reported when Deconstructing a Tuple #7456

Open
TonyValenti opened this issue Oct 23, 2024 · 0 comments
Open

CS0219 Not Reported when Deconstructing a Tuple #7456

TonyValenti opened this issue Oct 23, 2024 · 0 comments

Comments

@TonyValenti
Copy link

Analyzer

Diagnostic ID: CS0219 : The variable 'variable' is assigned but its value is never used

Analyzer source

SDK: .NET 8.05

Describe the bug

If you use this code:

namespace ConsoleApp41 {
    internal class Program {
        static void Main(string[] args) {
            var Values = new[] {
                ("A", "B", "C"),
                ("A", "B", "C"),
                ("A", "B", "C"),
            };
            foreach (var (A, B, C) in Values) {
                Console.WriteLine(A + C);   
            }

            var D = "";

        }
    }
}

You'll see the following in VS:
Image

D correctly generates CS0219 but B does not.
This makes it easy to miss that B's value is not being used.

Expected behavior

B generates CS0219.

Actual behavior

B does not generate CS0219.

Additional context

I notice that B does generate IDE0059 but D generates both.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant