Im not familiar with the Torch patching methods, but here is a transpiler that works with harmony. It just adds a null check where it should be... Feel free to ignore this if you already have another solution.
[HarmonyTranspiler]
[HarmonyPatch(typeof(MyComponentBase), "Serialize")]
public static IEnumerable<CodeInstruction> SerializeFix(IEnumerable<CodeInstruction> instructions, ILGenerator gen)
{
Label label = gen.DefineLabel();
LocalBuilder local = gen.DeclareLocal(typeof(MyObjectBuilder_ComponentBase));
foreach (CodeInstruction code in instructions)
{
if (code.opcode == OpCodes.Dup)
{
yield return new CodeInstruction(OpCodes.Stloc_0);
yield return new CodeInstruction(OpCodes.Ldloc_0);
yield return new CodeInstruction(OpCodes.Brfalse, label);
yield return new CodeInstruction(OpCodes.Ldloc_0);
}
else if (code.opcode == OpCodes.Ret)
{
yield return new CodeInstruction(OpCodes.Ldloc_0).WithLabels(label);
yield return code;
}
else
{
yield return code;
}
}
}
Thank you for this. Keen have already acknowledged the error so if I got a spare few, I will implement if I come to find that the next hotfix its not near
Im not familiar with the Torch patching methods, but here is a transpiler that works with harmony. It just adds a null check where it should be... Feel free to ignore this if you already have another solution.