Bug 19012 - XmlArrayItemAttribute.IsNullable default does not match MS.NET default
Summary: XmlArrayItemAttribute.IsNullable default does not match MS.NET default
Status: RESOLVED FIXED
Alias: None
Product: Class Libraries
Classification: Mono
Component: System.XML ()
Version: 3.2.x
Hardware: PC Mac OS
: Normal normal
Target Milestone: Untriaged
Assignee: marcos.henrich
URL:
Depends on:
Blocks:
 
Reported: 2014-04-13 14:16 UTC by t9mike
Modified: 2014-11-27 05:52 UTC (History)
4 users (show)

Tags:
Is this bug a regression?: ---
Last known good build:


Attachments
Sample (14.27 KB, application/zip)
2014-04-13 14:17 UTC, t9mike
Details


Notice (2018-05-24): bugzilla.xamarin.com is now in read-only mode.

Please join us on Visual Studio Developer Community and in the Xamarin and 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 Links.

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.

Related Links:
Status:
RESOLVED FIXED

Description t9mike 2014-04-13 14:16:33 UTC
When serializing an object via XmlSerializer that uses XmlArrayItem attrribute:

        [XmlArrayItem("Element")]
        public List<MyElement> Elements;

Any null items in Elements list will not be serialized. This differs from Microsoft .NET Framrwork implementation which continues to serialize them.

A sample is attached that shows error under Mono console or iOS.

Under Microsoft .NET Framework  I get:

 <Elements>
    <Element>
      <Prop>Hello</Prop>
    </Element>
    <Element xsi:nil="true" />
    <Element>
      <Prop>World</Prop>
    </Element>
  </Elements>

But under Mono:

 <Elements>
    <Element>
      <Prop>Hello</Prop>
    </Element>
    ... null element skipped ...
    <Element>
      <Prop>World</Prop>
    </Element>
  </Elements>
Comment 1 t9mike 2014-04-13 14:17:18 UTC
Created attachment 6570 [details]
Sample
Comment 2 t9mike 2014-04-14 11:31:57 UTC
Version I used:

Xamarin Studio
Version 4.2.3 (build 60)
Runtime:
	Mono 3.2.6 ((no/9b58377)
	GTK+ 2.24.23 theme: Raleigh
	GTK# (2.12.0.0)
	Package version: 302060000

Xamarin.iOS
Version: 7.2.0.2 (Business Edition)
Hash: 58c3efa
Branch: 
Build date: 2014-10-03 18:02:26-0400

Build Information
Release ID: 402030060
Git revision: 30c4afc300c2a39ec5300851357ce02e49dd217e
Build date: 2014-03-05 22:09:33+0000
Xamarin addins: f8a9589b57c2bfab2ccd73c880e7ad81e3ecf044
Comment 3 t9mike 2014-04-21 21:11:00 UTC
How can I get this bug escalated? This is a show stopper for a new app.
Comment 4 t9mike 2014-04-27 09:27:43 UTC
The issue is that XmlArrayItemAttribute.IsNullable is true by default on MS.NET, and false on Mono. http://msdn.microsoft.com/en-us/library/system.xml.serialization.xmlarrayitemattribute.isnullable.aspx

I have a workaround by specifying this attribute property, but IMHO default should be changed in Mono for code compatibility.
Comment 5 marcos.henrich 2014-09-15 10:56:53 UTC
Hi t9mike,

Thank you for the detailed bug report.

The pull request for this issue can be found in the link below.
https://github.com/mono/mono/pull/1286
Comment 6 marcos.henrich 2014-09-15 12:25:09 UTC
Fixed in master b7fb7362544083b128df00fd7f4c1153cc1efbc5.
https://github.com/mono/mono/commit/b7fb7362544083b128df00fd7f4c1153cc1efbc5
Comment 7 Sadik Ali 2014-11-27 05:52:33 UTC
I have checked this issue with Attached project, it has been fixed. I checked elements result with iOS and Console project. I am getting same result in iOS project as getting in Console project. Null items in Elements list are also getting serialized. 

Screencast : http://www.screencast.com/t/BD2eWBuu

Environment Info:
=== Xamarin Studio ===

Version 5.7 (build 596)
Installation UUID: 67eaf3b4-f8a7-4ab4-a9df-3197350ca5dc
Runtime:
	Mono 3.12.0 ((detached/b75fa2b)
	GTK+ 2.24.23 (Raleigh theme)

	Package version: 312000046

=== Apple Developer Tools ===

Xcode 6.2 (6736)
Build 6C86e

=== Xamarin.iOS ===

Version: 8.6.0.5 (Business Edition)
Hash: 880cc21
Branch: 
Build date: 2014-11-25 12:12:17-0500

=== Xamarin.Android ===

Version: 5.0.0.0 (Business Edition)
Android SDK: /Users/ixamarin78/Desktop/android-sdk-macosx
	Supported Android versions:
		2.3    (API level 10)
		4.0.3  (API level 15)
		4.1    (API level 16)
		4.2    (API level 17)
		4.3    (API level 18)
		4.4    (API level 19)
		4.4.87 (API level 20)
		5.0    (API level 21)
Java SDK: /usr
java version "1.8.0_25"
Java(TM) SE Runtime Environment (build 1.8.0_25-b17)
Java HotSpot(TM) 64-Bit Server VM (build 25.25-b02, mixed mode)

=== Xamarin.Mac ===

Version: 1.10.0.18 (Business Edition)

=== Build Information ===

Release ID: 507000596
Git revision: d996e9ba6874a0d64241e43e5e6b06322ce29c84
Build date: 2014-11-25 17:17:54-05
Xamarin addins: 8ca19707b41536a391f53364ee4ff9272711feb0

=== Operating System ===

Mac OS X 10.10.0
Darwin XamnewiMac.local 14.0.0 Darwin Kernel Version 14.0.0
    Fri Sep 19 00:26:44 PDT 2014
    root:xnu-2782.1.97~2/RELEASE_X86_64 x86_64