Welcome to mirror list, hosted at ThFree Co, Russian Federation.

MissingProperty.cs « corcompare « tools « mcs - github.com/mono/mono.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
blob: d3eb711d4fb1f27bf5b2f22be652cbcb32c937f8 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
// 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;
		}
	}
}