Protobuf-net doesnt trigger ISerializationCallbackReceiver.OnAfterDeserialize

When [Serializable] class that implements ISerializationCallbackReceiver is deserialized with JSONUtility, it triggers both its required methods

  1. before serialization it triggers OnBeforeSerialize
  2. after deserialization it triggers OnAfterDeserialize

Im now using Protobuf-net for deserialization.
I can’t get OnAfterDeserialize trigger after deserialization. Is there an easy way to make protobuf-net trigger that?

Simple, actually. Protobuf-net already has support through Attributes.

Example of how this is handled with protobuf-net:

  1. You don’t need to use ISerializationCallbackReceiver interface for your class.

  2. You decorate your functions to be called after/before serialization and after/before deserialization with these Attributes:

    [ProtoAfterDeserialization]
    [ProtoAfterSerialization]
    [ProtoBeforeDeserialization]
    [ProtoBeforeSerialization]