added support for:
[mono.git] / mcs / tools / corcompare / MissingMember.cs
1 using System;
2 using System.Xml;
3 using System.Reflection;
4 using System.Collections;
5
6 namespace Mono.Util.CorCompare
7 {
8
9         /// <summary>
10         ///     Represents a generic member that is completely missing
11         /// </summary>
12         /// <remarks>
13         ///     created by - Piersh
14         ///     created on - 3/1/2002 3:37:00 am
15         /// </remarks>
16         abstract class MissingMember : MissingBase
17         {
18                 // e.g. <method name="Equals" status="missing"/>
19                 protected MemberInfo mInfoMono;
20                 protected MemberInfo mInfoMS;
21                 protected CompletionTypes completion = CompletionTypes.Missing;
22                 protected ArrayList rgAttributes;
23                 protected CompletionInfo ci;
24
25                 public MissingMember (MemberInfo infoMono, MemberInfo infoMS) 
26                 {
27                         mInfoMono = infoMono;
28                         mInfoMS = infoMS;
29                         completion = (infoMono == null) ? CompletionTypes.Missing : CompletionTypes.Complete;
30                 }
31
32                 public override string Name 
33                 {
34                         get { return Info.Name; }
35                 }
36
37                 public override CompletionTypes Completion
38                 {
39                         get { return completion; }
40                 }
41
42                 /// <summary>
43                 /// returns the MemberInfo for this member.
44                 /// if it's a missing member then the microsoft MemberInfo is returned instead
45                 /// </summary>
46                 public MemberInfo Info
47                 {
48                         get { return (mInfoMono != null) ? mInfoMono : mInfoMS; }
49                 }
50
51                 /// <summary>
52                 /// returns the 'best' info for this member. the 'best' info is the microsoft info, if it's available, otherwise the mono info.
53                 /// </summary>
54                 public MemberInfo BestInfo
55                 {
56                         get { return (mInfoMS != null) ? mInfoMS : mInfoMono; }
57                 }
58
59                 public override XmlElement CreateXML (XmlDocument doc)
60                 {
61                         XmlElement eltMissing = base.CreateXML (doc);
62
63                         XmlElement eltAttributes = MissingBase.CreateMemberCollectionElement ("attributes", rgAttributes, ci, doc);
64                         if (eltAttributes != null)
65                                 eltMissing.AppendChild (eltAttributes);
66
67                         return eltMissing;
68                 }
69
70                 public virtual CompletionInfo Analyze ()
71                 {
72                         if (mInfoMono == null)
73                         {
74                                 completion = CompletionTypes.Missing;
75                         }
76                         else
77                         {
78                                 rgAttributes = new ArrayList ();
79                                 ci = MissingAttribute.AnalyzeAttributes (
80                                         (mInfoMono == null) ? null : mInfoMono.GetCustomAttributes (false),
81                                         (mInfoMS   == null) ? null :   mInfoMS.GetCustomAttributes (false),
82                                         rgAttributes);
83
84                                 if (ci.cTodo != 0 || ci.cMissing != 0)
85                                         completion = CompletionTypes.Todo;
86                                 else
87                                         completion = CompletionTypes.Complete;
88                         }
89                         return ci;
90                 }
91         }
92 }