DeepCopy not generated for record primary constructor parameters in other assemblies
- Dominant language
- C#
- Stars
- 10.9k
- Forks
- 2.1k
- Avg merge
- 15h 1m
- Merged PRs (30d)
- 345
Description
I have a record type with primary constructor parameters in a separate assembly to an Orleans application which uses the GenerateCodeForDeclaringAssembly annotation to generate the serializers for the separate assembly. When serializing one of these records for a grain call, it does not throw an exception but instead gives back the default object. If you debug and step through the generated code, you can see the generated DeepCopy function does not copy the primary constructor parameters.
Here is an example record which does not work.
```C#
[GenerateSerializer]
public record UrlDetails(string FullUrl, string ShortenedRouteSegment)
{
public UrlDetails() : this("", "")
{
}
}
```
It is worth noting that it does work if you:
1. bring the record into the same assembly as the Orleans application
2. move the primary constructor parameters into fields
I have reproduced the issue in [this repository](https://github.com/tom-elvidge/orleans-record-serialization-issue). See line 37 and line 94 in `Application/Program.cs` for an example where `UrlDetails` is passed via a grain call. Setting a breakpoint at these lines will show the expected `UrlDetails` at line 37 just before the grain call but the default `UrlDetails` at line 94 within the grain.
Contributor guide
Assessment
This issue has not been assessed yet.