adam-dot-cohen / HyperSerializer

Dot Net Binary Serializer - 17x faster than Protobuf and Messagepack, 2x faster than MemoryPack
Apache License 2.0
64 stars 5 forks source link

Enhancement: Optional Support for Fields/Modes and Member Attributes #6

Closed najak3d closed 6 months ago

najak3d commented 9 months ago

Loving this simple library. Planning to use it for Unity3D networking for simple Command classes (members are all value-types).

I'd like to see the option for including Fields, not just Properties. Also, Opt-In vs. Opt-Out mode (via member attributes).

And so Member-Attributes for Opt-in/out would be needed too.

adam-dot-cohen commented 9 months ago

Support added and turned on by default. To turn off set HyperSerializerSettings.SerializeFields = false.

Member serialization attributes can be added relatively easily (implementation would occur in MemberTypeInfos<T> class, but I don't have the time to get to this right now. Will leave open as an enhancement for now. Feel free to fork and implement if you need it asap.

najak3d commented 9 months ago

For now, we don't need this, as our usage is very narrow -- it's only used for value-types commands sent over the network, and so these commands are easy to make their public API be 100% designed for serialization. So not currently an issue for us. With "Ignore" or "Include" attributes, that would make it so that you don't have to create separate classes/instances just to encapsulate the network message, which may be convenient for us in the future.