Updates referencesource to .NET 4.7
[mono-project.git] / mcs / class / referencesource / mscorlib / system / reflection / memberinfo.cs
blob9b7ba894b6f7dae69b9adbdcbb36b74e34f4ea91
1 // ==++==
2 //
3 // Copyright(c) Microsoft Corporation. All rights reserved.
4 //
5 // ==--==
6 // <OWNER>Microsoft</OWNER>
7 //
9 namespace System.Reflection
11 using System;
12 using System.Collections.Generic;
13 using System.Diagnostics.Contracts;
14 using System.Runtime;
15 using System.Runtime.InteropServices;
16 using System.Security.Permissions;
18 [Serializable]
19 [ClassInterface(ClassInterfaceType.None)]
20 [ComDefaultInterface(typeof(_MemberInfo))]
21 #pragma warning disable 618
22 [PermissionSetAttribute(SecurityAction.InheritanceDemand, Name = "FullTrust")]
23 #pragma warning restore 618
24 [System.Runtime.InteropServices.ComVisible(true)]
25 #if CONTRACTS_FULL
26 [ContractClass(typeof(MemberInfoContracts))]
27 #endif
28 public abstract class MemberInfo : ICustomAttributeProvider, _MemberInfo
30 #region Constructor
31 protected MemberInfo() { }
32 #endregion
34 #region Internal Methods
35 internal virtual bool CacheEquals(object o) { throw new NotImplementedException(); }
36 #endregion
38 #region Public Abstract\Virtual Members
39 public abstract MemberTypes MemberType { get; }
41 public abstract String Name { get; }
43 public abstract Type DeclaringType { get; }
45 public abstract Type ReflectedType { get; }
47 public virtual IEnumerable<CustomAttributeData> CustomAttributes
49 get
51 return GetCustomAttributesData();
54 public abstract Object[] GetCustomAttributes(bool inherit);
56 public abstract Object[] GetCustomAttributes(Type attributeType, bool inherit);
58 public abstract bool IsDefined(Type attributeType, bool inherit);
60 public virtual IList<CustomAttributeData> GetCustomAttributesData()
62 throw new NotImplementedException();
65 #if MONO
66 public virtual extern int MetadataToken {
67 [System.Runtime.CompilerServices.MethodImplAttribute (System.Runtime.CompilerServices.MethodImplOptions.InternalCall)]
68 get;
70 #else
71 public virtual int MetadataToken { get { throw new InvalidOperationException(); } }
72 #endif
74 public virtual Module Module
76 get
78 if (this is Type)
79 return ((Type)this).Module;
81 throw new NotImplementedException();
87 #endregion
89 #if !FEATURE_CORECLR
90 public static bool operator ==(MemberInfo left, MemberInfo right)
92 if (ReferenceEquals(left, right))
93 return true;
95 if ((object)left == null || (object)right == null)
96 return false;
98 Type type1, type2;
99 MethodBase method1, method2;
100 FieldInfo field1, field2;
101 EventInfo event1, event2;
102 PropertyInfo property1, property2;
104 if ((type1 = left as Type) != null && (type2 = right as Type) != null)
105 return type1 == type2;
106 else if ((method1 = left as MethodBase) != null && (method2 = right as MethodBase) != null)
107 return method1 == method2;
108 else if ((field1 = left as FieldInfo) != null && (field2 = right as FieldInfo) != null)
109 return field1 == field2;
110 else if ((event1 = left as EventInfo) != null && (event2 = right as EventInfo) != null)
111 return event1 == event2;
112 else if ((property1 = left as PropertyInfo) != null && (property2 = right as PropertyInfo) != null)
113 return property1 == property2;
115 return false;
118 public static bool operator !=(MemberInfo left, MemberInfo right)
120 return !(left == right);
122 #endif // !FEATURE_CORECLR
124 public override bool Equals(object obj)
126 return base.Equals(obj);
129 public override int GetHashCode()
131 return base.GetHashCode();
134 #if !FEATURE_CORECLR
135 // this method is required so Object.GetType is not made final virtual by the compiler
136 Type _MemberInfo.GetType()
138 return base.GetType();
141 void _MemberInfo.GetTypeInfoCount(out uint pcTInfo)
143 throw new NotImplementedException();
146 void _MemberInfo.GetTypeInfo(uint iTInfo, uint lcid, IntPtr ppTInfo)
148 throw new NotImplementedException();
151 void _MemberInfo.GetIDsOfNames([In] ref Guid riid, IntPtr rgszNames, uint cNames, uint lcid, IntPtr rgDispId)
153 throw new NotImplementedException();
156 void _MemberInfo.Invoke(uint dispIdMember, [In] ref Guid riid, uint lcid, short wFlags, IntPtr pDispParams, IntPtr pVarResult, IntPtr pExcepInfo, IntPtr puArgErr)
158 throw new NotImplementedException();
160 #endif
163 #if CONTRACTS_FULL
164 [ContractClassFor(typeof(MemberInfo))]
165 internal abstract class MemberInfoContracts : MemberInfo
167 public override String Name {
168 get {
169 Contract.Ensures(Contract.Result<String>() != null);
170 return default(String);
174 #endif // CONTRACTS_FULL