{"record":{"id":"b3718dbf867b1998","repo":"EllanJiang/GameFramework","slug":"results-is-invalid-datatablemanager","errorCode":null,"errorMessage":"Results is invalid.","messagePattern":"Results is invalid\\.","errorType":"exception","errorClass":"GameFrameworkException","httpStatus":null,"severity":"error","filePath":"GameFramework/DataTable/DataTableManager.cs","lineNumber":286,"sourceCode":"            int index = 0;\n            DataTableBase[] results = new DataTableBase[m_DataTables.Count];\n            foreach (KeyValuePair<TypeNamePair, DataTableBase> dataTable in m_DataTables)\n            {\n                results[index++] = dataTable.Value;\n            }\n\n            return results;\n        }\n\n        /// <summary>\n        /// 获取所有数据表。\n        /// </summary>\n        /// <param name=\"results\">所有数据表。</param>\n        public void GetAllDataTables(List<DataTableBase> results)\n        {\n            if (results == null)\n            {\n                throw new GameFrameworkException(\"Results is invalid.\");\n            }\n\n            results.Clear();\n            foreach (KeyValuePair<TypeNamePair, DataTableBase> dataTable in m_DataTables)\n            {\n                results.Add(dataTable.Value);\n            }\n        }\n\n        /// <summary>\n        /// 创建数据表。\n        /// </summary>\n        /// <typeparam name=\"T\">数据表行的类型。</typeparam>\n        /// <returns>要创建的数据表。</returns>\n        public IDataTable<T> CreateDataTable<T>() where T : class, IDataRow, new()\n        {\n            return CreateDataTable<T>(string.Empty);\n        }","sourceCodeStart":268,"sourceCodeEnd":304,"githubUrl":"https://github.com/EllanJiang/GameFramework/blob/d0c010b05167c58e92350449d04864a91ca13fd2/GameFramework/DataTable/DataTableManager.cs#L268-L304","documentation":"GetAllDataTables(List<DataTableBase>) throws this when the results list argument is null. The method clears and fills the caller-supplied list, so a null destination is invalid; it does not allocate a list for you.","triggerScenarios":"Calling dataTableManager.GetAllDataTables(null), or passing a property/field of type List<DataTableBase> that was never initialized.","commonSituations":"Reusing a cached list variable that was declared but never assigned; passing a LINQ result or method return that was null.","solutions":["Pass a new or existing non-null List<DataTableBase>: new List<DataTableBase>().","Initialize the list field/property before calling.","Wrap in try-catch if the list provenance is dynamic."],"exampleFix":"// before\ndataTableManager.GetAllDataTables(results); // results is null\n// after\nList<DataTableBase> results = new List<DataTableBase>();\ndataTableManager.GetAllDataTables(results);","handlingStrategy":"validation","validationCode":"List<DataTableBase> results = resultsList ?? new List<DataTableBase>();\ndataTableManager.GetAllDataTables(results);","typeGuard":"bool IsValidResultsList(List<DataTableBase> list) => list != null;","tryCatchPattern":"try { dataTableManager.GetAllDataTables(results); }\ncatch (GameFrameworkException ex) { Log.Error(\"Results list must be non-null: {0}\", ex.Message); }","preventionTips":["Always allocate the list yourself; the method fills it but never creates it.","Initialize reused list fields at declaration or in Awake.","Consider a small wrapper that allocates and returns the list."],"tags":["csharp","gameframework","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"}