summaryrefslogtreecommitdiff
path: root/src/mscorlib/src/System/Reflection/RuntimeFieldInfo.cs
diff options
context:
space:
mode:
authorJiyoung Yun <jy910.yun@samsung.com>2017-04-13 14:17:19 +0900
committerJiyoung Yun <jy910.yun@samsung.com>2017-04-13 14:17:19 +0900
commita56e30c8d33048216567753d9d3fefc2152af8ac (patch)
tree7e5d979695fc4a431740982eb1cfecc2898b23a5 /src/mscorlib/src/System/Reflection/RuntimeFieldInfo.cs
parent4b11dc566a5bbfa1378d6266525c281b028abcc8 (diff)
downloadcoreclr-a56e30c8d33048216567753d9d3fefc2152af8ac.tar.gz
coreclr-a56e30c8d33048216567753d9d3fefc2152af8ac.tar.bz2
coreclr-a56e30c8d33048216567753d9d3fefc2152af8ac.zip
Imported Upstream version 2.0.0.11353upstream/2.0.0.11353
Diffstat (limited to 'src/mscorlib/src/System/Reflection/RuntimeFieldInfo.cs')
-rw-r--r--src/mscorlib/src/System/Reflection/RuntimeFieldInfo.cs136
1 files changed, 136 insertions, 0 deletions
diff --git a/src/mscorlib/src/System/Reflection/RuntimeFieldInfo.cs b/src/mscorlib/src/System/Reflection/RuntimeFieldInfo.cs
new file mode 100644
index 0000000000..29cc97d225
--- /dev/null
+++ b/src/mscorlib/src/System/Reflection/RuntimeFieldInfo.cs
@@ -0,0 +1,136 @@
+// Licensed to the .NET Foundation under one or more agreements.
+// The .NET Foundation licenses this file to you under the MIT license.
+// See the LICENSE file in the project root for more information.
+
+using System.Collections.Generic;
+using System.Diagnostics.Contracts;
+using System.Runtime.Serialization;
+using RuntimeTypeCache = System.RuntimeType.RuntimeTypeCache;
+
+namespace System.Reflection
+{
+ [Serializable]
+ internal abstract class RuntimeFieldInfo : FieldInfo, ISerializable
+ {
+ #region Private Data Members
+ private BindingFlags m_bindingFlags;
+ protected RuntimeTypeCache m_reflectedTypeCache;
+ protected RuntimeType m_declaringType;
+ #endregion
+
+ #region Constructor
+ protected RuntimeFieldInfo()
+ {
+ // Used for dummy head node during population
+ }
+ protected RuntimeFieldInfo(RuntimeTypeCache reflectedTypeCache, RuntimeType declaringType, BindingFlags bindingFlags)
+ {
+ m_bindingFlags = bindingFlags;
+ m_declaringType = declaringType;
+ m_reflectedTypeCache = reflectedTypeCache;
+ }
+ #endregion
+
+ #region NonPublic Members
+ internal BindingFlags BindingFlags { get { return m_bindingFlags; } }
+ private RuntimeType ReflectedTypeInternal
+ {
+ get
+ {
+ return m_reflectedTypeCache.GetRuntimeType();
+ }
+ }
+
+ internal RuntimeType GetDeclaringTypeInternal()
+ {
+ return m_declaringType;
+ }
+
+ internal RuntimeType GetRuntimeType() { return m_declaringType; }
+ internal abstract RuntimeModule GetRuntimeModule();
+ #endregion
+
+ #region MemberInfo Overrides
+ public override MemberTypes MemberType { get { return MemberTypes.Field; } }
+ public override Type ReflectedType
+ {
+ get
+ {
+ return m_reflectedTypeCache.IsGlobal ? null : ReflectedTypeInternal;
+ }
+ }
+
+ public override Type DeclaringType
+ {
+ get
+ {
+ return m_reflectedTypeCache.IsGlobal ? null : m_declaringType;
+ }
+ }
+
+ public override Module Module { get { return GetRuntimeModule(); } }
+ #endregion
+
+ #region Object Overrides
+ public unsafe override String ToString()
+ {
+ return FieldType.FormatTypeName() + " " + Name;
+ }
+ #endregion
+
+ #region ICustomAttributeProvider
+ public override Object[] GetCustomAttributes(bool inherit)
+ {
+ return CustomAttribute.GetCustomAttributes(this, typeof(object) as RuntimeType);
+ }
+
+ public override Object[] GetCustomAttributes(Type attributeType, bool inherit)
+ {
+ if (attributeType == null)
+ throw new ArgumentNullException(nameof(attributeType));
+ Contract.EndContractBlock();
+
+ RuntimeType attributeRuntimeType = attributeType.UnderlyingSystemType as RuntimeType;
+
+ if (attributeRuntimeType == null)
+ throw new ArgumentException(SR.Arg_MustBeType, nameof(attributeType));
+
+ return CustomAttribute.GetCustomAttributes(this, attributeRuntimeType);
+ }
+
+ public override bool IsDefined(Type attributeType, bool inherit)
+ {
+ if (attributeType == null)
+ throw new ArgumentNullException(nameof(attributeType));
+ Contract.EndContractBlock();
+
+ RuntimeType attributeRuntimeType = attributeType.UnderlyingSystemType as RuntimeType;
+
+ if (attributeRuntimeType == null)
+ throw new ArgumentException(SR.Arg_MustBeType, nameof(attributeType));
+
+ return CustomAttribute.IsDefined(this, attributeRuntimeType);
+ }
+
+ public override IList<CustomAttributeData> GetCustomAttributesData()
+ {
+ return CustomAttributeData.GetCustomAttributesInternal(this);
+ }
+ #endregion
+
+ #region FieldInfo Overrides
+ // All implemented on derived classes
+ #endregion
+
+ #region ISerializable Implementation
+ public void GetObjectData(SerializationInfo info, StreamingContext context)
+ {
+ if (info == null)
+ throw new ArgumentNullException(nameof(info));
+ Contract.EndContractBlock();
+
+ MemberInfoSerializationHolder.GetSerializationInfo(info, this);
+ }
+ #endregion
+ }
+}