Bug/Patch

Jul 8, 2009 at 10:06 PM
Edited Jul 8, 2009 at 10:07 PM

I found a bug in XObjects.cs when adding objects to an IList<>.  This bug only occurs when the XSD processed is sufficiently complex.  Line 635 (of XObjects.cs) reading "stringValue = (string)datatype.ChangeType(value, XTypedServices.typeOfString);" should instead be:

 

var xType = value as XTypedElement;
if (xType != null)
        stringValue = xType.Untyped.Value;
else
        stringValue = (string)datatype.ChangeType(value, XTypedServices.typeOfString);

 

this patch sufficiently defers the problem so the condition will not exist (unfortunately, I don't think it solves the root problem of the ChangeType function).  Also, as a suggestion - it would be useful to provide a mechanism to validate XML documents be loaded/parsed within Linq-To-Xsd.  For example, you could pass/load a XmlSchemaSet to validate a XML document.