protected override bool TryDeserializeRoot(TypeModel model, ref ProtoReader.State state, ref object value, bool autoCreate) { var serializer = TypeModel.TryGetSerializer <T>(model); if (serializer == null) { return(false); } // note FromObject is non-trivial; for value-type T it promotes the null to a default; we might not want that, // depending on the value of autoCreate bool resetToNullIfNotMoved = !autoCreate && value == null; var oldPos = state.GetPosition(); value = state.DeserializeRoot <T>(TypeHelper <T> .FromObject(value), serializer); if (resetToNullIfNotMoved && oldPos == state.GetPosition()) { value = null; } return(true); }