{"record":{"id":"8791e797fe8f82ba","repo":"EllanJiang/GameFramework","slug":"results-is-invalid","errorCode":null,"errorMessage":"Results is invalid.","messagePattern":"Results is invalid\\.","errorType":"exception","errorClass":"GameFrameworkException","httpStatus":null,"severity":"error","filePath":"GameFramework/Base/TaskPool/TaskPool.cs","lineNumber":185,"sourceCode":"        /// <param name=\"tag\">要获取信息的任务的标签。</param>\n        /// <returns>任务的信息。</returns>\n        public TaskInfo[] GetTaskInfos(string tag)\n        {\n            List<TaskInfo> results = new List<TaskInfo>();\n            GetTaskInfos(tag, results);\n            return results.ToArray();\n        }\n\n        /// <summary>\n        /// 根据任务的标签获取任务的信息。\n        /// </summary>\n        /// <param name=\"tag\">要获取信息的任务的标签。</param>\n        /// <param name=\"results\">任务的信息。</param>\n        public void GetTaskInfos(string tag, List<TaskInfo> results)\n        {\n            if (results == null)\n            {\n                throw new GameFrameworkException(\"Results is invalid.\");\n            }\n\n            results.Clear();\n            foreach (ITaskAgent<T> workingAgent in m_WorkingAgents)\n            {\n                T workingTask = workingAgent.Task;\n                if (workingTask.Tag == tag)\n                {\n                    results.Add(new TaskInfo(workingTask.SerialId, workingTask.Tag, workingTask.Priority, workingTask.UserData, workingTask.Done ? TaskStatus.Done : TaskStatus.Doing, workingTask.Description));\n                }\n            }\n\n            foreach (T waitingTask in m_WaitingTasks)\n            {\n                if (waitingTask.Tag == tag)\n                {\n                    results.Add(new TaskInfo(waitingTask.SerialId, waitingTask.Tag, waitingTask.Priority, waitingTask.UserData, TaskStatus.Todo, waitingTask.Description));\n                }","sourceCodeStart":167,"sourceCodeEnd":203,"githubUrl":"https://github.com/EllanJiang/GameFramework/blob/d0c010b05167c58e92350449d04864a91ca13fd2/GameFramework/Base/TaskPool/TaskPool.cs#L167-L203","documentation":"Generic null-guard inside the List-based GetTaskInfos overload of TaskPool: it fires when the caller passes a null results list to fill. It is a defensive parameter validation, not a state error; callers should pass an initialized List<TaskInfo> (or use the allocating overload that creates one internally).","triggerScenarios":"Calling GetTaskInfos(tag, null), commonly when the results list is a field that hasn't been initialized, or when reusing a list variable that was never assigned.","commonSituations":"Debug/monitoring code building task reports; mis-ordered initialization where the list is created after the first query.","solutions":["Pass a new (or reused, non-null) List<TaskInfo>: results = results ?? new List<TaskInfo>()","Initialize the results list field at declaration or in Awake","Note the method Clears the list, so you may safely reuse one list instance"],"exampleFix":"// before\nList<TaskInfo> results; // never assigned\nm_TaskPool.GetTaskInfos(\"download\", results);\n// after\nvar results = new List<TaskInfo>();\nm_TaskPool.GetTaskInfos(\"download\", results);","handlingStrategy":"validation","validationCode":"if (results == null) results = new List<TaskInfo>();\ntaskPool.GetTaskInfos(tag, results);","typeGuard":null,"tryCatchPattern":"try { taskPool.GetTaskInfos(tag, results); }\ncatch (GameFrameworkException ex) { Debug.LogError($\"GetTaskInfos failed: {ex.Message}\"); }","preventionTips":["Initialize list fields at declaration or Awake","Reuse one persistent list (the method clears it)","Never pass unassigned locals"],"tags":["taskpool","null-argument","unity","gameframework"],"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"}