New test.
[mono.git] / mcs / tools / corcompare / MissingProperty.cs
1 // Mono.Util.CorCompare.MissingProperty
2 //
3 // Author(s):
4 //   Nick Drochak (ndrochak@gol.com)
5 //
6 // (C) 2001-2002 Nick Drochak
7
8 using System;
9 using System.Reflection;
10 using System.Text;
11 using System.Xml;
12
13 namespace Mono.Util.CorCompare {
14
15         /// <summary>
16         ///     Represents a missing property from a class
17         /// </summary>
18         /// <remarks>
19         ///     created by - Nick
20         ///     created on - 2/20/2002 10:43:57 PM
21         /// </remarks>
22         class MissingProperty : MissingMember 
23         {
24                 // e.g. <property name="Length" status="missing"/>
25                 public MissingProperty (MemberInfo infoMono, MemberInfo infoMS) : base (infoMono, infoMS) {}
26
27                 public override string Type 
28                 {
29                         get { return "property"; }
30                 }
31
32                 protected MissingMethod mmGet;
33                 protected MissingMethod mmSet;
34
35                 public override NodeStatus Analyze ()
36                 {
37                         m_nodeStatus = base.Analyze ();
38
39                         PropertyInfo piMono = (PropertyInfo) mInfoMono;
40                         PropertyInfo piMS   = (PropertyInfo) mInfoMS;
41
42                         MemberInfo miGetMono, miSetMono;
43                         if (piMono == null)
44                                 miGetMono = miSetMono = null;
45                         else
46                         {
47                                 miGetMono = piMono.GetGetMethod ();
48                                 miSetMono = piMono.GetSetMethod ();
49                         }
50
51                         MemberInfo miGetMS, miSetMS;
52                         if (piMS == null)
53                                 miGetMS = miSetMS = null;
54                         else
55                         {
56                                 miGetMS = piMS.GetGetMethod ();
57                                 miSetMS = piMS.GetSetMethod ();
58                         }
59
60                         if (miGetMono != null || miGetMS != null)
61                         {
62                                 mmGet = new MissingMethod (miGetMono, miGetMS);
63                                 m_nodeStatus.AddChildren (mmGet.Analyze ());
64                         }
65                         if (miSetMono != null || miSetMS != null)
66                         {
67                                 mmSet = new MissingMethod (miSetMono, miSetMS);
68                                 m_nodeStatus.AddChildren (mmSet.Analyze ());
69                         }
70
71                         if (piMono != null && piMS != null)
72                         {
73                                 string strTypeMono = piMono.PropertyType.FullName;
74                                 string strTypeMS   =   piMS.PropertyType.FullName;
75                                 if (strTypeMono != strTypeMS)
76                                         Status.AddWarning ("Invalid type: is '"+strTypeMono+"', should be '"+strTypeMS+"'");
77                         }
78
79                         return m_nodeStatus;
80                 }
81
82                 public override XmlElement CreateXML (XmlDocument doc)
83                 {
84                         XmlElement eltMember = base.CreateXML (doc);
85
86                         if (mInfoMono != null)  // missing
87                         {
88                                 if (mmGet != null || mmSet != null)
89                                 {
90                                         XmlElement eltAccessors = doc.CreateElement ("accessors");
91                                         eltMember.AppendChild (eltAccessors);
92
93                                         if (mmGet != null)
94                                         {
95                                                 XmlElement eltGet = mmGet.CreateXML (doc);
96                                                 eltAccessors.AppendChild (eltGet);
97                                         }
98                                         if (mmSet != null)
99                                         {
100                                                 XmlElement eltSet = mmSet.CreateXML (doc);
101                                                 eltAccessors.AppendChild (eltSet);
102                                         }
103                                 }
104                         }
105                         return eltMember;
106                 }
107         }
108 }