MemoryPack
MemoryPack copied to clipboard
Dictionary<string,byte[]> formatter is being trimmed with PublishAot
Seems that the formatter that is being used internally in MemoryPack for Serialize(Dictionary<string,byte[])
is being trimmed, and the use of such object is now entirely broken.
Is there any update?
I have even attempted to somehow extract and create an instance of the required formatter myself, as I know the types at design time, but it has proven to be very difficult since a lot of the api's require use of inaccessible internal MemoryPack types/properties...
I'd even settle for a workaround, specifically for Dictionary<string, byte[]>
, without this my entire app is broken...
Maybe you can put following code somewhere to prevent trimming.
MemoryPackFormatterProvider.RegisterDictionary<Dictionary<string, byte[]>, string, byte[]>();
Or use a MemoryPackable(GenerateType.Collection)
type that extends from Dictionary<string, byte[]>
.
Maybe you can put following code somewhere to prevent trimming.
MemoryPackFormatterProvider.RegisterDictionary<Dictionary<string, byte[]>, string, byte[]>();
Or use a
MemoryPackable(GenerateType.Collection)
type that extends fromDictionary<string, byte[]>
.
The formatters for IMemoryPackable<T> implementing types are also being trimmed. Is looks like it is possible to register the formatters like you noted, but with many types, it seems verbose, and should probably happen automatically, this is the entire idea behind the attributes I assume...
Yes, it should happen automatically as you said, registering the formatters manually is just a workaround. I guess it could be solved by #251...