Table of Contents

Class MemoryField

Namespace
CStructSharp.Memory
Assembly
CStructSharp.dll

One member of a struct or union: a name, a type ID, a byte offset from the container's start, and an optional bit slice.

public sealed record MemoryField : IEquatable<MemoryField>
Inheritance
MemoryField
Implements
Inherited Members

Remarks

A field is the link between a containing composite and the type stored inside it. The offset is relative to the start of the containing record, never an absolute address; the session adds it to the record's region when a path selects the member. The referenced type supplies the storage size.

A bit slice describes a C bitfield: the field occupies only BitWidth bits of its storage integer, starting at BitOffset counted from the least significant bit. Bits are numbered after the storage integer has been assembled from its bytes, so switching byte order changes which byte holds the slice but not the meaning of bit index zero. A signed slice is sign-extended on read and range-checked on write, using two's complement.

A promoted field makes the members of an anonymous nested struct or union visible in the parent, mirroring C's anonymous members. If two promoted members share a name the schema rejects the ambiguity instead of picking one. Extent and overlap checks belong to MemorySchema, which sees the whole graph.

Constructors

MemoryField(string, string, int, int?, int?, bool, bool)

Creates a member description; type references, extents, and overlap are validated later by the schema.

public MemoryField(string name, string typeId, int offset, int? bitOffset = null, int? bitWidth = null, bool signed = false, bool promoted = false)

Parameters

name string

Member name used in session paths and struct value dictionaries.

typeId string

ID of the member's type in the schema.

offset int

Byte offset from the start of the containing struct or union, not a source address.

bitOffset int?

Index of the slice's least significant bit within the storage integer, or null for a whole value.

bitWidth int?

Number of bits in the slice, or null for a whole value; must accompany bitOffset.

signed bool

Whether the bit slice is a two's-complement signed number.

promoted bool

Whether the members of this composite are visible in the containing record.

Properties

BitOffset

Gets the index of the slice's least significant bit within the storage integer, or null for a whole value.

public int? BitOffset { get; }

Property Value

int?

BitWidth

Gets the number of bits in the slice, or null for a whole value.

public int? BitWidth { get; }

Property Value

int?

Name

Gets the member name used for path lookup and value dictionaries.

public string Name { get; }

Property Value

string

Offset

Gets the byte offset from the start of the containing record.

public int Offset { get; }

Property Value

int

Promoted

Gets whether the members of this composite are visible in its containing record.

public bool Promoted { get; }

Property Value

bool

Signed

Gets whether the bit slice is read and written as a two's-complement signed number.

public bool Signed { get; }

Property Value

bool

TypeId

Gets the ID of the member's type.

public string TypeId { get; }

Property Value

string

Methods

Equals(MemoryField?)

public bool Equals(MemoryField? other)

Parameters

other MemoryField

Returns

bool

Equals(object?)

public override bool Equals(object? obj)

Parameters

obj object

Returns

bool

GetHashCode()

public override int GetHashCode()

Returns

int

ToString()

public override string ToString()

Returns

string

Operators

operator ==(MemoryField?, MemoryField?)

public static bool operator ==(MemoryField? left, MemoryField? right)

Parameters

left MemoryField
right MemoryField

Returns

bool

operator !=(MemoryField?, MemoryField?)

public static bool operator !=(MemoryField? left, MemoryField? right)

Parameters

left MemoryField
right MemoryField

Returns

bool