{"record":{"id":"3e510e25d180bd1a","repo":"huiyadanli/RevokeMsgPatcher","slug":"error-3e510e","errorCode":null,"errorMessage":"补丁安装失败，原因：文件修改器初始化失败！","messagePattern":"补丁安装失败，原因：文件修改器初始化失败！","errorType":"exception","errorClass":"Exception","httpStatus":null,"severity":"error","filePath":"RevokeMsgPatcher/Modifier/AppModifier.cs","lineNumber":399,"sourceCode":"\n        /// <summary>\n        /// c.根据补丁信息，安装补丁\n        /// 两种打补丁的方式：精准（指定位置替换）、通用（特征码替换）\n        /// </summary>\n        /// <returns></returns>\n        public bool Patch()\n        {\n            // 首先验证文件修改器是否没问题\n            if (editors.Count == 0)\n            {\n                throw new Exception(\"补丁安装失败，原因：无对应的文件修改器\");\n            }\n\n            foreach (FileHexEditor editor in editors)\n            {\n                if (editor == null)\n                {\n                    throw new Exception(\"补丁安装失败，原因：文件修改器初始化失败！\");\n                }\n            }\n\n            // 再备份所有文件\n            foreach (FileHexEditor editor in editors)\n            {\n                editor.Backup();\n            }\n\n            // 打补丁！\n            List<FileHexEditor> done = new List<FileHexEditor>(); // 已经打上补丁的\n            try\n            {\n                foreach (FileHexEditor editor in editors)\n                {\n                    bool success = editor.Patch();\n                    if (!success)\n                    {","sourceCodeStart":381,"sourceCodeEnd":417,"githubUrl":"https://github.com/huiyadanli/RevokeMsgPatcher/blob/89cbbb3f0cc896d5d092de0199a635c5c39944b6/RevokeMsgPatcher/Modifier/AppModifier.cs#L381-L417","documentation":"AppModifier.Patch() throws a plain Exception if any element of the editors list is null. In the normal flow InitEditors only adds non-null FileHexEditor instances, so a null implies the list was externally mutated or a subclass/test injected a null.","triggerScenarios":"The editors list contains a null entry when Patch() runs. Not reachable through the public API if InitEditors is the only thing populating editors.","commonSituations":"Subclass or integration code replaced editors with a list containing null; a failed FileHexEditor constructor result was added manually.","solutions":["Do not mutate the editors list after InitEditors.","If subclassing AppModifier, ensure every editor added is non-null.","Filter nulls out of editors before calling Patch()."],"exampleFix":null,"handlingStrategy":"validation","validationCode":"if (editors == null || editors.Any(e => e == null))\n{\n    throw new InvalidOperationException(\"editors 列表包含 null，请检查初始化逻辑。\");\n}\nif (editors.Count == 0)\n{\n    throw new Exception(\"补丁安装失败，原因：无对应的文件修改器\");\n}","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Do not mutate the editors list after InitEditors; let it be the single source.","In subclasses, only add non-null FileHexEditor instances.","Fail loudly on a null editor during init rather than at Patch time."],"tags":["app-modifier","init"],"backgroundTag":null,"analyzedSha":"89cbbb3f0cc896d5d092de0199a635c5c39944b6","analyzedAt":"2026-08-13T10:37:37.073Z","schemaVersion":2},"datasetVersion":"2026-08-13T14:17:21.547Z"}