public static class ValueTupleExtensions { public static (T1, T2, T3) WithFirst(this (T2, T3) tuple, T1 withItem) { return (withItem, tuple.Item1, tuple.Item2); } public static (T1, T2, T3) With(this (T1, T2) tuple, T3 withItem) { return (tuple.Item1, tuple.Item2, withItem); } public static (T1, T2, T3, T4) With(this (T1, T2, T3) tuple, T4 withItem) { return (tuple.Item1, tuple.Item2, tuple.Item3, withItem); } public static (T1, T2, T3, T4, T5) With(this (T1, T2, T3, T4) tuple, T5 withItem) { return (tuple.Item1, tuple.Item2, tuple.Item3, tuple.Item4, withItem); } public static (T1, T2, T3, T4, T5, T6) With(this (T1, T2, T3, T4, T5) tuple, T6 withItem) { return (tuple.Item1, tuple.Item2, tuple.Item3, tuple.Item4, tuple.Item5, withItem); } public static (T1, T2, T3, T4, T5, T6, T7) With(this (T1, T2, T3, T4, T5, T6) tuple, T7 withItem) { return (tuple.Item1, tuple.Item2, tuple.Item3, tuple.Item4, tuple.Item5, tuple.Item6, withItem); } public static T2 DeconstructFirst(this (T1, T2) @this, out T1 item) { (item, _) = @this; return @this.Item2; } public static T1 DeconstructLast(this (T1, T2) @this, out T2 item) { item = @this.Item2; return @this.Item1; } public static (T1, T2) DeconstructLast(this (T1, T2, T3) @this, out T3 item) { item = @this.Item3; return (@this.Item1, @this.Item2); } public static (T1, T2, T3) DeconstructLast(this (T1, T2, T3, T4) @this, out T4 item) { item = @this.Item4; return (@this.Item1, @this.Item2, @this.Item3); } public static (T1, T2, T3, T4) DeconstructLast(this (T1, T2, T3, T4, T5) @this, out T5 item) { item = @this.Item5; return (@this.Item1, @this.Item2, @this.Item3, @this.Item4); } }