{"record":{"id":"0f70a390befe67d5","repo":"EllanJiang/GameFramework","slug":"results-is-invalid-filesystemmanager","errorCode":null,"errorMessage":"Results is invalid.","messagePattern":"Results is invalid\\.","errorType":"exception","errorClass":"GameFrameworkException","httpStatus":null,"severity":"error","filePath":"GameFramework/FileSystem/FileSystemManager.cs","lineNumber":273,"sourceCode":"            int index = 0;\n            IFileSystem[] results = new IFileSystem[m_FileSystems.Count];\n            foreach (KeyValuePair<string, FileSystem> fileSystem in m_FileSystems)\n            {\n                results[index++] = fileSystem.Value;\n            }\n\n            return results;\n        }\n\n        /// <summary>\n        /// 获取所有文件系统集合。\n        /// </summary>\n        /// <param name=\"results\">获取的所有文件系统集合。</param>\n        public void GetAllFileSystems(List<IFileSystem> results)\n        {\n            if (results == null)\n            {\n                throw new GameFrameworkException(\"Results is invalid.\");\n            }\n\n            results.Clear();\n            foreach (KeyValuePair<string, FileSystem> fileSystem in m_FileSystems)\n            {\n                results.Add(fileSystem.Value);\n            }\n        }\n    }\n}\n","sourceCodeStart":255,"sourceCodeEnd":284,"githubUrl":"https://github.com/EllanJiang/GameFramework/blob/d0c010b05167c58e92350449d04864a91ca13fd2/GameFramework/FileSystem/FileSystemManager.cs#L255-L284","documentation":"GameFrameworkManager.GetAllFileSystems copies all registered file systems into a caller-supplied List<IFileSystem>. The method requires a non-null results list to fill; it refuses to allocate one itself. If you pass null, FileSystemManager.cs:273 throws this GameFrameworkException immediately.","triggerScenarios":"Calling GetAllFileSystems(null) — the only condition in the guard at FileSystemManager.cs:273. The list contents are irrelevant (it is cleared), only nullness is checked.","commonSituations":"Passing a field that was never initialized; forwarding a result of another method that returned null; refactoring away an uninitialized List<IFileSystem> member in a Unity component.","solutions":["Pass a non-null List<IFileSystem> instance: var results = new List<IFileSystem>(); fileSystemComponent.GetAllFileSystems(results);","If the list may come from elsewhere, check for null before calling and create a new one when needed."],"exampleFix":"// before\nList<IFileSystem> results = null;\nfileSystemComponent.GetAllFileSystems(results);\n// after\nList<IFileSystem> results = new List<IFileSystem>();\nfileSystemComponent.GetAllFileSystems(results);","handlingStrategy":"validation","validationCode":"if (results == null) { results = new List<IFileSystem>(); }\nfileSystemComponent.GetAllFileSystems(results);","typeGuard":"bool IsValidResults(List<IFileSystem> results) => results != null;","tryCatchPattern":"try { fileSystemComponent.GetAllFileSystems(results); }\ncatch (GameFrameworkException) { results = new List<IFileSystem>(); fileSystemComponent.GetAllFileSystems(results); }","preventionTips":["Always instantiate the results list at the call site rather than accepting one from upstream.","Treat GetAllFileSystems as fill-in-place: it never allocates, so the list must exist first."],"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"}