-
Notifications
You must be signed in to change notification settings - Fork 2k
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
Collection Expression syntax not compatible with orleans serializer #8934
Comments
Adding the expected error here just in case :-)
|
Good find, thank you for reporting. It might be time for us to add serializers for unknown collection types. eg, if a type implements |
We encountered a related issue with code like this: private readonly List<Problem> _problems = [];
public List<Problem> Problems
{
get
{
return _problems;
}
set
{
_problems.AddRange(value);
}
}
public Problem Problem
{
set => _problems.Add(value);
} When the setter for private readonly List<Problem> _problems = new(); |
That is surprising behavior, @cbgrasshopper. I don't see any serialization attributes in that code, but I assume this error occurs post-deserialization? |
@ReubenBond Yes, this is post-deserialization, and yes, this is surprising behavior 🤣 . I didn't include the serialization attributes in my snippet, but they are there as follows: [GenerateSerializer]
[Alias("CommandOutcome")]
public record CommandOutcome
{
private readonly List<Problem> _problems = [];
...
[Id(0)]
public List<Problem> Problems
{
get => _problems;
set => _problems.AddRange(value);
} |
And if we substitute |
Just discovered that we can also resolve it as follows: [GenerateSerializer]
[Alias("CommandOutcome")]
public record CommandOutcome
{
[Id(1)]
private readonly List<Problem> _problems = [];
...
[Id(0)]
public List<Problem> Problems
{
get => _problems;
set => _problems.AddRange(value);
} In this case, the collection expression works. Very interesting... |
Oh, make sure you only give the field an |
It does have a default constructor.
This seems like a worthwhile addition to the Serialization in Orleans documentation. |
This is related - but also pretty much all public Task<IReadOnlySet<string>> ThisWillBreakSerialization() {
return new HashSet<string> { "Hello World" }.ToFrozenSet();
} |
The new fancy .NET 8 collection initialization expression uses types that are not compatible with Orleans 8.
I'm posting the issue here first, and a test to illustrate. I'll try to work on a PR tomorrow.
Example
The text was updated successfully, but these errors were encountered: