StateSaver: also save the type of each property along with its value so that we can convert them back to the right type during state restoration.
This makes some problematic cases such as enumeration to work.
Approved by Christian Dywan, PS Jenkins bot.