Module FieldAttributes

Expand description

Field attribute constants for controlling field characteristics and behavior

This module provides constants for the FieldAttributes bitmask that controls various aspects of field behavior including access control, storage type, mutability, and special runtime characteristics. These attributes are defined in the ECMA-335 specification and control how the runtime handles field access and storage.

§Attribute Categories

§Access Control (3-bit mask)

Controls visibility and accessibility of the field from different contexts.

§Storage Type

Determines whether the field is per-instance or shared across all instances.

§Mutability

Controls when and how the field value can be modified.

§Special Characteristics

Provides additional runtime behavior and metadata information.

§Reference

Constants§

ASSEMBLY
Field accessible by anyone within the assembly
COMPILER_CONTROLLED
Field not referenceable by user code
FAMILY
Field accessible only by type and subtypes
FAM_AND_ASSEM
Field accessible by subtypes only within this assembly
FAM_OR_ASSEM
Field accessible by subtypes anywhere, plus anyone in assembly
FIELD_ACCESS_MASK
Mask for extracting access control bits from field attributes
HAS_DEFAULT
Field has a default value
HAS_FIELD_MARSHAL
Field has associated marshaling information
HAS_FIELD_RVA
Field has associated RVA (Relative Virtual Address)
INIT_ONLY
Field can only be initialized, not written after initialization
LITERAL
Field value is a compile-time constant
NOT_SERIALIZED
Field should not be serialized when type is remoted
PINVOKE_IMPL
Implementation is forwarded through P/Invoke
PRIVATE
Field accessible only by the parent type
PUBLIC
Field accessible by anyone who has visibility to this scope
RTSPECIAL_NAME
CLI provides special behavior depending on the field name
SPECIAL_NAME
Field has special name significance
STATIC
Field is defined on type rather than per instance