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/feature request] default codec for collections #8964

Open
SGStino opened this issue Apr 30, 2024 · 1 comment
Open

[bug/feature request] default codec for collections #8964

SGStino opened this issue Apr 30, 2024 · 1 comment

Comments

@SGStino
Copy link

SGStino commented Apr 30, 2024

Currently, collection interfaces like IReadOnlyList<T> can be serialized if the actual implementation is List<T>, T[], ...

But this will break the serialization:

IReadOnlyList<T> data = [element]; 

Frequently encountered when trying something like this in a unit test:

await grainProxy.MyMethodWithListParameter([1,2,3])

while these would serialize perfectly:

await grainProxy.MyMethodWithListParameter(new int[] {1,2,3}),
await grainProxy.MyMethodWithListParameter(new List<int> {1,2,3}) 

If I'm interpreting the type name in the exception correctly:

Orleans.Serialization.CodecNotFoundException : Could not find a copier for type <>z__ReadOnlySingleElementList`1[ItemType].

I'd assume that Roslyn generates a type for the initializer that implements the IReadOnlyList, but not with a known dotnet library type.

Which means Orleans won't ever be able to generate a serializer for it unless there's a fallback for IReadOnlyList<T> (in this case)?

Can I attempt to write a fallback serializer (or surrogate) somewhere, and how do I get it registered if the <>z__ReadOnlySingleElementList1` can't be referenced?

@alexander-jesner-AP
Copy link

Also see #8934

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