{"record":{"id":"4e29c40a126e8155","repo":"pardeike/Harmony","slug":"first-argument-corrupt","errorCode":null,"errorMessage":"First argument corrupt","messagePattern":"First argument corrupt","errorType":"exception","errorClass":"ArgumentException","httpStatus":null,"severity":"error","filePath":"HarmonyTests/Patching/Assets/ReturningStructMethods.cs","lineNumber":83,"sourceCode":"\t\t\tif (s != \"test\") throw new ArgumentException(\"First argument corrupt\");\r\n\t\t\treturn new St06();\r\n\t\t}\r\n\t}\r\n\r\n\tpublic class ReturningStructs_I07\r\n\t{\r\n\t\tpublic St07 IM07(string s)\r\n\t\t{\r\n\t\t\tif (s != \"test\") throw new ArgumentException(\"First argument corrupt\");\r\n\t\t\treturn new St07();\r\n\t\t}\r\n\t}\r\n\r\n\tpublic class ReturningStructs_I08\r\n\t{\r\n\t\tpublic St08 IM08(string s)\r\n\t\t{\r\n\t\t\tif (s != \"test\") throw new ArgumentException(\"First argument corrupt\");\r\n\t\t\treturn new St08();\r\n\t\t}\r\n\t}\r\n\r\n\tpublic class ReturningStructs_I09\r\n\t{\r\n\t\tpublic St09 IM09(string s)\r\n\t\t{\r\n\t\t\tif (s != \"test\") throw new ArgumentException(\"First argument corrupt\");\r\n\t\t\treturn new St09();\r\n\t\t}\r\n\t}\r\n\r\n\tpublic class ReturningStructs_I10\r\n\t{\r\n\t\tpublic St10 IM10(string s)\r\n\t\t{\r\n\t\t\tif (s != \"test\") throw new ArgumentException(\"First argument corrupt\");\r","sourceCodeStart":65,"sourceCodeEnd":101,"githubUrl":"https://github.com/pardeike/Harmony/blob/e7872dc17008bc0ca2b3de1f53fd4120dbd7a17c/HarmonyTests/Patching/Assets/ReturningStructMethods.cs#L65-L101","documentation":"ReturningStructs_I08.IM08 is a test asset method that guards its contract: the first string argument must equal \"test\". The ArgumentException fires when the patcher/prefix passes a corrupted or missing first argument, which is how Harmony's struct-returning method tests detect broken argument marshalling.","triggerScenarios":"Invoking IM08 (directly or through a Harmony patch that alters the argument list) with s != \"test\" — e.g. a transpile/prefix that drops or reorders arguments, or calling IM08 with a different string.","commonSituations":"Writing a Harmony prefix/postfix with the wrong parameter order for struct-returning methods; passing null/empty strings in test harnesses; signature changes in target methods.","solutions":["Pass exactly \"test\" as the first argument to IM08","Fix the patch signature so the first argument is forwarded unmodified (correct [HarmonyArgument]/parameter order)","Remove or fix the patch that rewrites the argument list"],"exampleFix":"// before\nvar inst = new ReturningStructs_I08(); inst.IM08(\"wrong\");\n// after\nvar inst = new ReturningStructs_I08(); inst.IM08(\"test\");","handlingStrategy":"try-catch","validationCode":"Debug.Assert(s == \"test\");","typeGuard":"null","tryCatchPattern":"try { inst.IM08(s); } catch (ArgumentException ex) when (ex.Message == \"First argument corrupt\") { /* handle */ }","preventionTips":["Pass the exact contract input \"test\""],"tags":["csharp","harmony","test-asset"],"backgroundTag":"invalid-argument-value","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"}