-// Mono.Util.CorCompare.MissingProperty\r
-//\r
-// Author(s):\r
-// Nick Drochak (ndrochak@gol.com)\r
-//\r
-// (C) 2001-2002 Nick Drochak\r
-\r
-using System;\r
-using System.Reflection;\r
-using System.Text;\r
-\r
-namespace Mono.Util.CorCompare {\r
-\r
- /// <summary>\r
- /// Represents a missing property from a class\r
- /// </summary>\r
- /// <remarks>\r
- /// created by - Nick\r
- /// created on - 2/20/2002 10:43:57 PM\r
- /// </remarks>\r
- class MissingProperty : IMissingMember \r
- {\r
- // e.g. <property name="Length" status="missing"/>\r
- MemberInfo info;\r
-\r
- public MissingProperty(MemberInfo pInfo) {\r
- info = pInfo;\r
- }\r
-\r
- public string Name {\r
- get {\r
- StringBuilder retVal = new StringBuilder(info.Name + "{");\r
- if (this.NeedsGet) {\r
- retVal.Append(" get;");\r
- }\r
- if (this.NeedsSet) {\r
- retVal.Append(" set;");\r
- }\r
-\r
- retVal.Append(" }");\r
- return retVal.ToString();\r
- }\r
- }\r
- public virtual string Status {\r
- get {\r
- return "missing";\r
- }\r
- }\r
-\r
- public string Type {\r
- get {\r
- return "property";\r
- }\r
- }\r
-\r
- public bool NeedsGet = false;\r
- public bool NeedsSet = false;\r
- }\r
-}\r
+// Mono.Util.CorCompare.MissingProperty
+//
+// Author(s):
+// Nick Drochak (ndrochak@gol.com)
+//
+// (C) 2001-2002 Nick Drochak
+
+using System;
+using System.Reflection;
+using System.Text;
+using System.Xml;
+
+namespace Mono.Util.CorCompare {
+
+ /// <summary>
+ /// Represents a missing property from a class
+ /// </summary>
+ /// <remarks>
+ /// created by - Nick
+ /// created on - 2/20/2002 10:43:57 PM
+ /// </remarks>
+ class MissingProperty : MissingMember
+ {
+ // e.g. <property name="Length" status="missing"/>
+ public MissingProperty (MemberInfo infoMono, MemberInfo infoMS) : base (infoMono, infoMS) {}
+
+ public override string Type
+ {
+ get { return "property"; }
+ }
+
+ protected MissingMethod mmGet;
+ protected MissingMethod mmSet;
+
+ public override NodeStatus Analyze ()
+ {
+ m_nodeStatus = base.Analyze ();
+
+ PropertyInfo piMono = (PropertyInfo) mInfoMono;
+ PropertyInfo piMS = (PropertyInfo) mInfoMS;
+
+ MemberInfo miGetMono, miSetMono;
+ if (piMono == null)
+ miGetMono = miSetMono = null;
+ else
+ {
+ miGetMono = piMono.GetGetMethod ();
+ miSetMono = piMono.GetSetMethod ();
+ }
+
+ MemberInfo miGetMS, miSetMS;
+ if (piMS == null)
+ miGetMS = miSetMS = null;
+ else
+ {
+ miGetMS = piMS.GetGetMethod ();
+ miSetMS = piMS.GetSetMethod ();
+ }
+
+ if (miGetMono != null || miGetMS != null)
+ {
+ mmGet = new MissingMethod (miGetMono, miGetMS);
+ m_nodeStatus.AddChildren (mmGet.Analyze ());
+ }
+ if (miSetMono != null || miSetMS != null)
+ {
+ mmSet = new MissingMethod (miSetMono, miSetMS);
+ m_nodeStatus.AddChildren (mmSet.Analyze ());
+ }
+
+ if (piMono != null && piMS != null)
+ {
+ string strTypeMono = piMono.PropertyType.FullName;
+ string strTypeMS = piMS.PropertyType.FullName;
+ if (strTypeMono != strTypeMS)
+ Status.AddWarning ("Invalid type: is '"+strTypeMono+"', should be '"+strTypeMS+"'");
+ }
+
+ return m_nodeStatus;
+ }
+
+ public override XmlElement CreateXML (XmlDocument doc)
+ {
+ XmlElement eltMember = base.CreateXML (doc);
+
+ if (mInfoMono != null) // missing
+ {
+ if (mmGet != null || mmSet != null)
+ {
+ XmlElement eltAccessors = doc.CreateElement ("accessors");
+ eltMember.AppendChild (eltAccessors);
+
+ if (mmGet != null)
+ {
+ XmlElement eltGet = mmGet.CreateXML (doc);
+ eltAccessors.AppendChild (eltGet);
+ }
+ if (mmSet != null)
+ {
+ XmlElement eltSet = mmSet.CreateXML (doc);
+ eltAccessors.AppendChild (eltSet);
+ }
+ }
+ }
+ return eltMember;
+ }
+ }
+}