Cysharp / MemoryPack

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

UnmanagedType Specialization #216

Closed Akeit0 closed 7 months ago

Akeit0 commented 9 months ago

Proposal of UnmanagedType Specialization

[MemoryPackable]
[Serializable]
public partial class Data<T>where T:unmanaged
{
   [MemoryPackUnmanaged]
    public T Value { get; protected set; } = default;
}

Then serializer use ReadUnmanaged/WriteUnmanaged. Source generator can know whether generic T is unmanaged by ITypeSymbol.IsUnmanagedType.

hadashiA commented 7 months ago

Thanks for the suggestion. For the benefits, there seem to be a lot of difficulties.