From 1f9f9c3b24b8edf0713f2b4b93b4a172539d0416 Mon Sep 17 00:00:00 2001 From: Daniel Grunwald Date: Sat, 22 Aug 2020 19:31:16 +0200 Subject: [PATCH] Deconstruction: Correctness test where same variable is assigned twice. --- .../Correctness/DeconstructionTests.cs | 22 +++++++++++++++++++ 1 file changed, 22 insertions(+) diff --git a/ICSharpCode.Decompiler.Tests/TestCases/Correctness/DeconstructionTests.cs b/ICSharpCode.Decompiler.Tests/TestCases/Correctness/DeconstructionTests.cs index 626052b95..f27372aca 100644 --- a/ICSharpCode.Decompiler.Tests/TestCases/Correctness/DeconstructionTests.cs +++ b/ICSharpCode.Decompiler.Tests/TestCases/Correctness/DeconstructionTests.cs @@ -135,6 +135,8 @@ namespace ICSharpCode.Decompiler.Tests.TestCases.Correctness NullReferenceException_Field_Deconstruction(out _); NullReferenceException_RefLocalReferencesField_Deconstruction(out _); NullReferenceException_RefLocalReferencesArrayElement_Deconstruction(out _, null); + DeconstructTupleSameVar(("a", "b")); + DeconstructTupleListForEachSameVar(new List<(string, string)> { ("a", "b") }); } public void Property_NoDeconstruction_SwappedAssignments() @@ -223,5 +225,25 @@ namespace ICSharpCode.Decompiler.Tests.TestCases.Correctness Console.WriteLine(ex.GetType().FullName); } } + + public void DeconstructTupleSameVar((string, string) tuple) + { + Console.WriteLine("DeconstructTupleSameVar:"); + string a; + a = tuple.Item1; + a = tuple.Item2; + Console.WriteLine(a); + } + + public void DeconstructTupleListForEachSameVar(List<(string, string)> tuples) + { + Console.WriteLine("DeconstructTupleListForEachSameVar:"); + foreach (var tuple in tuples) { + string a; + a = tuple.Item1; + a = tuple.Item2; + Console.WriteLine(a); + } + } } }