{"record":{"id":"5f46351c930cba91","repo":"dotnet/machinelearning","slug":"nameof-startindex","errorCode":null,"errorMessage":"nameof(startIndex)","messagePattern":"nameof\\(startIndex\\)","errorType":"exception","errorClass":"ArgumentOutOfRangeException","httpStatus":null,"severity":"error","filePath":"src/Microsoft.Data.Analysis/PrimitiveDataFrameColumn.cs","lineNumber":201,"sourceCode":"            else if (type == typeof(uint))\n                return new UInt32Array(arrowValueBuffer, arrowNullBuffer, numberOfRows, nullCount, offset);\n            else if (type == typeof(ulong))\n                return new UInt64Array(arrowValueBuffer, arrowNullBuffer, numberOfRows, nullCount, offset);\n            else if (type == typeof(ushort))\n                return new UInt16Array(arrowValueBuffer, arrowNullBuffer, numberOfRows, nullCount, offset);\n            else if (type == typeof(byte))\n                return new UInt8Array(arrowValueBuffer, arrowNullBuffer, numberOfRows, nullCount, offset);\n            else\n                throw new NotImplementedException(type.ToString());\n        }\n\n        public new IReadOnlyList<T?> this[long startIndex, int length]\n        {\n            get\n            {\n                if (startIndex >= Length)\n                {\n                    throw new ArgumentOutOfRangeException(nameof(startIndex));\n                }\n                return _columnContainer[startIndex, length];\n            }\n        }\n\n        protected override IReadOnlyList<object> GetValues(long startIndex, int length)\n        {\n            if (startIndex >= Length)\n            {\n                throw new ArgumentOutOfRangeException(nameof(startIndex));\n            }\n\n            var ret = new List<object>(length);\n            long endIndex = Math.Min(Length, startIndex + length);\n            for (long i = startIndex; i < endIndex; i++)\n            {\n                ret.Add(this[i]);\n            }","sourceCodeStart":183,"sourceCodeEnd":219,"githubUrl":"https://github.com/dotnet/machinelearning/blob/7b76e69cf964daeca3f1377af6bc5543284d56c6/src/Microsoft.Data.Analysis/PrimitiveDataFrameColumn.cs#L183-L219","documentation":"The PrimitiveDataFrameColumn<T> indexer this[startIndex, length] throws ArgumentOutOfRangeException(nameof(startIndex)) when startIndex is greater than or equal to the column's Length. Only the start index is validated here (length is delegated to _columnContainer), so an out-of-range start is the failure mode. The message names startIndex but does not include the actual value or bound.","triggerScenarios":"Accessing column[startIndex, length] with startIndex >= column.Length, e.g. computing offsets from a different-length column, using a 1-based index, or slicing past the end of the data.","commonSituations":"Pagination loops whose upper bound is computed incorrectly; copying slices between columns of different lengths; off-by-one errors after Length changes when rows are added or removed.","solutions":["Clamp startIndex to column.Length - 1 (or return an empty slice) before indexing","Check startIndex < column.Length explicitly before calling the indexer","Recompute offsets from the same column instance whose Length is being indexed","Use Length-based loops (for (long i = 0; i < column.Length; ...)) instead of hard-coded indices"],"exampleFix":"// before\nvar slice = column[startIndex, length]; // ArgumentOutOfRangeException if startIndex >= Length\n// after\nif (startIndex >= column.Length) throw new ArgumentOutOfRangeException(nameof(startIndex), startIndex, \"startIndex must be < Length\");\nvar slice = column[startIndex, (int)Math.Min(length, column.Length - startIndex)];","handlingStrategy":"validation","validationCode":"if (startIndex < 0 || startIndex >= column.Length)\n    throw new ArgumentOutOfRangeException(nameof(startIndex), $\"startIndex {startIndex} must be in [0, {column.Length})\");","typeGuard":null,"tryCatchPattern":"try { var slice = column[startIndex, length]; }\ncatch (ArgumentOutOfRangeException) when (startIndex >= column.Length) { startIndex = Math.Max(0, column.Length - 1); var slice = column[startIndex, length]; }","preventionTips":["Always validate startIndex against column.Length before slicing","Recompute indices from the same column instance (Length may differ between columns)","Clamp length to column.Length - startIndex to avoid secondary range errors","Use Math.Min/Max clamping helpers in slice loops"],"tags":["argument-out-of-range","dataframe","indexer","bounds-check"],"backgroundTag":"argument-out-of-range","analyzedSha":"7b76e69cf964daeca3f1377af6bc5543284d56c6","analyzedAt":"2026-09-11T12:35:38.930Z","contentChangedAt":"2026-09-11T12:35:38.930Z","schemaVersion":2},"datasetVersion":"2026-09-14T05:17:10.506Z"}