{"record":{"id":"a53fbad7556e9440","repo":"EllanJiang/GameFramework","slug":"load-binary-callbacks-is-invalid","errorCode":null,"errorMessage":"Load binary callbacks is invalid.","messagePattern":"Load binary callbacks is invalid\\.","errorType":"validation","errorClass":"GameFrameworkException","httpStatus":null,"severity":"error","filePath":"GameFramework/Resource/ResourceManager.cs","lineNumber":1828,"sourceCode":"        {\n            return m_ResourceLoader.GetBinaryLength(binaryAssetName);\n        }\n\n        /// <summary>\n        /// 异步加载二进制资源。\n        /// </summary>\n        /// <param name=\"binaryAssetName\">要加载二进制资源的名称。</param>\n        /// <param name=\"loadBinaryCallbacks\">加载二进制资源回调函数集。</param>\n        public void LoadBinary(string binaryAssetName, LoadBinaryCallbacks loadBinaryCallbacks)\n        {\n            if (string.IsNullOrEmpty(binaryAssetName))\n            {\n                throw new GameFrameworkException(\"Binary asset name is invalid.\");\n            }\n\n            if (loadBinaryCallbacks == null)\n            {\n                throw new GameFrameworkException(\"Load binary callbacks is invalid.\");\n            }\n\n            m_ResourceLoader.LoadBinary(binaryAssetName, loadBinaryCallbacks, null);\n        }\n\n        /// <summary>\n        /// 异步加载二进制资源。\n        /// </summary>\n        /// <param name=\"binaryAssetName\">要加载二进制资源的名称。</param>\n        /// <param name=\"loadBinaryCallbacks\">加载二进制资源回调函数集。</param>\n        /// <param name=\"userData\">用户自定义数据。</param>\n        public void LoadBinary(string binaryAssetName, LoadBinaryCallbacks loadBinaryCallbacks, object userData)\n        {\n            if (string.IsNullOrEmpty(binaryAssetName))\n            {\n                throw new GameFrameworkException(\"Binary asset name is invalid.\");\n            }\n","sourceCodeStart":1810,"sourceCodeEnd":1846,"githubUrl":"https://github.com/EllanJiang/GameFramework/blob/d0c010b05167c58e92350449d04864a91ca13fd2/GameFramework/Resource/ResourceManager.cs#L1810-L1846","documentation":"ResourceManager.LoadBinary(string, LoadBinaryCallbacks) validates loadBinaryCallbacks and throws this GameFrameworkException when it is null. Callbacks are required so the caller receives the loaded binary bytes or the failure reason. This is the final guard before m_ResourceLoader.LoadBinary is called with null userData.","triggerScenarios":"Calling LoadBinary(binaryAssetName, loadBinaryCallbacks) with loadBinaryCallbacks == null.","commonSituations":"Fire-and-forget binary loads passing null; callback fields left unassigned; wrapper APIs around LoadBinary that omit callback parameters.","solutions":["Pass an initialized LoadBinaryCallbacks with success and failure handlers","Provide no-op handlers when the result is not needed","Adjust wrappers to construct or require callbacks rather than forwarding null"],"exampleFix":"// before\nresourceManager.LoadBinary(binaryAssetName, null);\n// after\nresourceManager.LoadBinary(binaryAssetName, new LoadBinaryCallbacks(\n    (assetName, bytes, duration) => { /* use bytes */ },\n    (assetName, status) => { /* handle failure */ }));","handlingStrategy":"validation","validationCode":"if (loadBinaryCallbacks == null) throw new ArgumentException(\"loadBinaryCallbacks required\", nameof(loadBinaryCallbacks));","typeGuard":"bool HasBinaryCallbacks(LoadBinaryCallbacks? c) => c is not null;","tryCatchPattern":"try { resourceManager.LoadBinary(binaryAssetName, loadBinaryCallbacks); } catch (GameFrameworkException ex) { Log.Error(ex.Message); }","preventionTips":["Always supply LoadBinaryCallbacks with success and failure handlers","Centralize binary callback creation in a helper","Avoid null-callback fire-and-forget patterns with this framework"],"tags":["csharp","gameframework","argument-null","binary-loading"],"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"}