Cysharp / MemoryPack

Zero encoding extreme performance binary serializer for C# and Unity.
MIT License
3.01k stars 182 forks source link

Add attr to not overwrite Member with default value #268

Closed hadashiA closed 3 months ago

hadashiA commented 3 months ago

185

Add [SuppressDefaultInitialization] attribute.

e.g)

[MemoryPackable]
partial class A
{
    public int X;
    public int Y = 12345;

    [SkipOverwriteByDefault]
    public float Z = 678.9f;
}
    NEW:
        value = new FieldDefaultValue()
        {
            @X = __X, 
            @Y = __Y
        };
        if (3 <= count) value.@Z = __Z; // < Added this branch