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.
In System.Xml.Serialization, XmlCustomFormater.cs the method GenerateToXmlStringCore does not correctly handle a null value for base64Binary and hexBinary. It returns String.Empty, but it should return null. In other words those two cases should look like this:
case "base64Binary": return value + " == null ? null : Convert.ToBase64String (" + value + ")";
case "hexBinary": return value + " == null ? null : ToBinHexString (" + value + ")";
Also, for the sake of consistency, the method ToXmlString should be fixed as well; however in this case the null checks are unnecessary since there is already a check before entering the switch statement.
Created attachment 1544 [details]
Proposed patch to XmlCustomFormatter.cs
I'm not sure why we need this. Does this differentiate the serialization results?
(No one is working on this namespace now so no one can guess what it is for.)
After creating and XML-serializing a new class with a null-able and not set property, output string will NOT contain this property TAG (it's correct behavior) and sometimes (NOT ALWAYS!, it's a function of time, hard to say who is blamable for this GC??? and when it can happen) it contains just closed tag <myproperty /> - this is not correct behavior. After such class de-serialization this property value will be equal to String.Empty (if property of type String) instead of NULL.
We have not received the requested information. If you are still experiencing this issue please provide all the requested information and reopen the bug report.