A general theory of X‐ray diffraction in crystals