{"record":{"id":"44cd1936e245e6fe","repo":"EllanJiang/GameFramework","slug":"file-system-helper-is-invalid","errorCode":null,"errorMessage":"File system helper is invalid.","messagePattern":"File system helper is invalid\\.","errorType":"exception","errorClass":"GameFrameworkException","httpStatus":null,"severity":"error","filePath":"GameFramework/FileSystem/FileSystemManager.cs","lineNumber":87,"sourceCode":"            while (m_FileSystems.Count > 0)\n            {\n                foreach (KeyValuePair<string, FileSystem> fileSystem in m_FileSystems)\n                {\n                    DestroyFileSystem(fileSystem.Value, false);\n                    break;\n                }\n            }\n        }\n\n        /// <summary>\n        /// 设置文件系统辅助器。\n        /// </summary>\n        /// <param name=\"fileSystemHelper\">文件系统辅助器。</param>\n        public void SetFileSystemHelper(IFileSystemHelper fileSystemHelper)\n        {\n            if (fileSystemHelper == null)\n            {\n                throw new GameFrameworkException(\"File system helper is invalid.\");\n            }\n\n            m_FileSystemHelper = fileSystemHelper;\n        }\n\n        /// <summary>\n        /// 检查是否存在文件系统。\n        /// </summary>\n        /// <param name=\"fullPath\">要检查的文件系统的完整路径。</param>\n        /// <returns>是否存在文件系统。</returns>\n        public bool HasFileSystem(string fullPath)\n        {\n            if (string.IsNullOrEmpty(fullPath))\n            {\n                throw new GameFrameworkException(\"Full path is invalid.\");\n            }\n\n            return m_FileSystems.ContainsKey(Utility.Path.GetRegularPath(fullPath));","sourceCodeStart":69,"sourceCodeEnd":105,"githubUrl":"https://github.com/EllanJiang/GameFramework/blob/d0c010b05167c58e92350449d04864a91ca13fd2/GameFramework/FileSystem/FileSystemManager.cs#L69-L105","documentation":"FileSystemManager.SetFileSystemHelper stores the IFileSystemHelper used to create file system instances. Passing null would leave the manager without a helper and break all later CreateFileSystem calls, so the null argument is rejected immediately.","triggerScenarios":"Calling FileSystemManager.SetFileSystemHelper(null), typically when the helper dependency failed to construct or was not yet instantiated.","commonSituations":"Initialization order bugs where a helper field is still null at setup time; a factory returning null; refactoring that removed the helper creation.","solutions":["Instantiate a concrete IFileSystemHelper (e.g. DefaultFileSystemHelper) and pass it to SetFileSystemHelper.","Check why the helper reference is null — fix construction or initialization order.","Register the helper during framework initialization before any file system usage."],"exampleFix":"// before\nfileSystemManager.SetFileSystemHelper(null); // or uninitialized field\n// after\nfileSystemManager.SetFileSystemHelper(new DefaultFileSystemHelper());","handlingStrategy":"validation","validationCode":"if (fileSystemHelper == null)\n    throw new InvalidOperationException(\"File system helper must be constructed before registration.\");\nfileSystemManager.SetFileSystemHelper(fileSystemHelper);","typeGuard":"static bool IsValidHelper(IFileSystemHelper helper) => helper != null;","tryCatchPattern":"try { fileSystemManager.SetFileSystemHelper(helper); }\ncatch (GameFrameworkException ex) when (ex.Message == \"File system helper is invalid.\") { /* helper construction failed — fail fast during bootstrap */ }","preventionTips":["Register the helper in a single, early bootstrap function.","Never allow nullable helper fields to reach registration code; construct inline if needed.","Add a startup assertion that the manager has a helper before game logic runs."],"tags":["filesystem","initialization","null-argument","dependency-injection"],"backgroundTag":"null-argument","analyzedSha":"d0c010b05167c58e92350449d04864a91ca13fd2","analyzedAt":"2026-09-15T13:37:15.352Z","contentChangedAt":"2026-09-15T13:37:15.352Z","schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}