{"record":{"id":"cd5c22428e3d73c4","repo":"EllanJiang/GameFramework","slug":"results-is-invalid-filesystem","errorCode":null,"errorMessage":"Results is invalid.","messagePattern":"Results is invalid\\.","errorType":"validation","errorClass":"GameFrameworkException","httpStatus":null,"severity":"error","filePath":"GameFramework/FileSystem/FileSystem.cs","lineNumber":301,"sourceCode":"            FileInfo[] results = new FileInfo[m_FileDatas.Count];\n            foreach (KeyValuePair<string, int> fileData in m_FileDatas)\n            {\n                BlockData blockData = m_BlockDatas[fileData.Value];\n                results[index++] = new FileInfo(fileData.Key, GetClusterOffset(blockData.ClusterIndex), blockData.Length);\n            }\n\n            return results;\n        }\n\n        /// <summary>\n        /// 获取所有文件信息。\n        /// </summary>\n        /// <param name=\"results\">获取的所有文件信息。</param>\n        public void GetAllFileInfos(List<FileInfo> results)\n        {\n            if (results == null)\n            {\n                throw new GameFrameworkException(\"Results is invalid.\");\n            }\n\n            results.Clear();\n            foreach (KeyValuePair<string, int> fileData in m_FileDatas)\n            {\n                BlockData blockData = m_BlockDatas[fileData.Value];\n                results.Add(new FileInfo(fileData.Key, GetClusterOffset(blockData.ClusterIndex), blockData.Length));\n            }\n        }\n\n        /// <summary>\n        /// 检查是否存在指定文件。\n        /// </summary>\n        /// <param name=\"name\">要检查的文件名称。</param>\n        /// <returns>是否存在指定文件。</returns>\n        public bool HasFile(string name)\n        {\n            if (string.IsNullOrEmpty(name))","sourceCodeStart":283,"sourceCodeEnd":319,"githubUrl":"https://github.com/EllanJiang/GameFramework/blob/d0c010b05167c58e92350449d04864a91ca13fd2/GameFramework/FileSystem/FileSystem.cs#L283-L319","documentation":"GetAllFileInfos fills the caller-supplied List<FileInfo> with every file stored in this FileSystem. The library throws GameFrameworkException(\"Results is invalid.\") when the results reference is null, because there is no list to populate. Passing a valid, initialized list is a contract of the API.","triggerScenarios":"Calling GetAllFileInfos(null) on any FileSystem instance (Read, Write, or ReadWrite access).","commonSituations":"Caching the list in a field that was never initialized; a helper method forwarding a null list obtained from another component; refactoring that removed the `new List<FileInfo>()` allocation.","solutions":["Pass a non-null, pre-allocated List<FileInfo> instance: fileSystem.GetAllFileInfos(new List<FileInfo>());","Ensure any field/variable holding the list is initialized before the call.","Wrap the call in a null check or guard clause before invoking."],"exampleFix":"// before\nList<FileInfo> results = null;\nfileSystem.GetAllFileInfos(results);\n// after\nList<FileInfo> results = new List<FileInfo>();\nfileSystem.GetAllFileInfos(results);","handlingStrategy":"validation","validationCode":"if (results == null) throw new ArgumentException(\"results must not be null\", nameof(results));\nfileSystem.GetAllFileInfos(results);","typeGuard":"bool IsValidResults(System.Collections.Generic.List<FileInfo> results) => results != null;","tryCatchPattern":"try { fileSystem.GetAllFileInfos(results); } catch (GameFrameworkException ex) { Log.Error(\"GetAllFileInfos failed: {0}\", ex.Message); }","preventionTips":["Always pass a freshly allocated List<FileInfo>.","Null-check inputs at API boundaries in your own helpers.","Never reuse a list variable that may have been set to null on dispose."],"tags":["csharp","null-argument","filesystem"],"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"}