{"record":{"id":"d6206d17de02ee67","repo":"Unity-Technologies/UnityCsReference","slug":"multicolumnheader-state-is-not-allowed-to-be-null","errorCode":null,"errorMessage":"MultiColumnHeader state is not allowed to be null","messagePattern":"MultiColumnHeader state is not allowed to be null","errorType":"exception","errorClass":"ArgumentNullException","httpStatus":null,"severity":"error","filePath":"Editor/Mono/GUI/TreeView/MultiColumnHeader.cs","lineNumber":58,"sourceCode":"        {\n            get { return state.sortedColumnIndex; }\n            set\n            {\n                if (value != state.sortedColumnIndex)\n                {\n                    state.sortedColumnIndex = value;\n                    OnSortingChanged();\n                }\n            }\n        }\n\n        public MultiColumnHeaderState state\n        {\n            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","sourceCodeStart":40,"sourceCodeEnd":76,"githubUrl":"https://github.com/Unity-Technologies/UnityCsReference/blob/225b0fbdb57cc17d094e8056b71f8314aba56f73/Editor/Mono/GUI/TreeView/MultiColumnHeader.cs#L40-L76","documentation":"Thrown by the MultiColumnHeader.state setter when an attempt is made to assign null. The header requires a valid MultiColumnHeaderState to render columns, sort state, and visibility; a null state would break every downstream accessor.","triggerScenarios":"Assigning header.state = null directly; replacing the state with the result of a function that returns null (e.g. a failed deserialization).","commonSituations":"Loading a serialized MultiColumnHeaderState that failed to deserialize; clearing state on dispose without intending to reset; a migration that constructs state conditionally.","solutions":["Always assign a non-null MultiColumnHeaderState, constructing a default one if needed.","Guard deserialization: if the loaded state is null, build a fresh MultiColumnHeaderState from the column definitions.","Avoid reassigning state at all; mutate the existing state in place instead."],"exampleFix":"// before\nheader.state = loadedState; // loadedState may be null\n\n// after\nheader.state = loadedState ?? new MultiColumnHeaderState(CreateDefaultColumns());","handlingStrategy":"validation","validationCode":"header.state = newState ?? new MultiColumnHeaderState(CreateDefaultColumns());","typeGuard":"static bool HasState(MultiColumnHeader h) => h.state != null;","tryCatchPattern":null,"preventionTips":["Never assign null to state; construct a default instead.","Validate deserialized state and rebuild on failure.","Prefer mutating existing state over replacing it."],"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"}