In my experience on BMI, flying a UA code, I received all my UA miles, including bonuses. I haven't dug deep enough into the rules about code-shares, but I've decided whenever there is a UA code (and the price isn't outta whack) I will book with the UA code vs the code of the true carrier, to maximize my mileage opportunity.
Sadly, it's often the case that the UA code seats are significantly higher than the underlying carrier's fare for the same flights. Case in point, an upcoming LHR-FLR trip was $200 on LH and $750 on UA.