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
{{ message }}
Repository navigation
Have MessagePackSerializer play nice with repeated dynamic type loading
#2249
I'm in the process of building a dynamic type loader with Roslyn and I would like to use MessagePack to serialize/deserialize instances of some of these types. The loader periodically will discard and reload assemblies from C# source code (and re-create corresponding types).
Since every load creates new types, I'm finding that I can't use MessagePackSerializer because it retains type information in its static Serializes property. This means that any type that has been loaded and has used the serializer is impossible to unload from memory. I'm wondering if there could be some mechanism that would allow managing this in some way.
The most straightforward way would likely be allowing the creation of MessagePackSerializer instances (there could still be a default singleton to keep the current interface). This would allow assigning one MessagePackSerializer instance per assembly (which could then be unloaded with said assembly).
I've also looked at what it might take to expose some kind of type cache management mechanism, but that seems like a lot of work to do right considering the current implementation of ThreadsafeTypeKeyHashTable, and probably not desirable as a feature.
reacted with thumbs up emoji reacted with thumbs down emoji reacted with laugh emoji reacted with hooray emoji reacted with confused emoji reacted with heart emoji reacted with rocket emoji reacted with eyes emoji
Uh oh!
There was an error while loading. Please reload this page.
Hi all!
I'm in the process of building a dynamic type loader with Roslyn and I would like to use MessagePack to serialize/deserialize instances of some of these types. The loader periodically will discard and reload assemblies from C# source code (and re-create corresponding types).
Since every load creates new types, I'm finding that I can't use
MessagePackSerializerbecause it retains type information in its staticSerializesproperty. This means that any type that has been loaded and has used the serializer is impossible to unload from memory. I'm wondering if there could be some mechanism that would allow managing this in some way.The most straightforward way would likely be allowing the creation of
MessagePackSerializerinstances (there could still be a default singleton to keep the current interface). This would allow assigning oneMessagePackSerializerinstance per assembly (which could then be unloaded with said assembly).I've also looked at what it might take to expose some kind of type cache management mechanism, but that seems like a lot of work to do right considering the current implementation of
ThreadsafeTypeKeyHashTable, and probably not desirable as a feature.Is there any interest in solving this problem?
All reactions