title: FxCop Complaint: Exposed concrete xml types and a bad improvement
body: <p>I want to save certain classes and since xml-serialization won't do it in my case i'm saving the values manually into an xml-document. Works fine, but FxCop doesn't like it and since FxCop normally gives good advice and reasons why i shouldn't do things in a certain way i try to keep it happy. </p>
  
  <p>This time, i dont understand how this is an improvement.</p>
  
  <p>This is what i had:</p>
  
  <pre><code>public void Save()
  {
        XmlDocument doc = new XmlDocument();
        XmlNode XmlNodeJob = doc.CreateElement("Job");
        doc.AppendChild(XmlNodeJob);
        OtherclassSave2(XmlNodeJob);//Node as Parameter
   }
  
   public void OtherclassSave2(XmlNode node)
   {
  
   }
  </code></pre>
  
  <p>And this is what FxCop complained:
  <em>"Modify member 'OtherclassSave2(XmlNode)' so that it no longer exposes the concrete type 'XmlNode'. Use IXPathNavigable to represent XML data sources."</em></p>
  
  <p>And now my awesome solution:</p>
  
  <blockquote>
  <pre><code>    public void Save()
      {
          XmlDocument doc = new XmlDocument();
          XmlNode XmlNodeJob = doc.CreateElement("Job");
          doc.AppendChild(XmlNodeJob);
          OtherclassSave2(XmlNodeJob.CreateNavigator());//Interface from a node's navigator
      }
  
      public void OtherclassSave2(IXPathNavigable nav)
      {
          XmlNode node = (XmlNode)(nav.CreateNavigator().UnderlyingObject);
  
      }
  </code></pre>
  </blockquote>
  
  <p>This way i get my node in the other method and FxCop is happy, but i really don't see the improvement and i need a node to add things in it, not something to read.</p>
  
  <p>I though about changing void <em>SaveInThisNode(XmlNode)</em> into a <em>XmlNode GetMeTheNode()</em> but to create nodes via CreateElements, i need the XmlDocument-object which i am not allowed to use as a parameter, but i could create new XmlDocuments in every step, fine. </p>
  
  <p>My solution was simple and worked fine for everything i wanted it to do, but FxCop does not seem to allow solutions that are not obviously worse and more complicated.</p>