[Mono-dev] MS/Mono XmlWriter incompatibility
atsushi at ximian.com
Tue Feb 14 04:38:49 EST 2006
> I'm simply using Windows XP SP2 with VS2005. (v2.0.50727).
> I'm using Flush it's to ensure that xml is actually sent.
> I've tested with Framework 1.1 and the WriteString is effectively ignored.
> It seems that the behavior changes with Framework 2.0.
> I've attached a simple test app that reproduce it.
Thanks for the repro code. So it tells that WriteString("") behavior
is different between System.Xml.XmlTextWriter and the writer returned
by XmlWriter.Create(StringBuilder,XmlWriterSettings). What I tried
was XmlTextWriter which does not show such behavior differences.
We don't have different implementation than XmlTextWriter for
XmlWriter.Create(), so we can't simply change its behavior, at
least for now (someone who thinks that such implementation details
matter should contribute such XmlWriter class).
(Hint: it can be easily hacked by adding "isXmlWriterCreated"
field or whatever differentiates the origin in XmlTextWriter.)
So, there is another "compatibility" problem. What if Microsoft
changed internal implementation of XmlWriter.Create() in the
future version of .NET? That "factory method" is of cource to
hide implementation details (anyone who object this argument
should explain what the purpose of factory methods is). If users
depend on such undocumented behavior, Microsoft as well as we can
never make XmlWriter better than now.
If you depend on the implementation details, why not just simply
use those implementation classes, not from XmlWriter.Create()?
(Oops, yes MS does not expose the implementation class unlike
org.apache.xerces.parsers.SAXParser, so you just can't do that.)
BTW feel free to register it as a bug in bugzilla. I'm unlikely
to "fix" it, but it would help those who want to know compat issues.
For now it is easily workarounded by using either WriteCData("") or
WriteRaw("") as I indicated, so the priority is low.
More information about the Mono-devel-list