dotnet / dotnet/orleans

Codec not found even though IConverter created

Open
#8,244 3 comments 0 reactions 1 assignee Claimed by @ReubenBond View on GitHub
area-serialization Needs: triage :mag:
Dominant language
C#
Stars
10.9k
Forks
2.1k
Avg merge
13h 56m
Merged PRs (30d)
351

Description

Im getting a `CodecNotFoundException` when trying to serialize a generic struct type from an external lib, `OneOf` https://www.nuget.org/packages/OneOf

Here is my `IConverter`

``` cs
namespace Grains.Surrogates;

[GenerateSerializer]
public struct OneOfSurrogate
{
[Id(0)] public GameCardModel? V0;
[Id(1)] public GamePlayerModel? V1;
}

// Implement the IConverter
[RegisterConverter]
public sealed class OneOfSurrogateConverter : IConverter, OneOfSurrogate>
{
public OneOf ConvertFromSurrogate(in OneOfSurrogate surrogate)
=> surrogate.V0 != null
? OneOf.FromT0(surrogate.V0)
: OneOf.FromT1(surrogate.V1!);

public OneOfSurrogate ConvertToSurrogate(in OneOf value)
=> new()
{
V0 = value.IsT0 ? value.AsT0 : null,
V1 = value.IsT1 ? value.AsT1 : null,
};
}

```

And here is the generated orleans code where the error originates
``` cs
_codec0 = OrleansGeneratedCodeHelper.GetService>>(this, codecProvider);

```

The `IConverter` is in the same assembly as the grains and the sdk is installed

```xml


net7.0
enable
enable

























```

I have another surrogate in the code base which works fine for a non generic struct type so im not sure what the issue is here.

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.