{"record":{"id":"7b362a87b71b19f6","repo":"egametang/ET","slug":"arg-arrayplusofftoosmall","errorCode":null,"errorMessage":"Arg_ArrayPlusOffTooSmall","messagePattern":"Arg_ArrayPlusOffTooSmall","errorType":"exception","errorClass":"ArgumentException","httpStatus":null,"severity":"error","filePath":"Packages/cn.etetet.core/Scripts/Core/Share/Collection/SortedSet.cs","lineNumber":708,"sourceCode":"\n            if (array.Rank != 1)\n            {\n                throw new ArgumentException(SR.Arg_RankMultiDimNotSupported, nameof(array));\n            }\n\n            if (array.GetLowerBound(0) != 0)\n            {\n                throw new ArgumentException(SR.Arg_NonZeroLowerBound, nameof(array));\n            }\n\n            if (index < 0 || index > array.Length)\n            {\n                throw new ArgumentOutOfRangeException(nameof(index), index, SR.ArgumentOutOfRange_Index);\n            }\n\n            if (array.Length - index < Count)\n            {\n                throw new ArgumentException(SR.Arg_ArrayPlusOffTooSmall);\n            }\n\n            T[] tarray = array as T[];\n            if (tarray != null)\n            {\n                CopyTo(tarray, index);\n            }\n            else\n            {\n                object[] objects = array as object[];\n                if (objects == null)\n                {\n                    throw new ArgumentException(SR.Argument_IncompatibleArrayType, nameof(array));\n                }\n\n                try\n                {\n                    InOrderTreeWalk(node =>","sourceCodeStart":690,"sourceCodeEnd":726,"githubUrl":"https://github.com/egametang/ET/blob/5cab01f7a8bee5f49f4781eebe9e2b1c6d7ebe0f/Packages/cn.etetet.core/Scripts/Core/Share/Collection/SortedSet.cs#L690-L726","documentation":"Standard .NET BCL argument error from SortedSet<T>.CopyTo: the destination array is too small to hold the set starting at the given index, i.e. array.Length - index < Count. Raised after the index-range check passes.","triggerScenarios":"Passing a destination array shorter than the set's Count (minus the offset), or a non-zero index that leaves insufficient remaining slots, e.g. copying 10 elements into an array of length 5, or into index 8 of a length-10 array.","commonSituations":"Assuming Count when allocating; reusing a shared buffer sized for a previous, smaller set; subtracting an offset incorrectly.","solutions":["Allocate the destination with at least Count elements: `var arr = new T[set.Count]; set.CopyTo(arr, 0);`.","If using an offset, ensure array.Length - index >= Count.","Use ToArray() when you just need a correctly sized snapshot."],"exampleFix":"// before\nvar dest = new T[3];\nset.CopyTo(dest, 0); // throws if set.Count > 3\n// after\nvar dest = new T[set.Count];\nset.CopyTo(dest, 0);","handlingStrategy":"validation","validationCode":"T[] arr = new T[set.Count]; // always sized to Count\nset.CopyTo(arr, 0);","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Size destinations to at least set.Count (minus any offset).","Use ToArray() for a right-sized snapshot.","Recompute Count at copy time, not from a stale variable."],"tags":["csharp","unity","core","collection","sortedset","argument"],"backgroundTag":null,"analyzedSha":"5cab01f7a8bee5f49f4781eebe9e2b1c6d7ebe0f","analyzedAt":"2026-08-13T21:10:40.377Z","schemaVersion":2},"datasetVersion":"2026-08-14T00:17:13.853Z"}