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

Does HyperSerializer Respect C#'s [NonSerialized] Annotation? #9

Closed MrNavaStar closed 4 months ago

MrNavaStar commented 6 months ago

I'm having trouble figuring out if this library respects the built in [NonSerialized] Annotation. If it doesn't, support for this would be awesome! If it does, I will be on my way, but maybe add something to the docs :)

Cheers!

adam-dot-cohen commented 6 months ago

Do you mean an attribute that includes/excludes a property of field from serializalization?

MrNavaStar commented 6 months ago

Correct

adam-dot-cohen commented 6 months ago

It doesn't. It's a contract-less serializer. If you want to exclude properties or fields would would need to implement a DTO.

MrNavaStar commented 6 months ago

Ah I see. I think Adding support for this annotation would make using this library a lot more straightforward forward (Especially for implementing into existing projects)

adam-dot-cohen commented 5 months ago

Will consider it for future release. In the meantime, you can create an object (DTO) that has the properties you want to serialize and use a library like AutoMapper to copy the fields/properties you wish to serialize

adam-dot-cohen commented 4 months ago

Support has been added for ignoring fields or properties in version 1.5 as follows:

[IgnoreDataMember]
public int MyProperty { get; set; }