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

[BUG] Can't instantiate MemoryPack serializer on NET7 #93

Closed
RMcD opened this issue Dec 7, 2022 · 6 comments
Closed

[BUG] Can't instantiate MemoryPack serializer on NET7 #93

RMcD opened this issue Dec 7, 2022 · 6 comments
Assignees
Labels
bug Something isn't working

Comments

@RMcD
Copy link

RMcD commented Dec 7, 2022

Describe the bug
Trying to instantiate the FusionCacheCysharpMemoryPackSerializer on .NET7 throws a runtime exception.

Method 'Serialize' on type 'ZiggyCreatures.Caching.Fusion.Serialization.CysharpMemoryPack.Internals.FusionCacheDistributedEntryFormatter`1' from assembly 'ZiggyCreatures.FusionCache.Serialization.CysharpMemoryPack, Version=0.17.0.0, Culture=neutral, PublicKeyToken=null' tried to implicitly override a method with weaker type parameter constraints.

To Reproduce
Here's a MRE (Minimal Reproducible Example) of the issue:

// When using .NET7 runtime target.
var _ = new FusionCacheCysharpMemoryPackSerializer();

LinqPad

<Query Kind="Statements">
  <NuGetReference>ZiggyCreatures.FusionCache.Serialization.CysharpMemoryPack</NuGetReference>
  <Namespace>ZiggyCreatures.Caching.Fusion</Namespace>
  <Namespace>ZiggyCreatures.Caching.Fusion.Serialization</Namespace>
  <Namespace>ZiggyCreatures.Caching.Fusion.Serialization.CysharpMemoryPack</Namespace>
  <RuntimeVersion>7.0</RuntimeVersion>
</Query>

var _ = new FusionCacheCysharpMemoryPackSerializer();

Expected behavior
The serializer should instantiate the object like it does on .NET6/netstandard2.1

Versions
I've encountered this issue on:

  • FusionCache 0.17
  • .NET version 7
  • OS version Window10

Additional context
Add any other context about the problem here.

@RMcD RMcD changed the title [BUG] Can't instantiate MemoryCache serializer on NET7 [BUG] Can't instantiate MemoryPack serializer on NET7 Dec 7, 2022
@jodydonetti
Copy link
Collaborator

Hi @RMcD and thanks for using FusionCache.
Will check and let you know.

@jodydonetti
Copy link
Collaborator

jodydonetti commented Dec 10, 2022

I can confirm the same problem, and I think I know what is happening here: to be sure though, I have to summon MemoryPack's creator.

I created an issue there, let's see what @neuecc will say.

@jodydonetti jodydonetti self-assigned this Dec 10, 2022
@jodydonetti jodydonetti added the bug Something isn't working label Dec 11, 2022
@jodydonetti
Copy link
Collaborator

Hi @RMcD , an update on this: my guess was in fact correct, and you can see the details of the discussion in the issue I linked.

Long story short: I don't know what will happen regarding MemoryPack itself, if it will make some changes to have a more standard experience regarding transitive .NET version dependencies or not. In the meantime though, I tried a different approach for my library (thanks to some suggestions from its author, which is super kind and helpful 🙏) and after some tweaks I made it to work well, and all the 300+ tests are now passing.
So now I'm preparing a new version which should fix this specific issue: I will release it soon, but I don't know if I will be able to do it today or later. Will update you.

Oh, and thanks for your tip, which started the conversation!

@jodydonetti
Copy link
Collaborator

FYI: I just pushed the new branch

@jodydonetti
Copy link
Collaborator

jodydonetti commented Dec 15, 2022

Hi @RMcD , just wanted to update you: the code has been updated and it's now working correctly also on .NET 7, and thanks to some back & forth with MemoryPack author it's now in perfect shape.

I'll release a new version very soon.

@jodydonetti
Copy link
Collaborator

Hi @RMcD , the new v0.18.0 has been released 🎉

It includes the needed changes, too.

Please let me know if everything is fine.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants