title: XmlDocument interface to resolve code analysis warning CA1059
body: <p>I have an interface and when I run the code analysis tool for Visual Studio I get the error:</p>
  <blockquote>
  <p>CA1059 <strong>Members should not expose certain concrete types</strong></p>
  <p>Modify member 'ISharedRepository.RunNewsHeadlinesReport(string)' so that it
  no longer exposes the concrete type 'XmlDocument'. Use IXPathNavigable
  to represent XML data
  sources.  Ev.Pharma.Business  ISharedRepository.cs    8</p>
  </blockquote>
  <p>The interface I have is:</p>
  <pre><code>public interface ISharedRepository
  {
      XmlDocument RunWhatsNewHeadlinesReport();
      XmlDocument RunNewsHeadlinesReport(string reportId);
  }
  </code></pre>
  <p>I am using XmlDocument as the code is intended to work with some legacy code, and the ability to modify the document is crucial. I would love to use XDocument however there is a lot of code which would need changing to use XDocument and I would have to cast an XmlDocument to an XDocument somewhere along the lines to get the code to work.</p>
  <p>The suggestion I can find online is to use the IXPathNavigable interface in place of XmlDocument however in doing so I'm no longer able to call the XmlDocument methods as these methods are not part of the IXPathNavigable  interface.</p>
  <p>This error seems a bit pointless to me as I never plan on swapping out the XmlDocument for a different concrete type. Should I just suppress the error or should I change my code somehow to get rid of the warning?</p>