I avoid codeshare as much as I can. There is often uncertainty about how I am treated and whether I get the miles or bonus miles (if applicable).
I do not even do code share between CX and KA. If it is a KA-operated flight, I book on KA flight number, and CX-operated flight on CX flight number.