{"record":{"id":"3fec162cb652667c","repo":"pardeike/Harmony","slug":"note-info-methodtype","errorCode":null,"errorMessage":"{note} [{info.methodType}]","messagePattern":"\\{note\\} \\[\\{info\\.methodType\\}\\]","errorType":"exception","errorClass":"ArgumentException","httpStatus":null,"severity":"error","filePath":"Harmony/Public/PatchClassProcessor.cs","lineNumber":150,"sourceCode":"\t\t\t\t}\r\n\t\t\t}\r\n\t\t}\r\n\r\n\t\tList<MethodInfo> BulkPatch(List<MethodBase> originals, ref MethodBase lastOriginal, bool unpatch)\r\n\t\t{\r\n\t\t\tvar jobs = new PatchJobs<MethodInfo>();\r\n\t\t\tfor (var i = 0; i < originals.Count; i++)\r\n\t\t\t{\r\n\t\t\t\tlastOriginal = originals[i];\r\n\t\t\t\tvar job = jobs.GetJob(lastOriginal);\r\n\t\t\t\tforeach (var patchMethod in patchMethods)\r\n\t\t\t\t{\r\n\t\t\t\t\tvar note = \"You cannot combine TargetMethod, TargetMethods or [HarmonyPatchAll] with individual annotations\";\r\n\t\t\t\t\tvar info = patchMethod.info;\r\n\t\t\t\t\tif (info.methodName is not null)\r\n\t\t\t\t\t\tthrow new ArgumentException($\"{note} [{info.methodName}]\");\r\n\t\t\t\t\tif (info.methodType.HasValue && info.methodType.Value != MethodType.Normal)\r\n\t\t\t\t\t\tthrow new ArgumentException($\"{note} [{info.methodType}]\");\r\n\t\t\t\t\tif (info.argumentTypes is not null)\r\n\t\t\t\t\t\tthrow new ArgumentException($\"{note} [{info.argumentTypes.Description()}]\");\r\n\r\n\t\t\t\t\tjob.AddPatch(patchMethod);\r\n\t\t\t\t}\r\n\t\t\t}\r\n\t\t\tforeach (var job in jobs.GetJobs())\r\n\t\t\t{\r\n\t\t\t\tlastOriginal = job.original;\r\n\t\t\t\tif (unpatch)\r\n\t\t\t\t\tProcessUnpatchJob(job);\r\n\t\t\t\telse\r\n\t\t\t\t\tProcessPatchJob(job);\r\n\t\t\t}\r\n\t\t\treturn jobs.GetReplacements();\r\n\t\t}\r\n\r\n\t\tList<MethodInfo> PatchWithAttributes(ref MethodBase lastOriginal, bool unpatch)\r","sourceCodeStart":132,"sourceCodeEnd":168,"githubUrl":"https://github.com/pardeike/Harmony/blob/e7872dc17008bc0ca2b3de1f53fd4120dbd7a17c/Harmony/Public/PatchClassProcessor.cs#L132-L168","documentation":"Same family as the methodName conflict: in bulk-patch mode the target is chosen by TargetMethod/TargetMethods/[HarmonyPatchAll], so a patch method must not pin a specific MethodType (e.g. Getter, Setter, Constructor). Harmony throws to avoid the ambiguity of two independent target selectors.","triggerScenarios":"BulkPatch encounters a patch method whose info.methodType is set to anything other than MethodType.Normal while the class uses TargetMethod/TargetMethods/[HarmonyPatchAll].","commonSituations":"[HarmonyPatch(MethodType = MethodType.Getter)] inside an [HarmonyPatchAll] class; migrating property/constructor patches into a bulk-patched class.","solutions":["Remove the MethodType from the patch method and return the property getter/setter or constructor directly from TargetMethod()/TargetMethods()","Or move the patch to its own class without bulk-targeting attributes and keep the MethodType there"],"exampleFix":"// before (in [HarmonyPatchAll] class)\n[HarmonyPatch(MethodType = MethodType.Getter)]\nstatic void Postfix() { }\n// after\nstatic IEnumerable<MethodBase> TargetMethods()\n{\n    yield return AccessTools.Property(typeof(Foo), \"Bar\").GetGetMethod();\n}","handlingStrategy":"validation","validationCode":"if (hasBulkTargeting && patchMethods.Any(p => p.info.methodType is not null and not MethodType.Normal)) throw ...;","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Express getters/setters/constructors as MethodBase from TargetMethods() instead of MethodType attributes in bulk classes"],"tags":["conflicting-attributes","method-type","harmony","annotations"],"backgroundTag":"conflicting-config-options","analyzedSha":"e7872dc17008bc0ca2b3de1f53fd4120dbd7a17c","analyzedAt":"2026-09-15T22:47:11.550Z","contentChangedAt":"2026-09-15T22:47:11.550Z","schemaVersion":2},"datasetVersion":"2026-09-16T09:17:16.951Z"}