Open mmusu3 opened 3 years ago
Fixing #2378 improves this somewhat as now this does no longer produce invalid code, however, the deconstruction is no longer detected, most likely because of the inline assignment.
// DeconstructForeachItemTest
using System.Collections.Generic;
private static void Test(Dictionary<string, object> data)
{
Dictionary<string, object> dictionary = new Dictionary<string, object>();
foreach (KeyValuePair<string, object> datum in data)
{
datum.Deconstruct(out var key2, out var value2);
string key = key2;
object value = (dictionary[key] = value2);
}
}
The fixes only seem to apply for projects targeting newer .NET versions (tested with Core 3.1 and Net 5). It still produces the old wrong output for older versions (tested with netstandard2 and netfx 4.8).
Input code
Erroneous output
Error CS0165: Use of unassigned local variable 'key'
Details