Xml descriptor destruction fails in a NUnit project, but not on a platform

We are creating a package to deserialize certain XML files using the code generated by xsd.exe. Some "though" s:

  • We use Xamarin (iOS and Android) using Visual Studio for Mac 2017.
  • We use MvvmCross-setup with a kernel (PCL), platform, and collaborative code projects, although MvvmCross is not involved in this problem.
  • The code generated by xsd.exe is in the shared code project.
  • Because we want to use deserialized objects in the kernel / PCL, we extracted the interfaces from the types generated by xsd.exe, and allowed the generated types to implement these interfaces.
  • To do this, all the properties used by the deserializer were annotated with [XmlElement(Type = <concrete-type>)], since the properties themselves are now interfaces.

When using this design on platforms, it works fine.

Although when using this in a NUnit project, we get an exception:

System.NotSupportedException: cannot serialize type <specific type of type of type <interface-type>, because it is an interface.

As if the attribute was [XmlElement]not there.

We have not yet been able to find the reason and hope to find wisdom here :-) So does anyone know why this is happening and / or how we can solve it?

Btw: If there is any simpler or more efficient way to use XML deserialization using PCL code, let me know.

Additional Information

  • "" , . , , .
  • NUnit , .NET. , , , .
  • System.Xml-:
    • iOS-project: System.Xml v2.0.5.0 Xamarin.iOS
    • Android-: System.Xml v2.0.5.0 Xamarin.Android
    • NUnit-project: System.Xml v4.0.0.0.NET Framework v4.6.1
+4

Source: https://habr.com/ru/post/1681370/


All Articles