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.
It appears that setting MaxCharactersInDocument property to a negative value in
System.Xml.XmlReaderSettings class in Xaramin Android and mono 3.3.0 results in inconsistent behavior when
compared to Windows phone 8.1 and .Net 4.5. In .Net, trying to set this property to a negative value results in an
ArgumentOutOfRangeException. However, in mono, so such exception is thrown and the property successfully is set to a negative value. Since this property denotes the maximum allowable number of character in an XML document, it seems the .Net behavior of not allowing a negative value to be more plausible.
To reproduce this issue, run the following code snippet:
System.Xml.XmlReaderSettings v0 = new System.Xml.XmlReaderSettings();
((System.Xml.XmlReaderSettings)v0).MaxCharactersInDocument = -10 ;
catch (System.ArgumentOutOfRangeException e)
Windows Phone 8.1/ .Net 4.5 result:
"Specified argument was out of the range of valid values.
Parameter name: value"
Xamarin Android/Mono 3.3.0 result:
No exceptions are thrown
This code snippet was placed in a PCL project and was run on an android 4.4.2
emulator and a Windows Phone 8.1 emulator and .Net 4.5 on the Desktop.
Additionally, the code snippet was compiled using mono 3.3.0, which matched the Xamarin android behavior.
Additional Build Environment info:
Xamarin.Android Version: 4.16.0 (Business Edition)
Java SDK: C:\Program Files (x86)\Java\jdk1.6.0_39
Also repros in `csharp`:
$ csharp -r:System.Xml
csharp> using System.Xml;
csharp> var s = new System.Xml.XmlReaderSettings();
csharp> s.MaxCharactersInDocument = -10;
No exception is generated.
Now our XmlReaderSettings is based on referencesource, even this no-one-would-actually-depend-on-it kind of difference is also gone. It was even documented as MonoTODO.