Notice (2018-05-24): bugzilla.xamarin.com is now in
Please join us on
Visual Studio Developer Community and in the
Mono organizations on
GitHub to continue tracking issues. Bugzilla will remain
available for reference in read-only mode. We will continue to work
on open Bugzilla bugs, copy them to the new locations
as needed for follow-up, and add the new items under Related
Our sincere thanks to everyone who has contributed on this bug
tracker over the years. Thanks also for your understanding as we
make these adjustments and improvements for the future.
Please create a new report on
GitHub or Developer Community with
your current version information, steps to reproduce, and relevant error
messages or log files if you are hitting an issue that looks similar to
this resolved bug and you do not yet see a matching new report.
The polymorphism is NOT respected by Xamarin DataContractJsonSerializer (System.Runtime.Serialization.Json) (System.Runtime.Serialization.dll 220.127.116.11) in MonoAndroid & MonoTouch. I attach 4 test projects - Win8, Windows phone 8, Xamarin.Android, and Xamarin.iOS, and one file with the test output of four projects. (Polymorphism is respected ONLY in Win8 & WP8). The serialization testing code is in Win8 project and linked in other three projects.
The object graph is:
Then the properties in class Test are instantiated as such: Test1 is of type Test1, Test2 is of type Test2, TestList is of type Test1, and TestList is of type Test2.
The problem is that after serializing & deserializing with Xamarin DataContractJsonSerializer the properties in class Test are downgraded to its base : all Test1, Test2, TestList, and TestList are now of type TestBase.
Created attachment 4664 [details]
four simple test projects (win8, wp8, android and ios) + output
The same bug is present in desktop mono; edit TestSerialization/Win8Serialization/Win8Serialization/TestSerialization.cs and:
1. Add TestSerialization.Main():
static void Main ()
new TestSerialization ().Execute ();
2. Change TestSerialization.Log() to use Console.WriteLine(), not Debug.WriteLine():
public void Log(string info)
$ mcs TestSerialization.cs -r:System.Runtime.Serialization.dll
$ mono TestSerialization.exe
Works as expected with recent Mono versions