{"record":{"id":"25ae9ecee7faf3c6","repo":"AvaloniaUI/Avalonia","slug":"non-zero-lower-bounds-are-not-supported","errorCode":null,"errorMessage":"Non-zero lower bounds are not supported.","messagePattern":"Non-zero lower bounds are not supported\\.","errorType":"exception","errorClass":"ArgumentException","httpStatus":null,"severity":"error","filePath":"src/Avalonia.Base/Collections/AvaloniaList.cs","lineNumber":671,"sourceCode":"            RemoveAt(index);\n        }\n\n        /// <inheritdoc/>\n        void ICollection.CopyTo(Array array, int index)\n        {\n            if (array == null)\n            {\n                throw new ArgumentNullException(nameof(array));\n            }\n\n            if (array.Rank != 1)\n            {\n                throw new ArgumentException(\"Multi-dimensional arrays are not supported.\");\n            }\n\n            if (array.GetLowerBound(0) != 0)\n            {\n                throw new ArgumentException(\"Non-zero lower bounds are not supported.\");\n            }\n\n            if (index < 0)\n            {\n                throw new ArgumentException(\"Invalid index.\");\n            }\n\n            if (array.Length - index < Count)\n            {\n                throw new ArgumentException(\"The target array is too small.\");\n            }\n\n            if (array is T[] tArray)\n            {\n                _inner.CopyTo(tArray, index);\n            }\n            else\n            {","sourceCodeStart":653,"sourceCodeEnd":689,"githubUrl":"https://github.com/AvaloniaUI/Avalonia/blob/11c542726898ae954a1ef668c65ec79ec92ab17d/src/Avalonia.Base/Collections/AvaloniaList.cs#L653-L689","documentation":"ArgumentException thrown by AvaloniaList.ICollection.CopyTo when the destination array's lower bound is non-zero. This happens with arrays created via Array.CreateInstance with a non-zero lower bound; the implementation only supports zero-based arrays.","triggerScenarios":"Passing an array created with Array.CreateInstance(typeof(T), new[]{length}, new[]{1}) (non-zero lower bound) to CopyTo.","commonSituations":"Legacy interop or COM-style code that produces non-zero-based arrays; rare VB6-style array interop.","solutions":["Use a standard zero-based array (new T[n]) as the destination.","If you must keep a non-zero-based array, copy element-by-element into the correct indices manually.","Check array.GetLowerBound(0) == 0 before calling CopyTo."],"exampleFix":"// before\nvar dest = Array.CreateInstance(typeof(T), new[]{10}, new[]{1});\n((ICollection)list).CopyTo(dest, 1);\n\n// after\nvar dest = new T[10];\n((ICollection)list).CopyTo(dest, 0);","handlingStrategy":"validation","validationCode":"if (array.GetLowerBound(0) != 0) throw new ArgumentException(\"Array must be zero-based.\", nameof(array));","typeGuard":"static bool IsZeroBased(Array a) => a.GetLowerBound(0) == 0;","tryCatchPattern":null,"preventionTips":["Use standard zero-based arrays (new T[n]).","Avoid Array.CreateInstance with non-zero lower bounds for CopyTo targets.","Check GetLowerBound(0) when interopping with legacy arrays."],"tags":["avalonia","collections","list","copyto","array-validation"],"backgroundTag":null,"analyzedSha":"11c542726898ae954a1ef668c65ec79ec92ab17d","analyzedAt":"2026-08-13T11:57:40.261Z","schemaVersion":2},"datasetVersion":"2026-08-13T14:17:21.547Z"}