Table of Contents

Class MemoryTypeDefinition

Namespace
CStructSharp.Memory
Assembly
CStructSharp.dll

An immutable description of one type: its identity, display name, kind, explicit byte size, and kind-specific details.

public sealed class MemoryTypeDefinition
Inheritance
MemoryTypeDefinition
Inherited Members

Remarks

Definitions are the nodes of a MemorySchema graph, connected by IDs. Id is the key that fields, arrays, and pointers refer to; Name is only for display. The two are separate because native metadata routinely contains distinct types with the same name (two unrelated struct node definitions in different translation units), and an importer must be able to keep both.

Size is always a byte count and includes any padding the compiler inserted, which is how a memory schema differs from a Portable declaration: the size is stated, not computed. The remaining members depend on the kind. Composites list their immediate Fields; arrays and pointers name their element or target through ElementTypeId, with Count giving an array's element count; scalars name a core codec through ScalarType so the memory APIs never duplicate numeric decoding.

Constructing a definition snapshots its fields but does not validate references, because a referenced type may not exist yet while an importer is still building the graph. MemorySchema validates everything once all definitions are available.

Constructors

MemoryTypeDefinition(string, string, MemoryTypeKind, int, IEnumerable<MemoryField>?, string?, int, string?, string?, string?, bool?)

Creates a definition, snapshotting its fields; graph-wide validation happens in MemorySchema.

public MemoryTypeDefinition(string id, string name, MemoryTypeKind kind, int size, IEnumerable<MemoryField>? fields = null, string? elementTypeId = null, int count = 0, string? scalarType = null, string? declaration = null, string? provenance = null, bool? isLittleEndian = null)

Parameters

id string

Stable identity that other definitions refer to.

name string

Human-readable name; it need not be unique within the schema.

kind MemoryTypeKind

Storage category that decides which of the remaining parameters apply.

size int

Encoded byte extent, including padding; zero only for incomplete types.

fields IEnumerable<MemoryField>

Immediate members of a struct or union, in metadata order.

elementTypeId string

ID of an array's element type or a pointer's target type; null for an opaque pointer.

count int

Number of elements in an array; this is an element count, not a byte length.

scalarType string

Core codec spelling for a scalar, such as "uint32" or an enum declared in declaration.

declaration string

Portable declarations the scalar codec depends on, such as an enum definition.

provenance string

Free-text origin of this definition, kept for inspection and diagnostics.

isLittleEndian bool?

Byte order for this scalar, or null to inherit the schema default.

Properties

Count

Gets the number of elements in an array; zero for other kinds.

public int Count { get; }

Property Value

int

Declaration

Gets Portable declarations the scalar codec depends on, such as an enum definition; null when none are needed.

public string? Declaration { get; }

Property Value

string

ElementTypeId

Gets the array element or pointer target ID; null for non-composites and for opaque pointers.

public string? ElementTypeId { get; }

Property Value

string

Fields

Gets the immediate members of a struct or union in metadata order; empty for other kinds.

public IReadOnlyList<MemoryField> Fields { get; }

Property Value

IReadOnlyList<MemoryField>

Id

Gets the stable identity that fields, arrays, and pointers refer to.

public string Id { get; }

Property Value

string

IsLittleEndian

Gets the scalar's byte order, or null to inherit the schema default.

public bool? IsLittleEndian { get; }

Property Value

bool?

IsProjected

Gets whether this composite was imported with a narrower field-validation scope.

public bool IsProjected { get; }

Property Value

bool

Remarks

Fields contains the union required by the selected paths. Whole-value reads return only those fields; use a full import for general inspection.

IsUnselected

Gets whether this address-only identity was deliberately left outside a projection, rather than missing from the metadata.

public bool IsUnselected { get; }

Property Value

bool

Remarks

This marker does not establish whether the metadata defines the type: its representation was not examined. Import separately or select a pointer value path in a new projection. Existing schemas never expand implicitly.

Kind

Gets the storage category.

public MemoryTypeKind Kind { get; }

Property Value

MemoryTypeKind

Name

Gets the display name, which may be shared by several definitions.

public string Name { get; }

Property Value

string

Provenance

Gets the origin of this definition as recorded by its importer, when available.

public string? Provenance { get; }

Property Value

string

ScalarType

Gets the core codec spelling for a scalar; null for other kinds.

public string? ScalarType { get; }

Property Value

string

Size

Gets the encoded extent in bytes, including padding.

public int Size { get; }

Property Value

int

UnselectedMembers

Gets immediate member names deliberately omitted from this composite, in metadata order; their descriptors have not been validated.

public IReadOnlyList<string> UnselectedMembers { get; }

Property Value

IReadOnlyList<string>