15 private int m_fieldTok;
21 private string m_fieldName;
25 private Type m_fieldType;
27 internal int MetadataTokenInternal => m_fieldTok;
35 public override string Name => m_fieldName;
43 if (m_typeBuilder.m_isHiddenGlobalType)
57 if (m_typeBuilder.m_isHiddenGlobalType)
87 if (fieldName ==
null)
91 if (fieldName.Length == 0)
95 if (fieldName[0] ==
'\0')
103 if (type == typeof(
void))
107 m_fieldName = fieldName;
108 m_typeBuilder = typeBuilder;
112 fieldSigHelper.
AddArgument(type, requiredCustomModifiers, optionalCustomModifiers);
114 byte[] signature = fieldSigHelper.InternalGetSignature(out length);
115 m_fieldTok =
TypeBuilder.DefineField(m_typeBuilder.GetModuleBuilder().GetNativeHandle(), typeBuilder.
TypeToken.
Token, fieldName, signature, length, m_Attributes);
120 internal void SetData(
byte[] data,
int size)
122 ModuleBuilder.SetFieldRVAContent(m_typeBuilder.GetModuleBuilder().GetNativeHandle(), m_tkField.
Token, data, size);
125 internal TypeBuilder GetTypeBuilder()
127 return m_typeBuilder;
193 [SecuritySafeCritical]
196 m_typeBuilder.ThrowIfCreated();
205 [SecuritySafeCritical]
206 [Obsolete(
"An alternate API is available: Emit the MarshalAs custom attribute instead. http://go.microsoft.com/fwlink/?linkid=14202")]
209 if (unmanagedMarshal ==
null)
213 m_typeBuilder.ThrowIfCreated();
214 byte[] array = unmanagedMarshal.InternalGetBytes();
215 TypeBuilder.SetFieldMarshal(m_typeBuilder.GetModuleBuilder().GetNativeHandle(),
GetToken().
Token, array, array.Length);
222 [SecuritySafeCritical]
225 m_typeBuilder.ThrowIfCreated();
235 [SecuritySafeCritical]
243 if (binaryAttribute ==
null)
248 m_typeBuilder.ThrowIfCreated();
257 [SecuritySafeCritical]
260 if (customBuilder ==
null)
264 m_typeBuilder.ThrowIfCreated();
266 customBuilder.CreateCustomAttribute(mod, m_tkField.
Token);
309 void _FieldBuilder.
Invoke(uint dispIdMember, [In] ref Guid riid, uint lcid,
short wFlags, IntPtr pDispParams, IntPtr pVarResult, IntPtr pExcepInfo, IntPtr puArgErr)
311 throw new NotImplementedException();
void AddArgument(Type clsArgument)
Adds an argument to the signature.
Performs reflection on a module.
The exception that is thrown when a null reference (Nothing in Visual Basic) is passed to a method th...
static SignatureHelper GetFieldSigHelper(Module mod)
Returns a signature helper for a field.
void SetCustomAttribute(CustomAttributeBuilder customBuilder)
Sets a custom attribute using a custom attribute builder.
FieldToken GetToken()
Returns the token representing this field.
Discovers the attributes of a class constructor and provides access to constructor metadata.
Discovers the attributes of a field and provides access to field metadata.
BindingFlags
Specifies flags that control binding and the way in which the search for members and types is conduct...
Represents a field using an internal metadata token.
void SetMarshal(UnmanagedMarshal unmanagedMarshal)
Describes the native marshaling of the field.
Provides methods for building signatures.
void GetTypeInfoCount(out uint pcTInfo)
Retrieves the number of type information interfaces that an object provides (either 0 or 1).
Helps build custom attributes.
override Type ReflectedType
Indicates the reference to the T:System.Type object from which this object was obtained....
MethodToken GetConstructorToken(ConstructorInfo constructor, IEnumerable< Type > optionalParameterTypes)
Returns the token used to identify the constructor that has the specified attributes and parameter ty...
Defines and represents a field. This class cannot be inherited.
void GetTypeInfo(uint iTInfo, uint lcid, IntPtr ppTInfo)
Retrieves the type information for an object, which can be used to get the type information for an in...
override string Name
Indicates the name of this field. This property is read-only.
override void SetValue(object obj, object val, BindingFlags invokeAttr, Binder binder, CultureInfo culture)
Sets the value of the field supported by the given object.
SecurityAction
Specifies the security actions that can be performed using declarative security.
Provides information about, and means to manipulate, the current environment and platform....
Represents a globally unique identifier (GUID).To browse the .NET Framework source code for this type...
Defines and creates new instances of classes during run time.
override Module Module
Retrieves the dynamic module that contains this type definition.
Defines and represents a module in a dynamic assembly.
FieldAttributes
Specifies flags that describe the attributes of a field.
TypeToken TypeToken
Returns the type token of this type.
A platform-specific type that is used to represent a pointer or a handle.
void GetIDsOfNames([In] ref Guid riid, IntPtr rgszNames, uint cNames, uint lcid, IntPtr rgDispId)
Maps a set of names to a corresponding set of dispatch identifiers.
Represents type declarations: class types, interface types, array types, value types,...
void Invoke(uint dispIdMember, [In] ref Guid riid, uint lcid, short wFlags, IntPtr pDispParams, IntPtr pVarResult, IntPtr pExcepInfo, IntPtr puArgErr)
Provides access to properties and methods exposed by an object.
override object [] GetCustomAttributes(Type attributeType, bool inherit)
Returns all the custom attributes defined for this field identified by the given type.
Selects a member from a list of candidates, and performs type conversion from actual argument type to...
Exposes the T:System.Reflection.Emit.FieldBuilder class to unmanaged code.
override Type DeclaringType
Indicates a reference to the T:System.Type object for the type that declares this field....
override bool IsDefined(Type attributeType, bool inherit)
Indicates whether an attribute having the specified type is defined on a field.
The exception that is thrown when one of the arguments provided to a method is not valid.
Represents the class that describes how to marshal a field from managed to unmanaged code....
void SetConstant(object defaultValue)
Sets the default value of this field.
int Token
Returns the metadata token for this method.
override RuntimeFieldHandle FieldHandle
Indicates the internal metadata handle for this field. This property is read-only.
override Type FieldType
Indicates the T:System.Type object that represents the type of this field. This property is read-only...
ClassInterfaceType
Identifies the type of class interface that is generated for a class.
int Token
Retrieves the metadata token for this class.
override object GetValue(object obj)
Retrieves the value of the field supported by the given object.
Provides information about a specific culture (called a locale for unmanaged code development)....
The exception that is thrown when an invoked method is not supported, or when there is an attempt to ...
void SetCustomAttribute(ConstructorInfo con, byte[] binaryAttribute)
Sets a custom attribute using a specified custom attribute blob.
The exception that is thrown when a requested method or operation is not implemented.
int Token
Retrieves the metadata token for this field.
override FieldAttributes Attributes
Indicates the attributes of this field. This property is read-only.
override object [] GetCustomAttributes(bool inherit)
Returns all the custom attributes defined for this field.
void SetOffset(int iOffset)
Specifies the field layout.
The FieldToken struct is an object representation of a token that represents a field.