adam-dot-cohen / HyperSerializer

.Net Binary Serializer - 17x faster than Protobuf and Messagepack, 2x faster than MemoryPack for C#, F# , VB, etc...
Apache License 2.0
71 stars 5 forks source link

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

Closed MrNavaStar closed 8 months ago

MrNavaStar commented 10 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 10 months ago

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

MrNavaStar commented 10 months ago

Correct

adam-dot-cohen commented 10 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 10 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 9 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 8 months ago

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

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