Serializing polymorphic records with constructor parameters
Nobody has claimed this yet.
- Dominant language
- C#
- Stars
- 10.9k
- Forks
- 2.1k
- Avg merge
- 13h 56m
- Merged PRs (30d)
- 351
Description
Is serializing polymorphic records with constructor parameters supposed to work?
I mean something like this:
[GenerateSerializer]
public abstract record BaseRecord
{
public abstract int test();
}
[GenerateSerializer]
public record DerivedRecord(int Value) : BaseRecord
{
public override int test() => Value;
}
And then:
public interface ITestGrain : IGrainWithGuidKey
{
Task<int> test(BaseRecord param);
}
public class TestGrain : Grain, ITestGrain
{
public async Task<int> test(BaseRecord param)
{
return param.test();
}
}
In my tests Value always has default value (zero). So result of the call is always zero (if serialization is involved, so not in local calls).
If I make Value a property instead of a constructor parameter then it works, but it means I can't easily make it read only.
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start with the [GenerateSerializer] records and the ITestGrain/TestGrain call shown in the issue, then reproduce the non-local call using DerivedRecord(int Value). Trace the serialization and deserialization path to determine why Value becomes zero; done means the constructor parameter survives serialization and the grain returns the original value.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- csharp
- Domain
- distributed-systems
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100