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.
Created attachment 6002 [details]
## Steps to reproduce
1. Compile and run the attached test project using Mono.
2. Compile and run the attached test project using .NET.
### Excerpt from .NET output
<a:anyType i:type="b:guid" xmlns:b="http://schemas.microsoft.com/2003/10/Serialization/">00000000-0000-0000-0000-000000000000</a:anyType>
### Excerpt from Mono output
<d2p1:anyType xmlns:d3p1="http://www.w3.org/2001/XMLSchema" i:type="d3p1:guid">00000000-0000-0000-0000-000000000000</d2p1:anyType>
`System.Guid` does _not_ map to an XML Schema (XSD) primitive type. See for example [1, 2]. Similarly, `System.Char` does not map to an XML Schema primitive type. Therefore, in both cases the appropriate namespace is actually:
... rather than:
>  The "Type/primitive mapping" section on http://msdn.microsoft.com/en-us/library/ms733112.aspx
>  http://www.w3.org/TR/2012/REC-xmlschema11-2-20120405/datatypes.html#built-in-primitive-datatypes
Created attachment 6003 [details]
This patch changes the logic in XmlFormatterSerializer.Serialize(). It now checks the `qname.Name` against the list of XSD primitive type names, taken from .
>  http://msdn.microsoft.com/en-us/library/ms733112.aspx
This fixes the test case, and also the `System.Char` case. It also does not break the serialization of types that _do_ map to XSD primitive types, for example `System.Int32`.
Created attachment 6010 [details]
My original patch was wasteful. The list of XSD primitive types is already contained once in the private `KnownTypeCollection.xs_predefined_types` field, and also a couple of times in the System.Xml.Schema namespace.
This new patch uses the public, static `XmlSchemaType.GetBuiltInSimpleType()` method  to check if the `qname.Name` can be matched to a "simple type" within the `XmlSchema.Namespace` namespace.
Atsushi, could you review this patch and approve if OK?
The change is looking good.
(Though since it's fairly doable we'd want a test case. Maybe Test/System.Runtime.Serialization/XmlObjectSerializerTest.cs has similar ones that helps writing one for this case.)
Created attachment 6126 [details]
Sounds good. Here are two tests, one each for Guid and Char. The tests fail before the patch for `XmlFormatterSerializer.Serialize()` has been applied, but succeed after.
The tests also pass on Windows.
Oh I thought you already committed your patch to mono. You can do it.
Applied patch and tests
Thank you Brendan!