Types should not derive from System.Xml.XmlDocument

Rule ND2601 .NET Framework Usage / System.Xml

Warns about subclasses of System.Xml.XmlDocument: don't subclass it to create an XML view of an underlying object model or data source.

How to fix

Use the System.Xml.XPath.IXPathNavigable interface implemented by XmlDocument, or use System.Xml.Linq.XDocument (LINQ2XML). More: http://stackoverflow.com/questions/1542073/xdocument-or-xmldocument

CQLinq source

This rule is written in CQLinq, C# LINQ over the NDepend code model. It ships with every new NDepend project: you can read it, adapt it, or use it as a starting point for your own custom rules.

// <Name>Types should not derive from System.Xml.XmlDocument</Name>
// <Id>ND2601:TypesShouldNotExtendSystemXmlXmlDocument</Id>

warnif count > 0 from t in Application.Types where
   t.DeriveFrom("System.Xml.XmlDocument".AllowNoMatch())
select new {
   t,
   Debt = 20.ToMinutes().ToDebt(),
   Severity = Severity.Medium
}

//<Expl>
// The *{0}* should not derive from *XmlDocument*.
// Instead use the *LINQ2XML* *System.Xml.Linq.XDocument* class.
//</Expl>

//<Desc>
// Warns about subclasses of **System.Xml.XmlDocument**: don't subclass it
// to create an XML view of an underlying object model or data source.
//</Desc>

//<HowToFix>
// Use the **System.Xml.XPath.IXPathNavigable** interface implemented by
// *XmlDocument*, or use **System.Xml.Linq.XDocument** (**LINQ2XML**). More:
// http://stackoverflow.com/questions/1542073/xdocument-or-xmldocument
//</HowToFix>

.NET Framework Usage / System.Xml: all 2 items