{"record":{"id":"ae8f155a111902bf","repo":"EllanJiang/GameFramework","slug":"results-is-invalid-datanodemanager-datanode","errorCode":null,"errorMessage":"Results is invalid.","messagePattern":"Results is invalid\\.","errorType":"exception","errorClass":"GameFrameworkException","httpStatus":null,"severity":"error","filePath":"GameFramework/DataNode/DataNodeManager.DataNode.cs","lineNumber":263,"sourceCode":"            public IDataNode[] GetAllChild()\n            {\n                if (m_Childs == null)\n                {\n                    return EmptyDataNodeArray;\n                }\n\n                return m_Childs.ToArray();\n            }\n\n            /// <summary>\n            /// 获取所有子数据结点。\n            /// </summary>\n            /// <param name=\"results\">所有子数据结点。</param>\n            public void GetAllChild(List<IDataNode> results)\n            {\n                if (results == null)\n                {\n                    throw new GameFrameworkException(\"Results is invalid.\");\n                }\n\n                results.Clear();\n                if (m_Childs == null)\n                {\n                    return;\n                }\n\n                foreach (DataNode child in m_Childs)\n                {\n                    results.Add(child);\n                }\n            }\n\n            /// <summary>\n            /// 根据索引移除子数据结点。\n            /// </summary>\n            /// <param name=\"index\">子数据结点的索引位置。</param>","sourceCodeStart":245,"sourceCodeEnd":281,"githubUrl":"https://github.com/EllanJiang/GameFramework/blob/d0c010b05167c58e92350449d04864a91ca13fd2/GameFramework/DataNode/DataNodeManager.DataNode.cs#L245-L281","documentation":"DataNode.GetAllChild(List<IDataNode> results) throws 'Results is invalid.' when the results list argument is null. The method clears and fills the caller-supplied list, so a null list has nowhere to write and the call is rejected upfront. This is a simple null-argument guard on the output parameter.","triggerScenarios":"Calling node.GetAllChild(null); passing a list property that was never initialized; a helper method forwarding an unassigned List<IDataNode> field.","commonSituations":"Refactoring where the list was previously created inside the method; C# 'new List<IDataNode>()' omitted when declaring the field; deserialized or pooled lists that are null on first use.","solutions":["Initialize the list before calling: new List<IDataNode>()","Check the list for null before the call if it comes from external code","Reuse a cached list and rely on the method's internal Clear()"],"exampleFix":"// before\nList<IDataNode> children = null;\nnode.GetAllChild(children);\n// after\nList<IDataNode> children = new List<IDataNode>();\nnode.GetAllChild(children);","handlingStrategy":"validation","validationCode":"if (results == null)\n{\n    results = new List<IDataNode>();\n}\nnode.GetAllChild(results);","typeGuard":"bool HasList(List<IDataNode> l) => l != null;","tryCatchPattern":"try { node.GetAllChild(results); }\ncatch (GameFrameworkException) { Log.Error(\"GetAllChild called with null list\"); results = new List<IDataNode>(); }","preventionTips":["Always instantiate result lists before passing them","Reuse a cached list — the method clears it anyway","Initialize List fields at declaration, not on first use","Wrap list-producing helpers to allocate internally"],"tags":["datanode","gameframework","null-argument"],"backgroundTag":"null-argument","analyzedSha":"d0c010b05167c58e92350449d04864a91ca13fd2","analyzedAt":"2026-09-15T13:37:15.352Z","contentChangedAt":"2026-09-15T13:37:15.352Z","schemaVersion":2},"datasetVersion":"2026-09-15T23:17:13.987Z"}