From a2165862363ea10f292a5fedc0b8b0a8038e9095 Mon Sep 17 00:00:00 2001 From: Siegfried Pammer Date: Fri, 7 Aug 2026 13:40:17 +0200 Subject: [PATCH] Require System.ValueTuple to be a struct to be tuple compatible C# only accepts System.ValueTuple as a tuple when it is a struct, so a class of that name is an unrelated type and rendering it with tuple syntax describes it as something it is not. It also made a tuple appear to contain itself, which no struct can, and the deconstruction transform then registered the same variable as a node of its tuple tree twice and threw ArgumentException, failing the whole method instead of leaving the statements alone. The check has accepted classes since tuples were added to the type system, alongside a name comparison against "ValueType" that was corrected later. Assisted-by: Claude:claude-opus-5[1m]:Claude Code --- ICSharpCode.Decompiler/TypeSystem/TupleType.cs | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/ICSharpCode.Decompiler/TypeSystem/TupleType.cs b/ICSharpCode.Decompiler/TypeSystem/TupleType.cs index a1267f6bf..7576e817d 100644 --- a/ICSharpCode.Decompiler/TypeSystem/TupleType.cs +++ b/ICSharpCode.Decompiler/TypeSystem/TupleType.cs @@ -115,8 +115,9 @@ namespace ICSharpCode.Decompiler.TypeSystem case TypeKind.Tuple: tupleCardinality = ((TupleType)type).ElementTypes.Length; return true; - case TypeKind.Class: case TypeKind.Struct: + // C# requires System.ValueTuple to be a struct, so a class of that name is + // some other type that happens to share it and must not become tuple syntax. if (type.Namespace == "System" && type.Name == "ValueTuple") { int tpc = type.TypeParameterCount;