You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Today, if you have an external type (that you obviously can't annotate with [MemoryPackable]) that you want to serialize using MemoryPack, you fall off cliff where you basically have to resort to using a wrapper type + a custom formatter + register that formatter + annotate every property of that type with [MemoryPackAllowSerialize] wherever it appears.
This is clearly not the best developer experience, especially as contrasted with a simple [MemoryPackable] attribute.
I'd propose introducing an assembly-level attribute that allows users to instruct MemoryPack to generate a serializer for an external type + automatically register that in some static context using [ModuleInitializer] + have it be recognized as a memory-packable type everywhere (meaning no need for a gazillion [MemoryPackAllowSerialize]s everywhere — you can then use cutting-edge features like [UnsafeAccessor] (if necessary, to write to/invoke private properties/constructors) to source-generate serializers with no perf overhead.
Example:
[assembly:MemoryPackable<SomeExternalType>]
The text was updated successfully, but these errors were encountered:
Today, if you have an external type (that you obviously can't annotate with
[MemoryPackable]
) that you want to serialize using MemoryPack, you fall off cliff where you basically have to resort to using a wrapper type + a custom formatter + register that formatter + annotate every property of that type with[MemoryPackAllowSerialize]
wherever it appears.This is clearly not the best developer experience, especially as contrasted with a simple
[MemoryPackable]
attribute.I'd propose introducing an assembly-level attribute that allows users to instruct MemoryPack to generate a serializer for an external type + automatically register that in some static context using
[ModuleInitializer]
+ have it be recognized as a memory-packable type everywhere (meaning no need for a gazillion[MemoryPackAllowSerialize]
s everywhere — you can then use cutting-edge features like[UnsafeAccessor]
(if necessary, to write to/invoke private properties/constructors) to source-generate serializers with no perf overhead.Example:
The text was updated successfully, but these errors were encountered: