Class FieldDefinition
- Namespace
- AsmResolver.DotNet
- Assembly
- AsmResolver.DotNet.dll
Represents a single field in a type definition of a .NET module.
public class FieldDefinition : MetadataMember, IMemberDefinition, IFieldDescriptor, IHasCustomAttribute, IHasConstant, IMemberForwarded, IMemberDescriptor, IFullNameProvider, IImportable, IHasFieldMarshal, IMetadataMember, INameProvider, IModuleProvider, IOwnedCollectionElement<TypeDefinition>
- Inheritance
-
FieldDefinition
- Implements
- Derived
- Inherited Members
- Extension Methods
Constructors
FieldDefinition(MetadataToken)
Initializes a new field definition.
protected FieldDefinition(MetadataToken token)
Parameters
token
MetadataTokenThe token of the field.
FieldDefinition(Utf8String?, FieldAttributes, FieldSignature?)
Creates a new field definition.
public FieldDefinition(Utf8String? name, FieldAttributes attributes, FieldSignature? signature)
Parameters
name
Utf8StringThe name of the field.
attributes
FieldAttributesThe attributes.
signature
FieldSignatureThe signature of the field.
FieldDefinition(Utf8String, FieldAttributes, TypeSignature?)
Creates a new field definition.
public FieldDefinition(Utf8String name, FieldAttributes attributes, TypeSignature? fieldType)
Parameters
name
Utf8StringThe name of the field.
attributes
FieldAttributesThe attributes.
fieldType
TypeSignatureThe type of values the field contains.
Properties
Attributes
Gets or sets the attributes associated to the field.
public FieldAttributes Attributes { get; set; }
Property Value
Constant
Gets or sets a constant that is assigned to the member.
public Constant? Constant { get; set; }
Property Value
Remarks
If this property is set to null
, the member is not assigned a constant value.
Updating this property does not update any of the attributes associated to the member.
CustomAttributes
Gets a collection of custom attributes assigned to this member.
public IList<CustomAttribute> CustomAttributes { get; }
Property Value
DeclaringType
Gets the type that defines the field.
public TypeDefinition? DeclaringType { get; }
Property Value
FieldOffset
Gets or sets the explicit offset of the field, relative to the starting address of the object (if available).
public int? FieldOffset { get; set; }
Property Value
- int?
FieldRva
Gets or sets a segment containing the initial value of the field.
public ISegment? FieldRva { get; set; }
Property Value
Remarks
Updating this property does not automatically update the HasFieldRva property, nor does the
value of HasFieldRva reflect whether the field has initialization data or not. Well-formed
.NET binaries should always set the HasFieldRva flag to true
if this property is non-null.
FullName
Gets the full name of the object.
public string FullName { get; }
Property Value
HasDefault
Gets or sets a value indicating whether the field has a default value associated to it.
public bool HasDefault { get; set; }
Property Value
HasFieldMarshal
Gets or sets a value indicating whether the field has marshalling information associated to it.
public bool HasFieldMarshal { get; set; }
Property Value
HasFieldRva
Gets or sets a value indicating whether the field has an initial value associated to it that is referenced by a relative virtual address.
public bool HasFieldRva { get; set; }
Property Value
ImplementationMap
Gets or sets the Platform Invoke (P/Invoke) implementation mapping of this member (if available).
public ImplementationMap? ImplementationMap { get; set; }
Property Value
IsAssembly
Gets or sets a value indicating whether the field is marked private and can only be accessed by members within the same assembly.
public bool IsAssembly { get; set; }
Property Value
IsFamily
Gets or sets a value indicating whether the field is marked private and can only be accessed by members within the same enclosing type, as well as any derived type.
public bool IsFamily { get; set; }
Property Value
IsFamilyAndAssembly
Gets or sets a value indicating whether the field is marked family and assembly, and can only be accessed by members within the same enclosing type and any derived type, within the same assembly.
public bool IsFamilyAndAssembly { get; set; }
Property Value
IsFamilyOrAssembly
Gets or sets a value indicating whether the field is marked family or assembly, and can only be accessed by members within the same enclosing type and any derived type, or within the same assembly.
public bool IsFamilyOrAssembly { get; set; }
Property Value
IsInitOnly
Gets or sets a value indicating whether the field is marked init-only, and can only be assigned a value by a constructor of the enclosing type.
public bool IsInitOnly { get; set; }
Property Value
IsLiteral
Gets or sets a value indicating whether the field is marked as a literal, and its value is decided upon compile time.
public bool IsLiteral { get; set; }
Property Value
IsNotSerialized
Gets or sets a value indicating whether the field is marked as not serialized, indicating the field does not have to be serialized when the enclosing type is remoted.
public bool IsNotSerialized { get; set; }
Property Value
IsPInvokeImpl
Gets or sets a value indicating whether the field's implementation is forwarded through Platform Invoke.
public bool IsPInvokeImpl { get; set; }
Property Value
IsPrivate
Gets or sets a value indicating whether the field is marked private and can only be accessed by members within the same enclosing type.
public bool IsPrivate { get; set; }
Property Value
IsPrivateScope
Gets or sets a value indicating whether the field is in a private scope.
public bool IsPrivateScope { get; set; }
Property Value
IsPublic
Gets or sets a value indicating whether the field is marked public, and can be accessed by any member having access to the enclosing type.
public bool IsPublic { get; set; }
Property Value
IsRuntimeSpecialName
Gets or sets a value indicating whether the field uses a name that is used by the runtime.
public bool IsRuntimeSpecialName { get; set; }
Property Value
IsSpecialName
Gets or sets a value indicating whether the field uses a special name.
public bool IsSpecialName { get; set; }
Property Value
IsStatic
Gets or sets a value indicating whether the field requires an object instance to access it.
public bool IsStatic { get; set; }
Property Value
Remarks
This property does not reflect the value of HasThis, nor will it change the value of HasThis if this property is changed. For a valid .NET image, these values should match, however.
MarshalDescriptor
Gets or sets the description on how a specific value needs to be marshaled upon calling to or from unmanaged code via P/Invoke dispatch.
public MarshalDescriptor? MarshalDescriptor { get; set; }
Property Value
Module
Gets the module that defines the member definition or reference.
public ModuleDefinition? Module { get; }
Property Value
Remarks
For member references, this does not obtain the module definition that the member is defined in. Rather, it obtains the module definition that references this reference.
Name
Gets or sets the name of the field.
public Utf8String? Name { get; set; }
Property Value
Remarks
This property corresponds to the Name column in the field table.
Signature
Gets or sets the signature of the field. This includes the field type.
public FieldSignature? Signature { get; set; }
Property Value
Methods
GetConstant()
Obtains the constant value assigned to the field definition.
protected virtual Constant? GetConstant()
Returns
- Constant
The constant.
Remarks
This method is called upon initialization of the Constant property.
GetCustomAttributes()
Obtains the list of custom attributes assigned to the member.
protected virtual IList<CustomAttribute> GetCustomAttributes()
Returns
- IList<CustomAttribute>
The attributes
Remarks
This method is called upon initialization of the CustomAttributes property.
GetDeclaringType()
Obtains the declaring type of the field definition.
protected virtual TypeDefinition? GetDeclaringType()
Returns
- TypeDefinition
The declaring type.
Remarks
This method is called upon initialization of the DeclaringType property.
GetFieldOffset()
Obtains the offset of the field as defined in the field layout.
protected virtual int? GetFieldOffset()
Returns
- int?
The field offset.
Remarks
This method is called upon initialization of the FieldOffset property.
GetFieldRva()
Obtains the initial value of the field.
protected virtual ISegment? GetFieldRva()
Returns
- ISegment
The initial value.
Remarks
This method is called upon initialization of the FieldRva property.
GetImplementationMap()
Obtains the platform invoke information assigned to the field.
protected virtual ImplementationMap? GetImplementationMap()
Returns
- ImplementationMap
The mapping.
Remarks
This method is called upon initialization of the ImplementationMap property.
GetMarshalDescriptor()
Obtains the marshal descriptor value assigned to the field definition.
protected virtual MarshalDescriptor? GetMarshalDescriptor()
Returns
- MarshalDescriptor
The marshal descriptor.
Remarks
This method is called upon initialization of the MarshalDescriptor property.
GetName()
Obtains the name of the field definition.
protected virtual Utf8String? GetName()
Returns
- Utf8String
The name.
Remarks
This method is called upon initialization of the Name property.
GetSignature()
Obtains the signature of the field definition.
protected virtual FieldSignature? GetSignature()
Returns
- FieldSignature
The signature.
Remarks
This method is called upon initialization of the Signature property.
ImportWith(ReferenceImporter)
Imports the field using the provided reference importer object.
public IFieldDescriptor ImportWith(ReferenceImporter importer)
Parameters
importer
ReferenceImporterThe reference importer to use.
Returns
- IFieldDescriptor
The imported field.
IsAccessibleFromType(TypeDefinition)
Determines whether the member can be accessed from the scope that is determined by the provided type.
public bool IsAccessibleFromType(TypeDefinition type)
Parameters
type
TypeDefinitionThe type defining the scope.
Returns
- bool
True if the scope of the provided type can access the member, false otherwise.
IsImportedInModule(ModuleDefinition)
Determines whether the descriptor of the member is fully imported in the provided module.
public bool IsImportedInModule(ModuleDefinition module)
Parameters
module
ModuleDefinitionThe module that is supposed to import the member.
Returns
- bool
true
if the descriptor of the member is fully imported by the module,false
otherwise.
Remarks
This method verifies all references in the descriptor of the member only. It does not verify any additional data or contents (such as a method body) associated to the member.
ToString()
Returns a string that represents the current object.
public override string ToString()
Returns
- string
A string that represents the current object.