We present a comprehensive first principles electronic structure study of the magnetoelastic and magnetostrictive properties in the Co-based Co$_2$XAl (X = V, Ti, Cr, Mn, Fe) full Heusler compounds. In addition to the commonly used total energy approach, we employ torque method to calculate the magnetoelastic tensor elements. We show that the torque based methods are in general computationally more efficient, and allow to unveil the atomic- and orbital-contributions to the magnetoelastic constants in an exact manner, as opposed to the conventional approaches based on second order perturbation with respect to the spin-orbit coupling. The magnetostriction constants are in good agreement with available experimental data. The results reveal that the main contribution to the magnetostriction constants, $lambda_{100}$ and $lambda_{111}$, arises primarily from the strained-induced modulation of the $langle d_{x^2-y^2}|hat{L}_z|d_{xy}rangle$ and $langle d_{z^2}|hat{L}_x|d_{yz}rangle$ spin orbit coupling matrix elements, respectively, of the Co atoms.