[BZ 1034359] Trait serialization
(cherry picked from commit b7393433dec4769cfaa49bada2d3bc71eb4bf192)