The following post is more or less a copy-paste of a question I posted on stackoverflow.
My colleagues suggested me to also post a question here on JIRA, so here I am.
I also provided a minimalistic sample code to reproduce the error.
===== ISSUE AND QUESTION ====
I'm currently having a strange issue with the latest mongodb c# driver (2.7), inheritance and serialization.I'm currently having a strange issue with the latest mongodb c# driver (2.7), inheritance and serialization.
Here is a super simplified class hierarchy that I'm using:
When I try to register the class for mongo serialization, I am getting an error:
The error is:
Now, and this is where things start to get weird, when I tried to understand what was happening I made some changes to the BaseClass or the DerivedClass.
ANY of the two changes listed below will make the `RegisterClassMap` method work without errors...
change 1: adding a second, unused property on BaseClass
change 2: changing the Id property to have a non-private setter (any other works)
My question is... what is happening? While I may agree that for the serializer you should have an accessible setter for every property on the class that you want to map (in this case, DerivedClass), why the case #1 is actually not giving any error?