Lost on the subcontinent

Distributed Agile, .NET, ThoughtLife

<December 2008>
SuMoTuWeThFrSa
30123456
78910111213
14151617181920
21222324252627
28293031123
45678910


Navigation

Subscriptions

Post Categories



Sunday, April 15, 2007 - Posts

Questionable design changes in System.Xml for .NET 2.0

We recently converted CCNet to .NET 2.0, and I've been changing the code to start to take advantage of some of the changes in the .NET 2.0 release. One area of the framework that seems to have undergone a bit of a facelift is System.Xml as is evident by the number of obsolete classes and methods. The biggest apparent change is the recommendation to instantiate all XmlReaders via a factory method. I certainly support the intention behind this as the plethora of different XmlReaders all optimized for different tasks is something that should be encapsulated. However, I think that it is a bit of a shame that they decided to implement this through a factory method on XmlReader rather than more cleanly via separate factory class.

The biggest problem that I've found with this change is that not all of the different reader configurations are specifiable via the XmlReaderSettings. For CCNet, we allow users to set up DTD entities within the CCNet configuration files in order to minimize duplication. Under .NET 2, to instruct a reader to expand these entities, you need to set the EntityHandling property to EntityHandling.ExpandEntities (this required some digging to figure out as it just happened automatically in .NET 1.x). Unfortunately, this property is only delcared on XmlTextReader and not on the XmlReader base class. This means that you need to downcast the XmlReader that you get from XmlReader.Create() in order to set this property explicitly, which defeats the purpose of encapsulating the type of the reader behind the factory method. It seems to me to be an oversight to have neglected to include this property on the XmlReaderSettings class.

posted Sunday, April 15, 2007 8:27 PM by exortech with 0 Comments




Powered by Dot Net Junkies, by Telligent Systems