I want to save specific classes, and since xml serialization will not do this in my case, I save the values manually in an XML document. It works great, but he doesn’t like FxCop, and since FxCop usually gives good advice and reasons why I shouldn’t do something in a certain way, I try to keep him happy.
This time I do not understand how this improvement.
This is what I had:
public void Save() { XmlDocument doc = new XmlDocument(); XmlNode XmlNodeJob = doc.CreateElement("Job"); doc.AppendChild(XmlNodeJob); OtherclassSave2(XmlNodeJob);
And this is what FxCop complained: “Change the member of“ OtherclassSave2 (XmlNode) ”so that it no longer shows the specific type“ XmlNode. ”Use IXPathNavigable to represent XML data sources.”
And now my wonderful solution:
public void Save() { XmlDocument doc = new XmlDocument(); XmlNode XmlNodeJob = doc.CreateElement("Job"); doc.AppendChild(XmlNodeJob); OtherclassSave2(XmlNodeJob.CreateNavigator());
This way I get my node in another method, and FxCop is happy, but I really don't see the improvement, and I need node to add something to it, and not read it.
Although I’m talking about changing void SaveInThisNode (XmlNode) to XmlNode GetMeTheNode (), but to create nodes via CreateElements I need an XmlDocument object that I am not allowed to use as a parameter, but I could create new XmlDocuments at each level, fine.
My solution was simple and worked perfectly in everything I wanted, but FxCop does not seem to allow solutions that are clearly no worse and more complex.
source share