question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Deserialization State Exception When Reference Entity Has Attribute-based Property

See original GitHub issue

Hey folks,

About the issue

I encountered a weird behavior with Extended XML serializer 3.6.0 yesterday: we have a pretty complex model where some entities reference each other, thus we enabled references in the ConfigurationContainer. More precisely, our model consists of a map that is the container object for several other entities like nodes, obstacles, storage rows, etc. Consequently, the map has a collection for each entity type.

Everything worked fine (for several months) until we added a new property to one of our entities. After that, ExtendedXmlSerializer no longer set the aforementioned collection properties while deserializing a map.

Minimal, complete, verifiable example

I have created a MCVE that you can find in this GitHub repo: https://github.com/Synnotech-AG/VweXmlSetCollectionsError

The repo contains the source code of ExtendedXmlSerializer as well as two additional projects: one of them is a simplified version of our core model, the other one is a test project with six tests. The repo contains two branches: if you checkout the working-mcve branch and run the tests, you will see that everything works as expected:

Succesful tests in branch working-mcve

If you then switch to the failing-mcve branch, you will see that we added a simple property to the StorageLocation class:

New Type Property on StorageLocation class

However if we run the tests again, some of the serialization tests fail:

Failing tests after property was defined

The one you should focus on is called SerializeSmallMap - it has the least instances involved.

What I’ve tried so far

I have only put in a few hours, but this is what I gathered so far:

  • The call to Deserialize does not throw, it simply does not set the collection properties on the Map object.
  • It doesn’t matter if you change the name of the new property
  • If the property is nullable and has null assigned to it, then deserialization works. However, if it is any other string value, deserialization fails in the same way as described above.
  • I tried to debug the tests to figure out what goes wrong but I couldn’t really find the source of the issue. As far as I understand the ExtendedXmlSerializer source, you dynamically generate code at runtime and call these via delegates, but I still need to figure out where the code is generated that sets the collections for the map.
  • I’m pretty sure that this issue is machine-independent. We encounter the same behavior on two dev machines as well as on our build server.

As always, thank you so much for your help in advance. I think this is a great project! I hope we can resolve this issue soon.

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Comments:15 (9 by maintainers)

github_iconTop GitHub Comments

1reaction
Mike-E-angelocommented, Mar 9, 2021

FWIW we are currently blocked on a release due to NextRelease issues. They are looking into it and should have something here in the next day, I am hoping. 🤞 I will update here accordingly.

1reaction
Mike-E-angelocommented, Mar 4, 2021

Oh wow, thank you for that! I did consider doing the sponsorship thing at one point but ultimately decided against it. I might though if others do ask for it, although my feeling is that I do not want to encourage it as it really is no longer a primary focus in my life (sad to say in this regard but happy in another… more on that below).

I obviously do not do this for the money but more of a call to a neurotic sense of duty, haha. I started out this version of the project in some ways to prove myself as a developer. Now I have all this code I have to support. Amazingly, I somehow manage to make it work, but it’s a kind, enduring reminder to be careful of what I wish for in life. 😉

BTW, if you do want to support me, please sign up for the project that I am actively working on now:

https://starbeam.one

I am hoping to have something to share later on this year (August-ish, I am hoping 🤞).

Don’t forget to use a burner address, I use this nifty service extensively, myself: https://burnermail.io/

Thanks again for the kind thoughts! It made my day.

<div>Sign Up for The Starbeam Project!</div><div> Welcome to The Starbeam Project's registration page. I am currently brain-deep developing this sucker. If you'd like to get notified when it's ready to try out, submit your email address below and I'll contact you when it's ready! -- Mike-E-angelo </div>
<div>Burner Mail - Fast, Easy, Burner Email Addresses</div><div>One-click burner email addresses that you can use when signing up on websites to protect your identity and prevent your personal email address from being sold or spammed.</div>
Read more comments on GitHub >

github_iconTop Results From Across the Web

Deserialization of reference types without parameterless ...
The answer from jawa states that Deserializing to immutable classes and structs can be achieved with System.Text.Json, by creating a custom ...
Read more >
How to preserve references in System.Text.Json
Learn how to preserve references and handle or ignore circular references while using System.Text.Json to serialize and deserialize JSON in ...
Read more >
How to ignore properties with System.Text.Json
Never - The property is always serialized and deserialized, regardless of the DefaultIgnoreCondition , IgnoreReadOnlyProperties , and ...
Read more >
Different Serialization Approaches for Java
Learn several approaches for serializing Java objects using third-party libraries or core Java's built-in serialization API.
Read more >
Introduction to Java Serialization
The serialization process is instance-independent; for example, we can serialize objects on one platform and deserialize them on another.
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found