I had a close look at the junction point of the M3 shaft ant the one of 335i
It don't seems that both parts (M3 one side and 335i other side) can join together directly. they are 2 male or female. and we need a male and a female to join it.
so my idea is to use a 6MT M3 shaft that is 30mm shorter than the 335i and build an adapter plate at the gearbox side, it will bridge the gap and adapt the circle diameter of the bolts, M3 has 105mm and 335i has 95mm at gearbox
look at realoem for the driveshaft of M3 and 335i parts and you will understand 8read the comments on the parts table for circle diameter)