Class TypeMemoryLayout
- Namespace
- AsmResolver.DotNet.Memory
- Assembly
- AsmResolver.DotNet.dll
Provides information about the memory layout of a type.
public class TypeMemoryLayout
- Inheritance
-
TypeMemoryLayout
- Inherited Members
Constructors
TypeMemoryLayout(ITypeDescriptor, uint, MemoryLayoutAttributes)
Creates a new instance of the TypeMemoryLayout class.
public TypeMemoryLayout(ITypeDescriptor type, uint size, MemoryLayoutAttributes attributes)
Parameters
type
ITypeDescriptorThe type for which the memory layout is determined.
size
uintThe size of the type.
attributes
MemoryLayoutAttributesThe attributes
Properties
Attributes
Gets additional attributes associated to this memory layout.
public MemoryLayoutAttributes Attributes { get; }
Property Value
Is32Bit
Gets a value indicating whether the type layout was determined assuming a 32-bit environment.
public bool Is32Bit { get; }
Property Value
Is64Bit
Gets a value indicating whether the type layout was determined assuming a 64-bit environment.
public bool Is64Bit { get; }
Property Value
IsPlatformDependent
Gets a value indicating whether the type layout is dependent on the bitness of the environment.
public bool IsPlatformDependent { get; }
Property Value
IsReferenceOrContainsReferences
Gets a value indicating whether the type is a managed reference or contains managed references that are tracked by the garbage collector.
public bool IsReferenceOrContainsReferences { get; }
Property Value
Remarks
This is an equivalent to RuntimeHelpers.IsReferenceOrContainsReferences
.
this[FieldDefinition]
Gets the implied memory layout for the provided field.
public FieldMemoryLayout this[FieldDefinition field] { get; }
Parameters
field
FieldDefinitionThe field.
Property Value
Size
Gets the total number of bytes this structure requires.
public uint Size { get; }
Property Value
Type
Gets the type for which the memory layout was determined.
public ITypeDescriptor Type { get; }
Property Value
Methods
GetFields()
Gets all fields stored in the type.
public IEnumerable<FieldDefinition> GetFields()
Returns
TryGetFieldAtOffset(uint, out FieldMemoryLayout?)
Finds a field within this type memory layout by its offset.
public bool TryGetFieldAtOffset(uint offset, out FieldMemoryLayout? field)
Parameters
offset
uintThe offset of the field to find.
field
FieldMemoryLayoutWhen the method returns
true
, contains the field with the provided offset..
Returns
- bool
true
if the field with the provided offset existed,false,
otherwise.
TryGetFieldPath(uint, out IList<FieldMemoryLayout>)
Traverses the type memory layout tree and finds a field within this type memory layout by its offset.
public bool TryGetFieldPath(uint offset, out IList<FieldMemoryLayout> path)
Parameters
offset
uintThe offset of the field to find.
path
IList<FieldMemoryLayout>The (incomplete) path of fields to traverse to reach the provided field offset.
Returns
- bool
true
if the offset points to the start of a field,false
otherwise.