{"record":{"id":"b342b1bc632cd4a1","repo":"EllanJiang/GameFramework","slug":"results-is-invalid-datatablemanager-datatable","errorCode":null,"errorMessage":"Results is invalid.","messagePattern":"Results is invalid\\.","errorType":"exception","errorClass":"GameFrameworkException","httpStatus":null,"severity":"error","filePath":"GameFramework/DataTable/DataTableManager.DataTable.cs","lineNumber":206,"sourceCode":"\n                return results.ToArray();\n            }\n\n            /// <summary>\n            /// 获取符合条件的数据表行。\n            /// </summary>\n            /// <param name=\"condition\">要检查的条件。</param>\n            /// <param name=\"results\">符合条件的数据表行。</param>\n            public void GetDataRows(Predicate<T> condition, List<T> results)\n            {\n                if (condition == null)\n                {\n                    throw new GameFrameworkException(\"Condition is invalid.\");\n                }\n\n                if (results == null)\n                {\n                    throw new GameFrameworkException(\"Results is invalid.\");\n                }\n\n                results.Clear();\n                foreach (KeyValuePair<int, T> dataRow in m_DataSet)\n                {\n                    if (condition(dataRow.Value))\n                    {\n                        results.Add(dataRow.Value);\n                    }\n                }\n            }\n\n            /// <summary>\n            /// 获取排序后的数据表行。\n            /// </summary>\n            /// <param name=\"comparison\">要排序的条件。</param>\n            /// <returns>排序后的数据表行。</returns>\n            public T[] GetDataRows(Comparison<T> comparison)","sourceCodeStart":188,"sourceCodeEnd":224,"githubUrl":"https://github.com/EllanJiang/GameFramework/blob/d0c010b05167c58e92350449d04864a91ca13fd2/GameFramework/DataTable/DataTableManager.DataTable.cs#L188-L224","documentation":"GetDataRows(Predicate<T>, List<T>) validates its output List<T> parameter after checking the condition; a null results list throws GameFrameworkException(\"Results is invalid.\") at line 206. The list is used as a caller-provided buffer that the method clears and fills.","triggerScenarios":"Calling GetDataRows(condition, null) — e.g. forgetting to new up the list, or passing a property that returns null before lazy initialization.","commonSituations":"Object-pool reuse code where the buffer field is assigned in OnEnable but the query runs earlier; a caller method with an optional list parameter defaulted to null.","solutions":["Pass an instantiated List<T>: `new List<T>()` (or a pooled instance)","Guard: `buffer ??= new List<T>();` before the call","If the buffer is lazily created, ensure initialization happens before the first query","Catch GameFrameworkException if the list comes from an external caller"],"exampleFix":"// before\nList<MyRow> buffer = null;\ntable.GetDataRows(cond, buffer);\n// after\nList<MyRow> buffer = new List<MyRow>();\ntable.GetDataRows(cond, buffer);","handlingStrategy":"validation","validationCode":"results ??= new List<T>();\ndataTable.GetDataRows(condition, results);","typeGuard":"static bool BufferReady<T>(List<T> list) => list != null;","tryCatchPattern":"try { dataTable.GetDataRows(condition, results); }\ncatch (GameFrameworkException ex) when (ex.Message == \"Results is invalid.\") { results = new List<T>(); dataTable.GetDataRows(condition, results); }","preventionTips":["Instantiate result buffers at field declaration","Acquire pooled lists before issuing queries","Never pass a lazily-created list property that can still be null"],"tags":["csharp","datatable","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-16T04:17:20.429Z"}