Files
Dec2017-Script-Dump/mscorlib/System/Reflection/FieldInfo.cs
T
2026-06-04 11:42:34 +02:00

449 lines
23 KiB
C#

using System;
using System.Diagnostics;
using System.Globalization;
using System.Reflection.Emit;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
namespace System.Reflection
{
/// <summary>Discovers the attributes of a field and provides access to field metadata. </summary>
// Token: 0x02000242 RID: 578
[ComDefaultInterface(typeof(_FieldInfo))]
[ComVisible(true)]
[ClassInterface(ClassInterfaceType.None)]
[Serializable]
public abstract class FieldInfo : MemberInfo, _FieldInfo
{
/// <summary>Maps a set of names to a corresponding set of dispatch identifiers.</summary>
/// <param name="riid">Reserved for future use. Must be IID_NULL.</param>
/// <param name="rgszNames">Passed-in array of names to be mapped.</param>
/// <param name="cNames">Count of the names to be mapped.</param>
/// <param name="lcid">The locale context in which to interpret the names.</param>
/// <param name="rgDispId">Caller-allocated array which receives the IDs corresponding to the names.</param>
/// <exception cref="T:System.NotImplementedException">Late-bound access using the COM IDispatch interface is not supported.</exception>
// Token: 0x06001E17 RID: 7703 RVA: 0x0007072C File Offset: 0x0006E92C
void _FieldInfo.GetIDsOfNames([In] ref Guid riid, IntPtr rgszNames, uint cNames, uint lcid, IntPtr rgDispId)
{
throw new NotImplementedException();
}
/// <summary>Retrieves the type information for an object, which can then be used to get the type information for an interface.</summary>
/// <param name="iTInfo">The type information to return.</param>
/// <param name="lcid">The locale identifier for the type information.</param>
/// <param name="ppTInfo">Receives a pointer to the requested type information object.</param>
/// <exception cref="T:System.NotImplementedException">Late-bound access using the COM IDispatch interface is not supported.</exception>
// Token: 0x06001E18 RID: 7704 RVA: 0x00070734 File Offset: 0x0006E934
void _FieldInfo.GetTypeInfo(uint iTInfo, uint lcid, IntPtr ppTInfo)
{
throw new NotImplementedException();
}
/// <summary>Retrieves the number of type information interfaces that an object provides (either 0 or 1).</summary>
/// <param name="pcTInfo">Points to a location that receives the number of type information interfaces provided by the object.</param>
/// <exception cref="T:System.NotImplementedException">Late-bound access using the COM IDispatch interface is not supported.</exception>
// Token: 0x06001E19 RID: 7705 RVA: 0x0007073C File Offset: 0x0006E93C
void _FieldInfo.GetTypeInfoCount(out uint pcTInfo)
{
throw new NotImplementedException();
}
/// <summary>Provides access to properties and methods exposed by an object.</summary>
/// <param name="dispIdMember">Identifies the member.</param>
/// <param name="riid">Reserved for future use. Must be IID_NULL.</param>
/// <param name="lcid">The locale context in which to interpret arguments.</param>
/// <param name="wFlags">Flags describing the context of the call.</param>
/// <param name="pDispParams">Pointer to a structure containing an array of arguments, an array of argument DISPIDs for named arguments, and counts for the number of elements in the arrays.</param>
/// <param name="pVarResult">Pointer to the location where the result is to be stored.</param>
/// <param name="pExcepInfo">Pointer to a structure that contains exception information.</param>
/// <param name="puArgErr">The index of the first argument that has an error.</param>
/// <exception cref="T:System.NotImplementedException">Late-bound access using the COM IDispatch interface is not supported.</exception>
// Token: 0x06001E1A RID: 7706 RVA: 0x00070744 File Offset: 0x0006E944
void _FieldInfo.Invoke(uint dispIdMember, [In] ref Guid riid, uint lcid, short wFlags, IntPtr pDispParams, IntPtr pVarResult, IntPtr pExcepInfo, IntPtr puArgErr)
{
throw new NotImplementedException();
}
/// <summary>Gets the attributes associated with this field.</summary>
/// <returns>The FieldAttributes for this field.</returns>
// Token: 0x17000571 RID: 1393
// (get) Token: 0x06001E1B RID: 7707
public abstract FieldAttributes Attributes { get; }
/// <summary>Gets a RuntimeFieldHandle, which is a handle to the internal metadata representation of a field.</summary>
/// <returns>A handle to the internal metadata representation of a field.</returns>
// Token: 0x17000572 RID: 1394
// (get) Token: 0x06001E1C RID: 7708
public abstract RuntimeFieldHandle FieldHandle { get; }
/// <summary>Gets the type of this field object.</summary>
/// <returns>The type of this field object.</returns>
// Token: 0x17000573 RID: 1395
// (get) Token: 0x06001E1D RID: 7709
public abstract Type FieldType { get; }
/// <summary>When overridden in a derived class, returns the value of a field supported by a given object.</summary>
/// <returns>An object containing the value of the field reflected by this instance.</returns>
/// <param name="obj">The object whose field value will be returned. </param>
/// <exception cref="T:System.Reflection.TargetException">The field is non-static and <paramref name="obj" /> is null. </exception>
/// <exception cref="T:System.NotSupportedException">A field is marked literal, but the field does not have one of the accepted literal types. </exception>
/// <exception cref="T:System.FieldAccessException">The caller does not have permission to access this field. </exception>
/// <exception cref="T:System.ArgumentException">The method is neither declared nor inherited by the class of <paramref name="obj" />. </exception>
// Token: 0x06001E1E RID: 7710
public abstract object GetValue(object obj);
/// <summary>Gets a <see cref="T:System.Reflection.MemberTypes" /> value indicating that this member is a field.</summary>
/// <returns>A <see cref="T:System.Reflection.MemberTypes" /> value indicating that this member is a field.</returns>
// Token: 0x17000574 RID: 1396
// (get) Token: 0x06001E1F RID: 7711 RVA: 0x0007074C File Offset: 0x0006E94C
public override MemberTypes MemberType
{
get
{
return MemberTypes.Field;
}
}
/// <summary>Gets a value indicating whether the value is written at compile time and cannot be changed.</summary>
/// <returns>true if the field has the Literal attribute set; otherwise, false.</returns>
// Token: 0x17000575 RID: 1397
// (get) Token: 0x06001E20 RID: 7712 RVA: 0x00070750 File Offset: 0x0006E950
public bool IsLiteral
{
get
{
return (this.Attributes & FieldAttributes.Literal) != FieldAttributes.PrivateScope;
}
}
/// <summary>Gets a value indicating whether the field is static.</summary>
/// <returns>true if this field is static; otherwise, false.</returns>
// Token: 0x17000576 RID: 1398
// (get) Token: 0x06001E21 RID: 7713 RVA: 0x00070764 File Offset: 0x0006E964
public bool IsStatic
{
get
{
return (this.Attributes & FieldAttributes.Static) != FieldAttributes.PrivateScope;
}
}
/// <summary>Gets a value indicating whether the field can only be set in the body of the constructor.</summary>
/// <returns>true if the field has the InitOnly attribute set; otherwise, false.</returns>
// Token: 0x17000577 RID: 1399
// (get) Token: 0x06001E22 RID: 7714 RVA: 0x00070778 File Offset: 0x0006E978
public bool IsInitOnly
{
get
{
return (this.Attributes & FieldAttributes.InitOnly) != FieldAttributes.PrivateScope;
}
}
/// <summary>Gets a value indicating whether the field is public.</summary>
/// <returns>true if this field is public; otherwise, false.</returns>
// Token: 0x17000578 RID: 1400
// (get) Token: 0x06001E23 RID: 7715 RVA: 0x0007078C File Offset: 0x0006E98C
public bool IsPublic
{
get
{
return (this.Attributes & FieldAttributes.FieldAccessMask) == FieldAttributes.Public;
}
}
/// <summary>Gets a value indicating whether the field is private.</summary>
/// <returns>true if the field is private; otherwise; false.</returns>
// Token: 0x17000579 RID: 1401
// (get) Token: 0x06001E24 RID: 7716 RVA: 0x0007079C File Offset: 0x0006E99C
public bool IsPrivate
{
get
{
return (this.Attributes & FieldAttributes.FieldAccessMask) == FieldAttributes.Private;
}
}
/// <summary>Gets a value indicating whether the visibility of this field is described by <see cref="F:System.Reflection.FieldAttributes.Family" />; that is, the field is visible only within its class and derived classes.</summary>
/// <returns>true if access to this field is exactly described by <see cref="F:System.Reflection.FieldAttributes.Family" />; otherwise, false.</returns>
// Token: 0x1700057A RID: 1402
// (get) Token: 0x06001E25 RID: 7717 RVA: 0x000707AC File Offset: 0x0006E9AC
public bool IsFamily
{
get
{
return (this.Attributes & FieldAttributes.FieldAccessMask) == FieldAttributes.Family;
}
}
/// <summary>Gets a value indicating whether the potential visibility of this field is described by <see cref="F:System.Reflection.FieldAttributes.Assembly" />; that is, the field is visible at most to other types in the same assembly, and is not visible to derived types outside the assembly.</summary>
/// <returns>true if the visibility of this field is exactly described by <see cref="F:System.Reflection.FieldAttributes.Assembly" />; otherwise, false.</returns>
// Token: 0x1700057B RID: 1403
// (get) Token: 0x06001E26 RID: 7718 RVA: 0x000707BC File Offset: 0x0006E9BC
public bool IsAssembly
{
get
{
return (this.Attributes & FieldAttributes.FieldAccessMask) == FieldAttributes.Assembly;
}
}
/// <summary>Gets a value indicating whether the visibility of this field is described by <see cref="F:System.Reflection.FieldAttributes.FamANDAssem" />; that is, the field can be accessed from derived classes, but only if they are in the same assembly.</summary>
/// <returns>true if access to this field is exactly described by <see cref="F:System.Reflection.FieldAttributes.FamANDAssem" />; otherwise, false.</returns>
// Token: 0x1700057C RID: 1404
// (get) Token: 0x06001E27 RID: 7719 RVA: 0x000707CC File Offset: 0x0006E9CC
public bool IsFamilyAndAssembly
{
get
{
return (this.Attributes & FieldAttributes.FieldAccessMask) == FieldAttributes.FamANDAssem;
}
}
/// <summary>Gets a value indicating whether the potential visibility of this field is described by <see cref="F:System.Reflection.FieldAttributes.FamORAssem" />; that is, the field can be accessed by derived classes wherever they are, and by classes in the same assembly.</summary>
/// <returns>true if access to this field is exactly described by <see cref="F:System.Reflection.FieldAttributes.FamORAssem" />; otherwise, false.</returns>
// Token: 0x1700057D RID: 1405
// (get) Token: 0x06001E28 RID: 7720 RVA: 0x000707DC File Offset: 0x0006E9DC
public bool IsFamilyOrAssembly
{
get
{
return (this.Attributes & FieldAttributes.FieldAccessMask) == FieldAttributes.FamORAssem;
}
}
/// <summary>Gets a value indicating whether the corresponding PinvokeImpl attribute is set in <see cref="T:System.Reflection.FieldAttributes" />.</summary>
/// <returns>true if the PinvokeImpl attribute is set in <see cref="T:System.Reflection.FieldAttributes" />; otherwise, false.</returns>
// Token: 0x1700057E RID: 1406
// (get) Token: 0x06001E29 RID: 7721 RVA: 0x000707EC File Offset: 0x0006E9EC
public bool IsPinvokeImpl
{
get
{
return (this.Attributes & FieldAttributes.PinvokeImpl) == FieldAttributes.PinvokeImpl;
}
}
/// <summary>Gets a value indicating whether the corresponding SpecialName attribute is set in the <see cref="T:System.Reflection.FieldAttributes" /> enumerator.</summary>
/// <returns>true if the SpecialName attribute is set in <see cref="T:System.Reflection.FieldAttributes" />; otherwise, false.</returns>
// Token: 0x1700057F RID: 1407
// (get) Token: 0x06001E2A RID: 7722 RVA: 0x00070804 File Offset: 0x0006EA04
public bool IsSpecialName
{
get
{
return (this.Attributes & FieldAttributes.SpecialName) == FieldAttributes.SpecialName;
}
}
/// <summary>Gets a value indicating whether this field has the NotSerialized attribute.</summary>
/// <returns>true if the field has the NotSerialized attribute set; otherwise, false.</returns>
// Token: 0x17000580 RID: 1408
// (get) Token: 0x06001E2B RID: 7723 RVA: 0x0007081C File Offset: 0x0006EA1C
public bool IsNotSerialized
{
get
{
return (this.Attributes & FieldAttributes.NotSerialized) == FieldAttributes.NotSerialized;
}
}
/// <summary>When overridden in a derived class, sets the value of the field supported by the given object.</summary>
/// <param name="obj">The object whose field value will be set. </param>
/// <param name="value">The value to assign to the field. </param>
/// <param name="invokeAttr">A field of Binder that specifies the type of binding that is desired (for example, Binder.CreateInstance or Binder.ExactBinding). </param>
/// <param name="binder">A set of properties that enables the binding, coercion of argument types, and invocation of members through reflection. If <paramref name="binder" /> is null, then Binder.DefaultBinding is used. </param>
/// <param name="culture">The software preferences of a particular culture. </param>
/// <exception cref="T:System.FieldAccessException">The caller does not have permission to access this field. </exception>
/// <exception cref="T:System.Reflection.TargetException">The <paramref name="obj" /> parameter is null and the field is an instance field. </exception>
/// <exception cref="T:System.ArgumentException">The field does not exist on the object.-or- The <paramref name="value" /> parameter cannot be converted and stored in the field. </exception>
// Token: 0x06001E2C RID: 7724
public abstract void SetValue(object obj, object value, BindingFlags invokeAttr, Binder binder, CultureInfo culture);
/// <summary>Sets the value of the field supported by the given object.</summary>
/// <param name="obj">The object whose field value will be set. </param>
/// <param name="value">The value to assign to the field. </param>
/// <exception cref="T:System.FieldAccessException">The caller does not have permission to access this field. </exception>
/// <exception cref="T:System.Reflection.TargetException">The <paramref name="obj" /> parameter is null and the field is an instance field. </exception>
/// <exception cref="T:System.ArgumentException">The field does not exist on the object.-or- The <paramref name="value" /> parameter cannot be converted and stored in the field. </exception>
// Token: 0x06001E2D RID: 7725 RVA: 0x00070834 File Offset: 0x0006EA34
[DebuggerStepThrough]
[DebuggerHidden]
public void SetValue(object obj, object value)
{
this.SetValue(obj, value, BindingFlags.Default, null, null);
}
// Token: 0x06001E2E RID: 7726
[MethodImpl(MethodImplOptions.InternalCall)]
private static extern FieldInfo internal_from_handle_type(IntPtr field_handle, IntPtr type_handle);
/// <summary>Gets a <see cref="T:System.Reflection.FieldInfo" /> for the field represented by the specified handle.</summary>
/// <returns>A <see cref="T:System.Reflection.FieldInfo" /> object representing the field specified by <paramref name="handle" />.</returns>
/// <param name="handle">A <see cref="T:System.RuntimeFieldHandle" /> structure that contains the handle to the internal metadata representation of a field. </param>
/// <exception cref="T:System.ArgumentException">
/// <paramref name="handle" /> is invalid.</exception>
// Token: 0x06001E2F RID: 7727 RVA: 0x00070844 File Offset: 0x0006EA44
public static FieldInfo GetFieldFromHandle(RuntimeFieldHandle handle)
{
if (handle.Value == IntPtr.Zero)
{
throw new ArgumentException("The handle is invalid.");
}
return FieldInfo.internal_from_handle_type(handle.Value, IntPtr.Zero);
}
/// <summary>Gets a <see cref="T:System.Reflection.FieldInfo" /> for the field represented by the specified handle, for the specified generic type.</summary>
/// <returns>A <see cref="T:System.Reflection.FieldInfo" /> object representing the field specified by <paramref name="handle" />, in the generic type specified by <paramref name="declaringType" />.</returns>
/// <param name="handle">A <see cref="T:System.RuntimeFieldHandle" /> structure that contains the handle to the internal metadata representation of a field.</param>
/// <param name="declaringType">A <see cref="T:System.RuntimeTypeHandle" /> structure that contains the handle to the generic type that defines the field.</param>
/// <exception cref="T:System.ArgumentException">
/// <paramref name="handle" /> is invalid.-or-<paramref name="declaringType" /> is not compatible with <paramref name="handle" />. For example, <paramref name="declaringType" /> is the runtime type handle of the generic type definition, and <paramref name="handle" /> comes from a constructed type. See Remarks. </exception>
// Token: 0x06001E30 RID: 7728 RVA: 0x00070884 File Offset: 0x0006EA84
[ComVisible(false)]
public static FieldInfo GetFieldFromHandle(RuntimeFieldHandle handle, RuntimeTypeHandle declaringType)
{
if (handle.Value == IntPtr.Zero)
{
throw new ArgumentException("The handle is invalid.");
}
FieldInfo fieldInfo = FieldInfo.internal_from_handle_type(handle.Value, declaringType.Value);
if (fieldInfo == null)
{
throw new ArgumentException("The field handle and the type handle are incompatible.");
}
return fieldInfo;
}
// Token: 0x06001E31 RID: 7729 RVA: 0x000708D8 File Offset: 0x0006EAD8
internal virtual int GetFieldOffset()
{
throw new SystemException("This method should not be called");
}
/// <summary>Returns the value of a field supported by a given object.</summary>
/// <returns>An Object containing a field value.</returns>
/// <param name="obj">A <see cref="T:System.TypedReference" /> structure that encapsulates a managed pointer to a location and a runtime representation of the type that might be stored at that location. </param>
/// <exception cref="T:System.NotSupportedException">The caller requires the Common Language Specification (CLS) alternative, but called this method instead. </exception>
// Token: 0x06001E32 RID: 7730 RVA: 0x000708E4 File Offset: 0x0006EAE4
[CLSCompliant(false)]
[MonoTODO("Not implemented")]
public virtual object GetValueDirect(TypedReference obj)
{
throw new NotImplementedException();
}
/// <summary>Sets the value of the field supported by the given object.</summary>
/// <param name="obj">A <see cref="T:System.TypedReference" /> structure that encapsulates a managed pointer to a location and a runtime representation of the type that can be stored at that location. </param>
/// <param name="value">The value to assign to the field. </param>
/// <exception cref="T:System.NotSupportedException">The caller requires the Common Language Specification (CLS) alternative, but called this method instead. </exception>
// Token: 0x06001E33 RID: 7731 RVA: 0x000708EC File Offset: 0x0006EAEC
[MonoTODO("Not implemented")]
[CLSCompliant(false)]
public virtual void SetValueDirect(TypedReference obj, object value)
{
throw new NotImplementedException();
}
// Token: 0x06001E34 RID: 7732
[MethodImpl(MethodImplOptions.InternalCall)]
private extern UnmanagedMarshal GetUnmanagedMarshal();
// Token: 0x17000581 RID: 1409
// (get) Token: 0x06001E35 RID: 7733 RVA: 0x000708F4 File Offset: 0x0006EAF4
internal virtual UnmanagedMarshal UMarshal
{
get
{
return this.GetUnmanagedMarshal();
}
}
// Token: 0x06001E36 RID: 7734 RVA: 0x000708FC File Offset: 0x0006EAFC
internal object[] GetPseudoCustomAttributes()
{
int num = 0;
if (this.IsNotSerialized)
{
num++;
}
if (this.DeclaringType.IsExplicitLayout)
{
num++;
}
UnmanagedMarshal umarshal = this.UMarshal;
if (umarshal != null)
{
num++;
}
if (num == 0)
{
return null;
}
object[] array = new object[num];
num = 0;
if (this.IsNotSerialized)
{
array[num++] = new NonSerializedAttribute();
}
if (this.DeclaringType.IsExplicitLayout)
{
array[num++] = new FieldOffsetAttribute(this.GetFieldOffset());
}
if (umarshal != null)
{
array[num++] = umarshal.ToMarshalAsAttribute();
}
return array;
}
// Token: 0x06001E37 RID: 7735
[MethodImpl(MethodImplOptions.InternalCall)]
private extern Type[] GetTypeModifiers(bool optional);
/// <summary>Gets an array of types that identify the optional custom modifiers of the field.</summary>
/// <returns>An array of <see cref="T:System.Type" /> objects that identify the optional custom modifiers of the current field, such as <see cref="T:System.Runtime.CompilerServices.IsConst" />.</returns>
// Token: 0x06001E38 RID: 7736 RVA: 0x000709A0 File Offset: 0x0006EBA0
public virtual Type[] GetOptionalCustomModifiers()
{
Type[] typeModifiers = this.GetTypeModifiers(true);
if (typeModifiers == null)
{
return Type.EmptyTypes;
}
return typeModifiers;
}
/// <summary>Gets an array of types that identify the required custom modifiers of the property.</summary>
/// <returns>An array of <see cref="T:System.Type" /> objects that identify the required custom modifiers of the current property, such as <see cref="T:System.Runtime.CompilerServices.IsConst" /> or <see cref="T:System.Runtime.CompilerServices.IsImplicitlyDereferenced" />.</returns>
// Token: 0x06001E39 RID: 7737 RVA: 0x000709C4 File Offset: 0x0006EBC4
public virtual Type[] GetRequiredCustomModifiers()
{
Type[] typeModifiers = this.GetTypeModifiers(false);
if (typeModifiers == null)
{
return Type.EmptyTypes;
}
return typeModifiers;
}
/// <summary>Returns a literal value associated with the field by a compiler. </summary>
/// <returns>An <see cref="T:System.Object" /> that contains the literal value associated with the field. If the literal value is a class type with an element value of zero, the return value is null.</returns>
/// <exception cref="T:System.InvalidOperationException">The Constant table in unmanaged metadata does not contain a constant value for the current property.</exception>
/// <exception cref="T:System.FormatException">The type of the value is not one of the types permitted by the Common Language Specification (CLS). See the ECMA Partition II specification Metadata Logical Format: Other Structures, Element Types used in Signatures. </exception>
// Token: 0x06001E3A RID: 7738 RVA: 0x000709E8 File Offset: 0x0006EBE8
public virtual object GetRawConstantValue()
{
throw new NotSupportedException("This non-CLS method is not implemented.");
}
/// <summary>Gets a <see cref="T:System.Type" /> object representing the <see cref="T:System.Reflection.FieldInfo" /> type.</summary>
/// <returns>A <see cref="T:System.Type" /> object representing the <see cref="T:System.Reflection.FieldInfo" /> type.</returns>
// Token: 0x06001E3B RID: 7739 RVA: 0x000709F4 File Offset: 0x0006EBF4
virtual Type System.Runtime.InteropServices._FieldInfo.GetType()
{
return base.GetType();
}
}
}