Second item in collection won't get deserialized
I have put the example code and used XSD's in this zip file:
XmlSchemaClassGeneratorExample.csproj is the generator for the code.
XmlSchemaClassGeneratorUseGenerated.csproj is the project which uses the generated code.
In project XmlSchemaClassGeneratorUseGenerated.csproj I deserialize:
<wfs:GetFeature xmlns:wfs="http://www.opengis.net/wfs/2.0" version="2.0.0" service="WFS" count="300" >
<wfs:Query typeNames="islands" srsName="EPSG:4326">
<fes:Filter xmlns:fes="http://www.opengis.net/fes/2.0" xmlns:gml="http://www.opengis.net/gml/3.2">
<fes:And>
<fes:Or>
<fes:PropertyIsLike escapeChar="\" singleChar="_" wildCard="%">
<fes:ValueReference>_key</fes:ValueReference>
<fes:Literal>%ISLAND</fes:Literal>
</fes:PropertyIsLike>
<fes:PropertyIsLike escapeChar="\" singleChar="_" wildCard="%">
<fes:ValueReference>_key</fes:ValueReference>
<fes:Literal>%ISLE</fes:Literal>
</fes:PropertyIsLike>
</fes:Or>
<fes:Intersects>
<fes:ValueReference>_geometry</fes:ValueReference>
<gml:Polygon srsName="urn:ogc:def:crs:EPSG::4326">
<gml:exterior>
<gml:LinearRing>
<gml:posList srsDimension="2">51.54466944888950053 4.0634507076977302 51.5539658802964027 4.06233249515291028 51.5560068508855025 4.08334931092553965 51.54611787831689895 4.09453962326862975 51.54005270284209672 4.07558429886301976 51.54203343526010173 4.06388044468392007 51.54203343526010173 4.06388044468392007 51.54466944888950053 4.0634507076977302</gml:posList>
</gml:LinearRing>
</gml:exterior>
</gml:Polygon>
</fes:Intersects>
</fes:And>
</fes:Filter>
</wfs:Query>
</wfs:GetFeature>
But the second fes:PropertyIsLike (%ISLE) isn't deserialized into the object.
Setting the GenerateComplexTypesForCollections to false also results in uncompilable code.
Is it a setting or a bug?
The latest version sort of fixes this. You'll probably have to set GenerateInterfaces to false, too. By sort of I mean there are scenarios where it doesn't work but it seems to work with this schema.
This works. But I am now using a NamespaceProvider. And that seems to exclude the Intersects XmlNode. I will try to isolate the issue.
I can't isolate that issue yet. But I have found another one.
Can you explain why:
[System.Xml.Serialization.XmlElementAttribute("And", Type=typeof(BinaryLogicOpType), Namespace="http://www.opengis.net/fes/2.0")]
[System.Xml.Serialization.XmlElementAttribute("Or", Type=typeof(Or), Namespace="http://www.opengis.net/fes/2.0")]
The Or gets the name Or. But And gets BinaryLogicOpType, which seems faulty.
Or should I open a new issue for that?
Both Or and And are (possible) root elements. There can be only one XmlRootAttribute on a class. That's why the Or class is an empty class that derives from BinaryLogicOpType.
Wouldn't it be possible to choose And as a name for And.
What would be best in this case is:
BinaryLogicOpType would become an abstract class.
And and Or would both derive from that.
There are more similar example of this happening on other classes... I can point them out if you like, hopefully this can be improved...
I made And and Or both get their individual classes which derive from BinaryLogicOpType. Couldn't make it abstract because there may also be non-root elements which don't get individual classes that reference the base class.
Now your example works nicely AFAICT.
I'll report back soon. I guess in a week or two.