diff options
author | Atsushi Eno <atsushieno@gmail.com> | 2015-02-06 00:36:13 +0300 |
---|---|---|
committer | Atsushi Eno <atsushieno@gmail.com> | 2015-02-20 22:32:44 +0300 |
commit | 6499ba871d76036e6faa10961f23e6760f3b10e7 (patch) | |
tree | 81d99149efb18856c077d92efd99bdd50ce8d6e2 /mcs/class/System.Xml.Linq | |
parent | 923ed6b24174eb5d87390fad0993306133213227 (diff) |
[XLinq] create new instance of XmlSchemaInfo for each XObject from XmlReader.
In referencesource, XmlReader.SchemaInfo does not return different instances
for each node at its state but just returns the XmlReader itself (which
implements IXmlSchemaInfo). Hence, if we just set the corresponding
IXmlScemaInfo to each XObject, it results in inconsistent state.
This fixes two regressions in ExtensionsTest (XAttributeFailValidate and
XAttributeThrowExceptionValidate).
Diffstat (limited to 'mcs/class/System.Xml.Linq')
-rw-r--r-- | mcs/class/System.Xml.Linq/System.Xml.Schema/Extensions.cs | 16 |
1 files changed, 14 insertions, 2 deletions
diff --git a/mcs/class/System.Xml.Linq/System.Xml.Schema/Extensions.cs b/mcs/class/System.Xml.Linq/System.Xml.Schema/Extensions.cs index 7aa0bb9f009..4c167d8094a 100644 --- a/mcs/class/System.Xml.Linq/System.Xml.Schema/Extensions.cs +++ b/mcs/class/System.Xml.Linq/System.Xml.Schema/Extensions.cs @@ -84,15 +84,27 @@ namespace System.Xml.Schema while (xr.Read ()) { if (addSchemaInfo) { if (xr.NodeType == XmlNodeType.Element) { - xsource.CurrentNode.AddAnnotation (xr.SchemaInfo); + xsource.CurrentNode.AddAnnotation (CopySchemaInfo (xr.SchemaInfo)); while (xr.MoveToNextAttribute ()) if (xr.NamespaceURI != XUtil.XmlnsNamespace) - xsource.GetCurrentAttribute ().AddAnnotation (xr.SchemaInfo); + xsource.GetCurrentAttribute ().AddAnnotation (CopySchemaInfo (xr.SchemaInfo)); xr.MoveToElement (); } } } } + + static XmlSchemaInfo CopySchemaInfo (IXmlSchemaInfo src) + { + return new XmlSchemaInfo () { + IsDefault = src.IsDefault, + IsNil = src.IsNil, + MemberType = src.MemberType, + SchemaAttribute = src.SchemaAttribute, + SchemaElement = src.SchemaElement, + SchemaType = src.SchemaType, + Validity = src.Validity }; + } [MonoTODO] public static void Validate (this XElement source, XmlSchemaObject partialValidationType, XmlSchemaSet schemas, ValidationEventHandler validationEventHandler) |