static void AddEqualsTypeReturn(MethodReference newEquals, Collection<Instruction> ins, TypeReference type) { ins.Add(Instruction.Create(OpCodes.Ldarg_0)); if (type.IsValueType) { var resolvedType = type.GetGenericInstanceType(type); ins.Add(Instruction.Create(OpCodes.Ldobj, resolvedType)); } ins.Add(Instruction.Create(OpCodes.Ldarg_1)); ins.Add(Instruction.Create(OpCodes.Call, newEquals)); ins.Add(Instruction.Create(OpCodes.Ret)); }