Serialization of nested polymorphic objects

Serializer has trouble with nested objects of polymorphic types; it serializes them as their stated base type in an annotation, rather than their real type.

This PR adds tests which exhibit this bug, then adds an additional pre-serialize event subscriber that corrects the issue.