1 // Mono.Util.CorCompare.MissingBase
4 // Piers Haken (piersh@friskit.com)
6 // (C) 2001-2002 Piers Haken
9 using System.Reflection;
10 using System.Collections;
12 namespace Mono.Util.CorCompare
15 /// Base class for all comparison items
18 /// created by - Piersh
19 /// created on - 3/3/2002 10:23:24 AM
21 public abstract class MissingBase
23 protected NodeStatus m_nodeStatus;
24 protected ArrayList rgAttributes;
25 protected NodeStatus nsAttributes;
27 public enum Accessibility
38 /// The name of the element (eg "System.Xml")
40 public abstract string Name { get ; }
43 /// The type of the element (eg "namespace")
45 public abstract string Type { get; }
48 /// Generates an XmlElement describint this element
50 /// <param name="doc">The document in which to create the element</param>
51 /// <returns></returns>
52 public virtual XmlElement CreateXML (XmlDocument doc)
54 XmlElement eltMissing = doc.CreateElement (Type);
55 eltMissing.SetAttribute ("name", Name);
56 //Status.status.SetAttributes (eltMissing);
57 Status.SetAttributes (eltMissing);
59 XmlElement eltAttributes = MissingBase.CreateMemberCollectionElement ("attributes", rgAttributes, nsAttributes, doc);
60 if (eltAttributes != null)
61 eltMissing.AppendChild (eltAttributes);
66 public virtual NodeStatus Status
68 get { return m_nodeStatus; }
71 public abstract NodeStatus Analyze ();
74 /// Creates an XmlElement grouping together a set of sub-elements
76 /// <param name="name">the name of the element to create</param>
77 /// <param name="rgMembers">a list of sub-elements</param>
78 /// <param name="doc">the document in which to create the element</param>
79 /// <returns></returns>
80 public static XmlElement CreateMemberCollectionElement (string name, ArrayList rgMembers, NodeStatus ns, XmlDocument doc)
82 XmlElement element = null;
83 if (rgMembers != null && rgMembers.Count > 0)
85 element = doc.CreateElement(name);
86 foreach (MissingBase mm in rgMembers)
87 element.AppendChild (mm.CreateXML (doc));
89 //ns.SetAttributes (element);
93 protected void AddFakeAttribute (bool fMono, bool fMS, string strName)
97 MissingAttribute ma = new MissingAttribute (
98 (fMono) ? strName : null,
99 (fMS) ? strName : null);
101 rgAttributes.Add (ma);
102 nsAttributes.AddChildren (ma.Status);
106 protected void AddFlagWarning (bool fMono, bool fMS, string strName)
109 m_nodeStatus.AddWarning ("Should be " + strName);
110 else if (fMono && !fMS)
111 m_nodeStatus.AddWarning ("Should not be " + strName);
114 protected string AccessibilityToString (Accessibility ac)
118 case Accessibility.Public:
120 case Accessibility.Assembly:
122 case Accessibility.FamilyOrAssembly:
123 return "protected internal";
124 case Accessibility.Family:
126 case Accessibility.FamilyAndAssembly:
127 return "protected"; // TODO:
128 case Accessibility.Private:
131 throw new Exception ("Invalid accessibility: "+ac.ToString ());