[Mono-dev] Issues with XElement.Load() & XmlReader.Create()
Atsushi Eno
atsushi at ximian.com
Wed Apr 30 01:41:41 EDT 2008
1) I don't, without concrete patch. But any fixes are welcome.
2) That's non-issue, nor are we hobby copycats that are glad to
waste time on mimicking .net behavior.
Atsushi Eno
Sasha Kogan wrote:
>
>
> To reproduce the bug:
>
> in MonoTests.System.Xml.Linq.XNodeReaderTest.CreateReader1()
> (XNodeReaderTest.cs:43) replace XDocument.Parse(xml) call with
> XDocument.Parse(xml, LoadOptions.PreserveWhitespace).
>
> The test will fail with the following stack:
>
>
>
> System.InvalidOperationException: Node type None is not supported
>
> at System.Xml.Linq.XNode.ReadFrom(XmlReader r, LoadOptions options)
> in
> C:\MonoSVN\source\trunk\mcs\class\System.Xml.Linq\System.Xml.Linq\XNode.cs:line
> 184
>
> at System.Xml.Linq.XContainer.ReadContentFrom(XmlReader reader,
> LoadOptions options) in
> C:\MonoSVN\source\trunk\mcs\class\System.Xml.Linq\System.Xml.Linq\XContainer.cs:line
> 196
>
> at System.Xml.Linq.XElement.LoadCore(XmlReader r, LoadOptions
> options) in
> C:\MonoSVN\source\trunk\mcs\class\System.Xml.Linq\System.Xml.Linq\XElement.cs:line
> 421
>
> at System.Xml.Linq.XElement.Load(XmlReader reader, LoadOptions
> options) in
> C:\MonoSVN\source\trunk\mcs\class\System.Xml.Linq\System.Xml.Linq\XElement.cs:line
> 395
>
> at System.Xml.Linq.XNode.ReadFrom(XmlReader r, LoadOptions options)
> in
> C:\MonoSVN\source\trunk\mcs\class\System.Xml.Linq\System.Xml.Linq\XNode.cs:line
> 152
>
> at System.Xml.Linq.XContainer.ReadContentFrom(XmlReader reader,
> LoadOptions options) in
> C:\MonoSVN\source\trunk\mcs\class\System.Xml.Linq\System.Xml.Linq\XContainer.cs:line
> 196
>
> at System.Xml.Linq.XDocument.ReadContent(XmlReader reader,
> LoadOptions options) in
> C:\MonoSVN\source\trunk\mcs\class\System.Xml.Linq\System.Xml.Linq\XDocument.cs:line
> 150
>
> at System.Xml.Linq.XDocument.LoadCore(XmlReader reader, LoadOptions
> options) in
> C:\MonoSVN\source\trunk\mcs\class\System.Xml.Linq\System.Xml.Linq\XDocument.cs:line
> 135
>
> at System.Xml.Linq.XDocument.Load(TextReader reader, LoadOptions
> options) in
> C:\MonoSVN\source\trunk\mcs\class\System.Xml.Linq\System.Xml.Linq\XDocument.cs:line
> 114
>
> at System.Xml.Linq.XDocument.Parse(String s, LoadOptions options) in
> C:\MonoSVN\source\trunk\mcs\class\System.Xml.Linq\System.Xml.Linq\XDocument.cs:line
> 173
>
> ...
>
>
>
> The failure is due to "using (XmlReader r = XmlReader.Create (reader,
> s))" statement in XElement.cs:394.
>
> In some cases the instance returned by XmlReader.Create() is 'reader'
> itself, thus r.Dispose() at the end of the recursive call invalidates
> the reader and the
>
> attempt to process the next element fails.
>
> Although MS API states that XmlReader.Create(XmlReader reader,
> XmlReaderSettings settings) returns a wrapper that uses the given
> instance as an underlying reader,
>
> MS implementation returns 'reader' itself in some cases (I think
> that's true iff 'settings' is same as 'reader''s settings, but I'm not
> 100% sure). Mono behavior is different –
>
> it returns the instance itself or a wrapper depending on specific
> flags in settings.
>
>
>
> The bottom line is that we have 2 issues here:
>
>
>
> 1) XElement.Load() should not dispose the XmlReader instance upon
> completion of recursive calls (if you approve, I’ll fix that).
>
> 2) Inconsistent XmlReader.Create() behavior (meaning not consistent
> with the API-breaking MS implementation...).
>
>
>
> Pls your comments & suggestions.
>
>
>
> ** /Sasha **
>
>
>
More information about the Mono-devel-list
mailing list