For Star Alliance, it is the operating carrier that counts. So there's no way around lower earnings by booking codeshares.
As pointed out by Kiwi Flyer and henry999 the problem is compounded by the fact that you never really know what class on the operating airline you'll end up being on codeshares.
henry999, I have always believed that the "mapping" of booking classes is an issue between the codeshare carriers, not the FF program awarding the miles. Are you sure about this?