{"record":{"id":"054fc54abfacc174","repo":"Unity-Technologies/UnityCsReference","slug":"columnindices","errorCode":null,"errorMessage":"columnIndices","messagePattern":"columnIndices","errorType":"exception","errorClass":"ArgumentNullException","httpStatus":null,"severity":"error","filePath":"Editor/Mono/GUI/TreeView/MultiColumnHeader.cs","lineNumber":72,"sourceCode":"            get { return m_State; }\n            set\n            {\n                if (value == null)\n                    throw new ArgumentNullException(\"state\", \"MultiColumnHeader state is not allowed to be null\");\n                m_State = value;\n            }\n        }\n\n        public MultiColumnHeader(MultiColumnHeaderState state)\n        {\n            m_State = state;\n            m_HeaderButtonsControlID = GUIUtility.GetPermanentControlID();\n        }\n\n        public void SetSortingColumns(int[] columnIndices, bool[] sortAscending)\n        {\n            if (columnIndices == null)\n                throw new ArgumentNullException(\"columnIndices\");\n\n            if (sortAscending == null)\n                throw new ArgumentNullException(\"sortAscending\");\n\n            if (columnIndices.Length != sortAscending.Length)\n                throw new ArgumentException(\"Input arrays should have same length\");\n\n            if (columnIndices.Length > state.maximumNumberOfSortedColumns)\n                throw new ArgumentException(\"The maximum number of sorted columns is \" + state.maximumNumberOfSortedColumns + \". Trying to set \" + columnIndices.Length + \" columns.\");\n\n            if (columnIndices.Length != columnIndices.DistinctCount())\n                throw new ArgumentException(\"Duplicate column indices are not allowed\", \"columnIndices\");\n\n            bool changed = false;\n\n            if (!columnIndices.AsSpan().SequenceEqual(state.sortedColumns))\n            {\n                state.sortedColumns = columnIndices;","sourceCodeStart":54,"sourceCodeEnd":90,"githubUrl":"https://github.com/Unity-Technologies/UnityCsReference/blob/225b0fbdb57cc17d094e8056b71f8314aba56f73/Editor/Mono/GUI/TreeView/MultiColumnHeader.cs#L54-L90","documentation":"Thrown by MultiColumnHeader.SetSortingColumns when the columnIndices array is null. The method pairs each column index with a sort-ascending flag, so a null column array makes the operation impossible.","triggerScenarios":"Calling SetSortingColumns(null, sortFlags); passing a lazily-initialized array that was never populated.","commonSituations":"Resetting sort to defaults but passing null instead of an empty array; a binding that yields null when no sort columns are configured.","solutions":["Pass an empty int array (Array.Empty<int>()) instead of null to clear sorting.","Initialize columnIndices before the call; default to the currently sorted columns.","Null-check at the caller and substitute a sensible default."],"exampleFix":"// before\nheader.SetSortingColumns(sortCols, sortAsc); // sortCols may be null\n\n// after\nint[] cols = sortCols ?? Array.Empty<int>();\nbool[] asc = sortAsc ?? Array.Empty<bool>();\nheader.SetSortingColumns(cols, asc);","handlingStrategy":"validation","validationCode":"int[] cols = columnIndices ?? Array.Empty<int>();","typeGuard":"static bool IsValidSortArray(int[] a) => a != null;","tryCatchPattern":null,"preventionTips":["Use Array.Empty<int>() to represent 'no sort columns' instead of null.","Coalesce nullable sort sources before calling SetSortingColumns.","Keep sort column sources initialized at declaration."],"tags":["unity-editor","treeview","multicolumn","null-check"],"backgroundTag":null,"analyzedSha":"225b0fbdb57cc17d094e8056b71f8314aba56f73","analyzedAt":"2026-08-13T19:07:19.849Z","schemaVersion":2},"datasetVersion":"2026-08-13T19:17:28.613Z"}