Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Dictionary<string,byte[]> formatter is being trimmed with PublishAot #272

Open
dusrdev opened this issue Mar 28, 2024 · 4 comments
Open

Comments

@dusrdev
Copy link

dusrdev commented Mar 28, 2024

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.

Screenshot 2024-03-28 at 16 03 06
@dusrdev
Copy link
Author

dusrdev commented Apr 9, 2024

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...

@meryuhi
Copy link

meryuhi commented Apr 21, 2024

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[]>.

@dusrdev
Copy link
Author

dusrdev commented Apr 21, 2024

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[]>.

The formatters for IMemoryPackable 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...

@meryuhi
Copy link

meryuhi commented Apr 21, 2024

Yes, it should happen automatically as you said, registering the formatters manually is just a workaround.
I guess it could be solved by #251...

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants