akkadotnet / akkadotnet/Hyperion
Preserving object references doesn't work
Open
@Horusiath is already working on this.
Since Jan 8, 2018.
bug
- Dominant language
- C#
- Stars
- 281
- Forks
- 62
- PR merge metrics
- No merged PRs in 30d
Description
While working on #82 I've found out that SerializerOptions.PreserveObjectReferences actually never worked for user-defined objects. Example:
var serializer = new Serializer(new SerializerOptions(preserveObjectReferences: true));
var serializerSession = new SerializerSession(serializer);
var deserializerSession = new DeserializerSession(serializer);
using (var stream = new MemoryStream())
{
var o = new MyClass {First = "hello", Second = 123};
serializer.Serialize(o, stream, serializerSession); // serialize object 1st time
stream.Position = 0;
serializer.Serialize(o, stream, serializerSession); // serialize it again using the same session
}
First serialization passes, but second one throws ArgumentException: An item with the same key has already been added.. From what I've seen, generated object serializer simply doesn't look it object has been saved previously before trying to serialize it again.
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.
Assessment
This issue has not been assessed yet.