CS0219 Not Reported when Deconstructing a Tuple
TonyValenti opened this issue · 0 comments
TonyValenti commented
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:
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.