{"record":{"id":"c19e6906e64d44c8","repo":"stride3d/stride","slug":"this-converter-supports-only-between-two-and-eight-elements","errorCode":null,"errorMessage":"This converter supports only between two and eight elements","messagePattern":"This converter supports only between two and eight elements","errorType":"exception","errorClass":"ArgumentException","httpStatus":null,"severity":"error","filePath":"sources/presentation/Stride.Core.Presentation.Wpf/ValueConverters/MultiBindingToTuple.cs","lineNumber":23,"sourceCode":"using Stride.Core.Annotations;\n\nnamespace Stride.Core.Presentation.ValueConverters\n{\n    public class MultiBindingToTuple : OneWayMultiValueConverter<MultiBindingToTuple>\n    {\n        [NotNull]\n        public override object Convert([NotNull] object[] values, Type targetType, object parameter, CultureInfo culture)\n        {\n            switch (values.Length)\n            {\n                case 2: return new Tuple<object, object>(values[0], values[1]);\n                case 3: return new Tuple<object, object, object>(values[0], values[1], values[2]);\n                case 4: return new Tuple<object, object, object, object>(values[0], values[1], values[2], values[3]);\n                case 5: return new Tuple<object, object, object, object, object>(values[0], values[1], values[2], values[3], values[4]);\n                case 6: return new Tuple<object, object, object, object, object, object>(values[0], values[1], values[2], values[3], values[4], values[5]);\n                case 7: return new Tuple<object, object, object, object, object, object, object>(values[0], values[1], values[2], values[3], values[4], values[5], values[6]);\n                case 8: return new Tuple<object, object, object, object, object, object, object, object>(values[0], values[1], values[2], values[3], values[4], values[5], values[6], values[7]);\n                default: throw new ArgumentException(\"This converter supports only between two and eight elements\");\n            }\n        }\n    }\n}\n","sourceCodeStart":5,"sourceCodeEnd":28,"githubUrl":"https://github.com/stride3d/stride/blob/96fad776d210c221682aac1ccdf4c79dc046fc38/sources/presentation/Stride.Core.Presentation.Wpf/ValueConverters/MultiBindingToTuple.cs#L5-L28","documentation":"MultiBindingToTuple.Convert packs 2-8 bound values into a Tuple<object,...>. The switch only handles tuples of arity 2 through 8; any other count (0, 1, 9+) falls to the default case and throws ArgumentException. The converter simply has no tuple type to build for those arities.","triggerScenarios":"Using a MultiBinding with fewer than two or more than eight Binding children on this converter, or calling Convert directly with an array of length 0, 1, or 9+.","commonSituations":"XAML MultiBinding accidentally left with a single binding after removing a value; adding a ninth binding when the limit was 8; tests invoking Convert with empty arrays.","solutions":["Ensure the MultiBinding has between 2 and 8 Binding children.","Remove the extra Binding or split the MultiBinding into two chained converters if more than 8 values are needed.","Compose values into a single object (e.g. a value-tuple property on the ViewModel) instead of exceeding 8 bindings."],"exampleFix":"<!-- before: 9 bindings -->\n<MultiBinding Converter=\"{StaticResource multiBindingToTuple}\"><Binding Path=\"A\"/>...<Binding Path=\"I\"/></MultiBinding>\n<!-- after: group extra values -->\n<MultiBinding Converter=\"{StaticResource multiBindingToTuple}\"><Binding Path=\"A\"/>...<Binding Path=\"H\"/></MultiBinding>","handlingStrategy":"validation","validationCode":"bool tupleSupported(object[] values) => values is { Length: >= 2 and <= 8 };","typeGuard":null,"tryCatchPattern":"try { result = converter.Convert(values, typeof(object), null, CultureInfo.InvariantCulture); } catch (ArgumentException) { result = Tuple.Create((object)values); }","preventionTips":["Count MultiBinding children; keep between 2 and 8","Split larger value sets across nested converters","Review MultiBinding XAML after removing bindings"],"tags":["wpf","multibinding","value-converter","tuple"],"backgroundTag":"value-out-of-range","analyzedSha":"96fad776d210c221682aac1ccdf4c79dc046fc38","analyzedAt":"2026-09-14T02:59:31.279Z","contentChangedAt":"2026-09-14T02:59:31.279Z","schemaVersion":2},"datasetVersion":"2026-09-15T23:17:13.987Z"}