{"record":{"id":"7a53e1b42bb33f7c","repo":"stride3d/stride","slug":"enumerables-do-not-have-the-same-number-of-items","errorCode":null,"errorMessage":"Enumerables do not have the same number of items.","messagePattern":"Enumerables do not have the same number of items\\.","errorType":"exception","errorClass":"InvalidOperationException","httpStatus":null,"severity":"error","filePath":"sources/core/Stride.Core.Design/Extensions/DesignExtensions.cs","lineNumber":86,"sourceCode":"        ArgumentNullException.ThrowIfNull(enumerable2);\n#else\n        if (enumerable1 is null) throw new ArgumentNullException(nameof(enumerable1));\n        if (enumerable2 is null) throw new ArgumentNullException(nameof(enumerable2));\n#endif\n\n        return Impl();\n\n        IEnumerable<Tuple<T1, T2>> Impl()\n        {\n            using var enumerator1 = enumerable1.GetEnumerator();\n            using var enumerator2 = enumerable2.GetEnumerator();\n            var enumMoved = true;\n            while (enumMoved)\n            {\n                enumMoved = enumerator1.MoveNext();\n                var enum2Moved = enumerator2.MoveNext();\n                if (enumMoved != enum2Moved)\n                    throw new InvalidOperationException(\"Enumerables do not have the same number of items.\");\n\n                if (enumMoved)\n                {\n                    yield return Tuple.Create(enumerator1.Current, enumerator2.Current);\n                }\n            }\n        }\n    }\n\n    /// <summary>\n    /// Iterates over all elements of source and their children recursively.\n    /// </summary>\n    /// <typeparam name=\"T\"></typeparam>\n    /// <param name=\"source\">The source.</param>\n    /// <param name=\"childrenSelector\">The children selector.</param>\n    /// <returns></returns>\n    [Pure]\n    public static IEnumerable<T> SelectDeep<T>(this IEnumerable<T> source, Func<T, IEnumerable<T>> childrenSelector)","sourceCodeStart":68,"sourceCodeEnd":104,"githubUrl":"https://github.com/stride3d/stride/blob/96fad776d210c221682aac1ccdf4c79dc046fc38/sources/core/Stride.Core.Design/Extensions/DesignExtensions.cs#L68-L104","documentation":"DesignExtensions.Zip(IEnumerable<T>, IEnumerable<T>) throws InvalidOperationException when the two enumerables do not yield the same number of items. As it walks both enumerators in lockstep, a length mismatch is detected when one enumerator can advance and the other cannot.","triggerScenarios":"Calling Zip on two sequences of unequal length, e.g. zipping a list of keys with a list of values where one collection is shorter.","commonSituations":"Misaligned data loaded from files/config where one column has more entries, refactoring that changed one collection but not its counterpart, partial deserialization.","solutions":["Validate both collections have equal Count before zipping","Pad or truncate the longer sequence to match","Consider .NET's built-in Enumerable.Zip which stops at the shorter sequence if pairing is optional"],"exampleFix":"// before\nvar pairs = keys.Zip(values); // throws if counts differ\n// after\nif (keys.Count() != values.Count()) throw new InvalidOperationException(\"keys/values length mismatch\");\nvar pairs = keys.Zip(values);","handlingStrategy":"validation","validationCode":"if (keys.Count() != values.Count())\n    throw new InvalidOperationException(\"Sequences must have equal length before Zip.\");\nvar pairs = keys.Zip(values);","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Compare counts of both collections before zipping","Keep paired collections in one collection of tuples instead of two parallel lists"],"tags":["csharp","linq","extensions"],"backgroundTag":"invalid-argument-value","analyzedSha":"96fad776d210c221682aac1ccdf4c79dc046fc38","analyzedAt":"2026-09-14T02:59:31.279Z","contentChangedAt":"2026-09-14T02:59:31.279Z","schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}