home: Deserialization State Exception When Reference Entity Has Attribute-based Property
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:
If you then switch to the failing-mcve
branch, you will see that we added a simple property to the StorageLocation
class:
However if we run the tests again, some of the serialization tests fail:
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 theMap
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.
About this issue
- Original URL
- State: closed
- Created 3 years ago
- Comments: 15 (9 by maintainers)
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.
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.
Is there any way I can sponsor you? You have been tremendously helpful, here as well as with other issues in the past. Couldn’t find anything in this repo about sponsorship, though.
Great! I will get this deployed to NuGet on Tuesday, our typical day of deployment. Please feel free to use the preview build until this time and do let me know of any additional issues you encounter. 👍
I’ve just checked it both on the MCVE as well as our project solution and it works great.
WHEW what a challenge. 😃
Check out the following, @feO2x and let me know if it treats you better: https://github.com/ExtendedXmlSerializer/home/pull/503#issuecomment-790637058
Please note that as part of that PR I have pulled in your tests/code from that repository and have made it a part of our test suite here going forward. Please let me know if that is a problem and I can work with you on resolution.
OK I have tracked this down to how the deserializer is processing reference/entity attributes when the reader context is within an attribute. This may be salvageable, no promises yet tho.