{"record":{"id":"699163ff36af786c","repo":"Unity-Technologies/UnityCsReference","slug":"rows-is-null","errorCode":null,"errorMessage":"rows is null","messagePattern":"rows is null","errorType":"exception","errorClass":"ArgumentNullException","httpStatus":null,"severity":"error","filePath":"Editor/Mono/GUI/TreeView/TreeViewControl/TreeViewControl.cs","lineNumber":528,"sourceCode":"        }\n\n        protected void CenterRectUsingSingleLineHeight(ref Rect rect)\n        {\n            float singleLineHeight = EditorGUIUtility.singleLineHeight;\n            if (rect.height > singleLineHeight)\n            {\n                rect.y += (rect.height - singleLineHeight) * 0.5f;\n                rect.height = singleLineHeight;\n            }\n        }\n\n        protected void AddExpandedRows(TreeViewItem<TIdentifier> root, IList<TreeViewItem<TIdentifier>> rows)\n        {\n            if (root == null)\n                throw new ArgumentNullException(\"root\", \"root is null\");\n\n            if (rows == null)\n                throw new ArgumentNullException(\"rows\", \"rows is null\");\n\n            if (root.hasChildren)\n                foreach (TreeViewItem<TIdentifier> child in root.children)\n                    GetExpandedRowsRecursive(child, rows);\n        }\n\n        void GetExpandedRowsRecursive(TreeViewItem<TIdentifier> item, IList<TreeViewItem<TIdentifier>> expandedRows)\n        {\n            if (item == null)\n                Debug.LogError(\"Found a TreeViewItem<TIdentifier> that is null. Invalid use of AddExpandedRows(): This method is only valid to call if you have built the full tree of TreeViewItems.\");\n\n            expandedRows.Add(item);\n\n            if (item.hasChildren && IsExpanded(item.id))\n                foreach (TreeViewItem<TIdentifier> child in item.children)\n                    GetExpandedRowsRecursive(child, expandedRows);\n        }\n","sourceCodeStart":510,"sourceCodeEnd":546,"githubUrl":"https://github.com/Unity-Technologies/UnityCsReference/blob/225b0fbdb57cc17d094e8056b71f8314aba56f73/Editor/Mono/GUI/TreeView/TreeViewControl/TreeViewControl.cs#L510-L546","documentation":"Thrown by AddExpandedRows when the rows list (IList<TreeViewItem>) argument is null. The method writes expanded rows into this list; a null list means there is no destination for the collected items.","triggerScenarios":"Calling AddExpandedRows(root, null); passing a field that was never allocated; a previous code path set the rows reference to null.","commonSituations":"Custom row-building override that forgets to allocate the list; refactoring that reordered initialization.","solutions":["Allocate the list before calling: var rows = new List<TreeViewItem<TIdentifier>>();","Initialize the rows field at declaration or in the constructor.","Add a null guard that allocates on demand."],"exampleFix":"// before\nAddExpandedRows(root, m_Rows); // m_Rows is null\n\n// after\nm_Rows = m_Rows ?? new List<TreeViewItem<TIdentifier>>();\nAddExpandedRows(root, m_Rows);","handlingStrategy":"validation","validationCode":"var rows = rows ?? new List<TreeViewItem<TIdentifier>>();\nAddExpandedRows(root, rows);","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Allocate the rows list before calling AddExpandedRows.","Initialize list fields at declaration.","Never pass null as an output collection argument."],"tags":["unity","treeview","null-argument","rows"],"backgroundTag":null,"analyzedSha":"225b0fbdb57cc17d094e8056b71f8314aba56f73","analyzedAt":"2026-08-13T19:07:19.849Z","schemaVersion":2},"datasetVersion":"2026-08-13T19:17:28.613Z"}