diff --git a/ICSharpCode.Decompiler.Tests/ICSharpCode.Decompiler.Tests.csproj b/ICSharpCode.Decompiler.Tests/ICSharpCode.Decompiler.Tests.csproj
index 8083f86e2..089c486af 100644
--- a/ICSharpCode.Decompiler.Tests/ICSharpCode.Decompiler.Tests.csproj
+++ b/ICSharpCode.Decompiler.Tests/ICSharpCode.Decompiler.Tests.csproj
@@ -70,7 +70,7 @@
-
+
diff --git a/ICSharpCode.Decompiler.Tests/PrettyTestRunner.cs b/ICSharpCode.Decompiler.Tests/PrettyTestRunner.cs
index 80c06925b..f80cc3498 100644
--- a/ICSharpCode.Decompiler.Tests/PrettyTestRunner.cs
+++ b/ICSharpCode.Decompiler.Tests/PrettyTestRunner.cs
@@ -280,7 +280,7 @@ namespace ICSharpCode.Decompiler.Tests
}
[Test]
- public void TupleTypes([ValueSource("roslynOnlyOptions")] CSharpCompilerOptions cscOptions)
+ public void TupleTests([ValueSource("roslynOnlyOptions")] CSharpCompilerOptions cscOptions)
{
RunForLibrary(cscOptions: cscOptions);
}
diff --git a/ICSharpCode.Decompiler.Tests/TestCases/Pretty/TupleTypes.cs b/ICSharpCode.Decompiler.Tests/TestCases/Pretty/TupleTests.cs
similarity index 67%
rename from ICSharpCode.Decompiler.Tests/TestCases/Pretty/TupleTypes.cs
rename to ICSharpCode.Decompiler.Tests/TestCases/Pretty/TupleTests.cs
index c0e6b6812..4a5d79a1e 100644
--- a/ICSharpCode.Decompiler.Tests/TestCases/Pretty/TupleTypes.cs
+++ b/ICSharpCode.Decompiler.Tests/TestCases/Pretty/TupleTests.cs
@@ -17,10 +17,12 @@
// DEALINGS IN THE SOFTWARE.
using System;
+using System.Collections.Generic;
+using System.Linq;
namespace ICSharpCode.Decompiler.Tests.TestCases.Pretty
{
- public class TupleTypes
+ public class TupleTests
{
public ValueTuple VT0;
public ValueTuple VT1;
@@ -44,5 +46,34 @@ namespace ICSharpCode.Decompiler.Tests.TestCases.Pretty
public ((object a, dynamic b), dynamic, (dynamic c, object d)) Nested2;
public (ValueTuple a, (int x1, int x2), ValueTuple b, (int y1, int y2), (int, int) c) Nested3;
public (int a, int b, int c, int d, int e, int f, int g, int h, (int i, int j)) Nested4;
+
+ public Dictionary<(int a, string b), (string c, int d)> TupleDict;
+
+ public int VT1Member => VT1.Item1;
+ public int AccessUnnamed8 => Unnamed8.Item8;
+ public int AccessNamed8 => Named8.h;
+ public int AccessPartiallyNamed => PartiallyNamed.a + PartiallyNamed.Item3;
+
+ public ValueTuple NewTuple1 => new ValueTuple(1);
+ public (int a, int b) NewTuple2 => (1, 2);
+ public object BoxedTuple10 => (1, 2, 3, 4, 5, 6, 7, 8, 9, 10);
+
+ public (uint, int) SwapUnnamed => (Unnamed2.Item2, Unnamed2.Item1);
+ public (uint, int) SwapNamed2 => (Named2.b, Named2.a);
+
+ public int TupleHash => (1, 2, 3).GetHashCode();
+ public int TupleHash2 => Named2.GetHashCode();
+
+ public void UseDict()
+ {
+ if (TupleDict.Count > 10) {
+ TupleDict.Clear();
+ }
+ // TODO: it would be nice if we could infer the name 'c' for the local
+ string item = TupleDict[(1, "abc")].c;
+ Console.WriteLine(item);
+ Console.WriteLine(item);
+ Console.WriteLine(TupleDict.Values.ToList().First().d);
+ }
}
}
diff --git a/ICSharpCode.Decompiler.Tests/TestCases/Pretty/TupleTests.opt.roslyn.il b/ICSharpCode.Decompiler.Tests/TestCases/Pretty/TupleTests.opt.roslyn.il
new file mode 100644
index 000000000..6267c588f
--- /dev/null
+++ b/ICSharpCode.Decompiler.Tests/TestCases/Pretty/TupleTests.opt.roslyn.il
@@ -0,0 +1,344 @@
+
+
+
+
+// Metadata version: v4.0.30319
+.assembly extern mscorlib
+{
+ .publickeytoken = (B7 7A 5C 56 19 34 E0 89 ) // .z\V.4..
+ .ver 4:0:0:0
+}
+.assembly extern System.Core
+{
+ .publickeytoken = (B7 7A 5C 56 19 34 E0 89 ) // .z\V.4..
+ .ver 4:0:0:0
+}
+.assembly TupleTests
+{
+ .custom instance void [mscorlib]System.Runtime.CompilerServices.CompilationRelaxationsAttribute::.ctor(int32) = ( 01 00 08 00 00 00 00 00 )
+ .custom instance void [mscorlib]System.Runtime.CompilerServices.RuntimeCompatibilityAttribute::.ctor() = ( 01 00 01 00 54 02 16 57 72 61 70 4E 6F 6E 45 78 // ....T..WrapNonEx
+ 63 65 70 74 69 6F 6E 54 68 72 6F 77 73 01 ) // ceptionThrows.
+
+ // --- The following custom attribute is added automatically, do not uncomment -------
+ // .custom instance void [mscorlib]System.Diagnostics.DebuggableAttribute::.ctor(valuetype [mscorlib]System.Diagnostics.DebuggableAttribute/DebuggingModes) = ( 01 00 02 00 00 00 00 00 )
+
+ .permissionset reqmin
+ = {[mscorlib]System.Security.Permissions.SecurityPermissionAttribute = {property bool 'SkipVerification' = bool(true)}}
+ .hash algorithm 0x00008004
+ .ver 0:0:0:0
+}
+.module TupleTests.dll
+.custom instance void [mscorlib]System.Security.UnverifiableCodeAttribute::.ctor() = ( 01 00 00 00 )
+.imagebase 0x10000000
+.file alignment 0x00000200
+.stackreserve 0x00100000
+.subsystem 0x0003 // WINDOWS_CUI
+.corflags 0x00000001 // ILONLY
+
+
+// =============== CLASS MEMBERS DECLARATION ===================
+
+.class public auto ansi beforefieldinit ICSharpCode.Decompiler.Tests.TestCases.Pretty.TupleTests
+ extends [mscorlib]System.Object
+{
+ .field public valuetype [mscorlib]System.ValueTuple VT0
+ .field public valuetype [mscorlib]System.ValueTuple`1 VT1
+ .field public valuetype [mscorlib]System.ValueTuple`8 VT7EmptyRest
+ .field public valuetype [mscorlib]System.ValueTuple`2 Unnamed2
+ .field public valuetype [mscorlib]System.ValueTuple`3 Unnamed3
+ .field public valuetype [mscorlib]System.ValueTuple`4 Unnamed4
+ .field public valuetype [mscorlib]System.ValueTuple`5 Unnamed5
+ .field public valuetype [mscorlib]System.ValueTuple`6 Unnamed6
+ .field public valuetype [mscorlib]System.ValueTuple`7 Unnamed7
+ .field public valuetype [mscorlib]System.ValueTuple`8> Unnamed8
+ .field public valuetype [mscorlib]System.ValueTuple`2 Named2
+ .custom instance void [mscorlib]System.Runtime.CompilerServices.TupleElementNamesAttribute::.ctor(string[]) = ( 01 00 02 00 00 00 01 61 01 62 00 00 ) // .......a.b..
+ .field public valuetype [mscorlib]System.ValueTuple`2[] Named2Array
+ .custom instance void [mscorlib]System.Runtime.CompilerServices.TupleElementNamesAttribute::.ctor(string[]) = ( 01 00 02 00 00 00 01 61 01 62 00 00 ) // .......a.b..
+ .field public valuetype [mscorlib]System.ValueTuple`8> Named8
+ .custom instance void [mscorlib]System.Runtime.CompilerServices.TupleElementNamesAttribute::.ctor(string[]) = ( 01 00 09 00 00 00 01 61 01 62 01 63 01 64 01 65 // .......a.b.c.d.e
+ 01 66 01 67 01 68 FF 00 00 ) // .f.g.h...
+ .field public valuetype [mscorlib]System.ValueTuple`5 PartiallyNamed
+ .custom instance void [mscorlib]System.Runtime.CompilerServices.TupleElementNamesAttribute::.ctor(string[]) = ( 01 00 05 00 00 00 FF 01 61 FF 01 62 FF 00 00 ) // ........a..b...
+ .field public valuetype [mscorlib]System.ValueTuple`3,valuetype [mscorlib]System.ValueTuple`2,valuetype [mscorlib]System.ValueTuple`2> Nested1
+ .custom instance void [mscorlib]System.Runtime.CompilerServices.TupleElementNamesAttribute::.ctor(string[]) = ( 01 00 09 00 00 00 01 78 01 79 01 7A 01 61 01 62 // .......x.y.z.a.b
+ FF FF 01 63 01 64 00 00 ) // ...c.d..
+ .field public valuetype [mscorlib]System.ValueTuple`3,object,valuetype [mscorlib]System.ValueTuple`2