using System; using System.Globalization; using System.Runtime.InteropServices; namespace System.Reflection.Emit { /// Defines and represents a field. This class cannot be inherited. // Token: 0x020001F3 RID: 499 [ClassInterface(ClassInterfaceType.None)] [ComDefaultInterface(typeof(_FieldBuilder))] [ComVisible(true)] public sealed class FieldBuilder : FieldInfo, _FieldBuilder { // Token: 0x06001A16 RID: 6678 RVA: 0x00062920 File Offset: 0x00060B20 internal FieldBuilder(TypeBuilder tb, string fieldName, Type type, FieldAttributes attributes, Type[] modReq, Type[] modOpt) { if (type == null) { throw new ArgumentNullException("type"); } this.attrs = attributes; this.name = fieldName; this.type = type; this.modReq = modReq; this.modOpt = modOpt; this.offset = -1; this.typeb = tb; this.table_idx = tb.get_next_table_index(this, 4, true); } /// Maps a set of names to a corresponding set of dispatch identifiers. /// Reserved for future use. Must be IID_NULL. /// Passed-in array of names to be mapped. /// Count of the names to be mapped. /// The locale context in which to interpret the names. /// Caller-allocated array which receives the IDs corresponding to the names. /// The method is called late-bound using the COM IDispatch interface. // Token: 0x06001A17 RID: 6679 RVA: 0x00062988 File Offset: 0x00060B88 void _FieldBuilder.GetIDsOfNames([In] ref Guid riid, IntPtr rgszNames, uint cNames, uint lcid, IntPtr rgDispId) { throw new NotImplementedException(); } /// Retrieves the type information for an object, which can then be used to get the type information for an interface. /// The type information to return. /// The locale identifier for the type information. /// Receives a pointer to the requested type information object. /// The method is called late-bound using the COM IDispatch interface. // Token: 0x06001A18 RID: 6680 RVA: 0x00062990 File Offset: 0x00060B90 void _FieldBuilder.GetTypeInfo(uint iTInfo, uint lcid, IntPtr ppTInfo) { throw new NotImplementedException(); } /// Retrieves the number of type information interfaces that an object provides (either 0 or 1). /// Points to a location that receives the number of type information interfaces provided by the object. /// The method is called late-bound using the COM IDispatch interface. // Token: 0x06001A19 RID: 6681 RVA: 0x00062998 File Offset: 0x00060B98 void _FieldBuilder.GetTypeInfoCount(out uint pcTInfo) { throw new NotImplementedException(); } /// Provides access to properties and methods exposed by an object. /// Identifies the member. /// Reserved for future use. Must be IID_NULL. /// The locale context in which to interpret arguments. /// Flags describing the context of the call. /// 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. /// Pointer to the location where the result is to be stored. /// Pointer to a structure that contains exception information. /// The index of the first argument that has an error. /// The method is called late-bound using the COM IDispatch interface. // Token: 0x06001A1A RID: 6682 RVA: 0x000629A0 File Offset: 0x00060BA0 void _FieldBuilder.Invoke(uint dispIdMember, [In] ref Guid riid, uint lcid, short wFlags, IntPtr pDispParams, IntPtr pVarResult, IntPtr pExcepInfo, IntPtr puArgErr) { throw new NotImplementedException(); } /// Indicates the attributes of this field. This property is read-only. /// The attributes of this field. // Token: 0x1700049A RID: 1178 // (get) Token: 0x06001A1B RID: 6683 RVA: 0x000629A8 File Offset: 0x00060BA8 public override FieldAttributes Attributes { get { return this.attrs; } } /// Indicates a reference to the object for the type that declares this field. This property is read-only. /// A reference to the object for the type that declares this field. // Token: 0x1700049B RID: 1179 // (get) Token: 0x06001A1C RID: 6684 RVA: 0x000629B0 File Offset: 0x00060BB0 public override Type DeclaringType { get { return this.typeb; } } /// Indicates the internal metadata handle for this field. This property is read-only. /// The internal metadata handle for this field. /// This method is not supported. // Token: 0x1700049C RID: 1180 // (get) Token: 0x06001A1D RID: 6685 RVA: 0x000629B8 File Offset: 0x00060BB8 public override RuntimeFieldHandle FieldHandle { get { throw this.CreateNotSupportedException(); } } /// Indicates the object that represents the type of this field. This property is read-only. /// The object that represents the type of this field. // Token: 0x1700049D RID: 1181 // (get) Token: 0x06001A1E RID: 6686 RVA: 0x000629C0 File Offset: 0x00060BC0 public override Type FieldType { get { return this.type; } } /// Indicates the name of this field. This property is read-only. /// A containing the name of this field. // Token: 0x1700049E RID: 1182 // (get) Token: 0x06001A1F RID: 6687 RVA: 0x000629C8 File Offset: 0x00060BC8 public override string Name { get { return this.name; } } /// Indicates the reference to the object from which this object was obtained. This property is read-only. /// A reference to the object from which this instance was obtained. // Token: 0x1700049F RID: 1183 // (get) Token: 0x06001A20 RID: 6688 RVA: 0x000629D0 File Offset: 0x00060BD0 public override Type ReflectedType { get { return this.typeb; } } /// Returns all the custom attributes defined for this field. /// An array of type representing all the custom attributes of the constructor represented by this instance. /// Controls inheritance of custom attributes from base classes. /// This method is not supported. // Token: 0x06001A21 RID: 6689 RVA: 0x000629D8 File Offset: 0x00060BD8 public override object[] GetCustomAttributes(bool inherit) { if (this.typeb.is_created) { return MonoCustomAttrs.GetCustomAttributes(this, inherit); } throw this.CreateNotSupportedException(); } /// Returns all the custom attributes defined for this field identified by the given type. /// An array of type representing all the custom attributes of the constructor represented by this instance. /// The custom attribute type. /// Controls inheritance of custom attributes from base classes. /// This method is not supported. // Token: 0x06001A22 RID: 6690 RVA: 0x000629F8 File Offset: 0x00060BF8 public override object[] GetCustomAttributes(Type attributeType, bool inherit) { if (this.typeb.is_created) { return MonoCustomAttrs.GetCustomAttributes(this, attributeType, inherit); } throw this.CreateNotSupportedException(); } /// Returns the token representing this field. /// Returns the object that represents the token for this field. // Token: 0x06001A23 RID: 6691 RVA: 0x00062A1C File Offset: 0x00060C1C public FieldToken GetToken() { return new FieldToken(this.MetadataToken); } /// Retrieves the value of the field supported by the given object. /// An containing the value of the field reflected by this instance. /// The object on which to access the field. /// This method is not supported. // Token: 0x06001A24 RID: 6692 RVA: 0x00062A2C File Offset: 0x00060C2C public override object GetValue(object obj) { throw this.CreateNotSupportedException(); } /// Indicates whether an attribute having the specified type is defined on a field. /// true if one or more instance of is defined on this field; otherwise, false. /// The type of the attribute. /// Controls inheritance of custom attributes from base classes. /// This method is not currently supported. Retrieve the field using and call on the returned . // Token: 0x06001A25 RID: 6693 RVA: 0x00062A34 File Offset: 0x00060C34 public override bool IsDefined(Type attributeType, bool inherit) { throw this.CreateNotSupportedException(); } // Token: 0x06001A26 RID: 6694 RVA: 0x00062A3C File Offset: 0x00060C3C internal override int GetFieldOffset() { return 0; } // Token: 0x06001A27 RID: 6695 RVA: 0x00062A40 File Offset: 0x00060C40 internal void SetRVAData(byte[] data) { this.rva_data = (byte[])data.Clone(); } /// Sets the default value of this field. /// The new default value for this field. /// The containing type has been created using . /// The field is not one of the supported types.-or-The type of does not match the type of the field.-or-The field is of type or other reference type, and is not null. // Token: 0x06001A28 RID: 6696 RVA: 0x00062A54 File Offset: 0x00060C54 public void SetConstant(object defaultValue) { this.RejectIfCreated(); this.def_value = defaultValue; } /// Sets a custom attribute using a custom attribute builder. /// An instance of a helper class to define the custom attribute. /// /// is null. /// The parent type of this field is complete. // Token: 0x06001A29 RID: 6697 RVA: 0x00062A64 File Offset: 0x00060C64 public void SetCustomAttribute(CustomAttributeBuilder customBuilder) { this.RejectIfCreated(); string fullName = customBuilder.Ctor.ReflectedType.FullName; if (fullName == "System.Runtime.InteropServices.FieldOffsetAttribute") { byte[] data = customBuilder.Data; this.offset = (int)data[2]; this.offset |= (int)data[3] << 8; this.offset |= (int)data[4] << 16; this.offset |= (int)data[5] << 24; return; } if (fullName == "System.NonSerializedAttribute") { this.attrs |= FieldAttributes.NotSerialized; return; } if (fullName == "System.Runtime.CompilerServices.SpecialNameAttribute") { this.attrs |= FieldAttributes.SpecialName; return; } if (fullName == "System.Runtime.InteropServices.MarshalAsAttribute") { this.attrs |= FieldAttributes.HasFieldMarshal; this.marshal_info = CustomAttributeBuilder.get_umarshal(customBuilder, true); return; } if (this.cattrs != null) { CustomAttributeBuilder[] array = new CustomAttributeBuilder[this.cattrs.Length + 1]; this.cattrs.CopyTo(array, 0); array[this.cattrs.Length] = customBuilder; this.cattrs = array; } else { this.cattrs = new CustomAttributeBuilder[1]; this.cattrs[0] = customBuilder; } } /// Sets a custom attribute using a specified custom attribute blob. /// The constructor for the custom attribute. /// A byte blob representing the attributes. /// /// or is null. /// The parent type of this field is complete. // Token: 0x06001A2A RID: 6698 RVA: 0x00062BAC File Offset: 0x00060DAC [ComVisible(true)] public void SetCustomAttribute(ConstructorInfo con, byte[] binaryAttribute) { this.RejectIfCreated(); this.SetCustomAttribute(new CustomAttributeBuilder(con, binaryAttribute)); } /// Describes the native marshaling of the field. /// A descriptor specifying the native marshalling of this field. /// /// is null. /// The containing type has been created using . // Token: 0x06001A2B RID: 6699 RVA: 0x00062BC4 File Offset: 0x00060DC4 [Obsolete("An alternate API is available: Emit the MarshalAs custom attribute instead.")] public void SetMarshal(UnmanagedMarshal unmanagedMarshal) { this.RejectIfCreated(); this.marshal_info = unmanagedMarshal; this.attrs |= FieldAttributes.HasFieldMarshal; } /// Specifies the field layout. /// The offset of the field within the type containing this field. /// The containing type has been created using . /// /// is less than zero. // Token: 0x06001A2C RID: 6700 RVA: 0x00062BE8 File Offset: 0x00060DE8 public void SetOffset(int iOffset) { this.RejectIfCreated(); this.offset = iOffset; } /// Sets the value of the field supported by the given object. /// The object on which to access the field. /// The value to assign to the field. /// A member of IBinder that specifies the type of binding that is desired (for example, IBinder.CreateInstance, IBinder.ExactBinding). /// A set of properties and enabling for binding, coercion of argument types, and invocation of members using reflection. If binder is null, then IBinder.DefaultBinding is used. /// The software preferences of a particular culture. /// This method is not supported. // Token: 0x06001A2D RID: 6701 RVA: 0x00062BF8 File Offset: 0x00060DF8 public override void SetValue(object obj, object val, BindingFlags invokeAttr, Binder binder, CultureInfo culture) { throw this.CreateNotSupportedException(); } // Token: 0x170004A0 RID: 1184 // (get) Token: 0x06001A2E RID: 6702 RVA: 0x00062C00 File Offset: 0x00060E00 internal override UnmanagedMarshal UMarshal { get { return this.marshal_info; } } // Token: 0x06001A2F RID: 6703 RVA: 0x00062C08 File Offset: 0x00060E08 private Exception CreateNotSupportedException() { return new NotSupportedException("The invoked member is not supported in a dynamic module."); } // Token: 0x06001A30 RID: 6704 RVA: 0x00062C14 File Offset: 0x00060E14 private void RejectIfCreated() { if (this.typeb.is_created) { throw new InvalidOperationException("Unable to change after type has been created."); } } /// Gets the module in which the type that contains this field is being defined. /// A that represents the dynamic module in which this field is being defined. // Token: 0x170004A1 RID: 1185 // (get) Token: 0x06001A31 RID: 6705 RVA: 0x00062C34 File Offset: 0x00060E34 public override Module Module { get { return base.Module; } } // Token: 0x040007B2 RID: 1970 private FieldAttributes attrs; // Token: 0x040007B3 RID: 1971 private Type type; // Token: 0x040007B4 RID: 1972 private string name; // Token: 0x040007B5 RID: 1973 private object def_value; // Token: 0x040007B6 RID: 1974 private int offset; // Token: 0x040007B7 RID: 1975 private int table_idx; // Token: 0x040007B8 RID: 1976 internal TypeBuilder typeb; // Token: 0x040007B9 RID: 1977 private byte[] rva_data; // Token: 0x040007BA RID: 1978 private CustomAttributeBuilder[] cattrs; // Token: 0x040007BB RID: 1979 private UnmanagedMarshal marshal_info; // Token: 0x040007BC RID: 1980 private RuntimeFieldHandle handle; // Token: 0x040007BD RID: 1981 private Type[] modReq; // Token: 0x040007BE RID: 1982 private Type[] modOpt; } }