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
idstringStable identity that other definitions refer to.
namestringHuman-readable name; it need not be unique within the schema.
kindMemoryTypeKindStorage category that decides which of the remaining parameters apply.
sizeintEncoded byte extent, including padding; zero only for incomplete types.
fieldsIEnumerable<MemoryField>Immediate members of a struct or union, in metadata order.
elementTypeIdstringID of an array's element type or a pointer's target type; null for an opaque pointer.
countintNumber of elements in an array; this is an element count, not a byte length.
scalarTypestringCore codec spelling for a scalar, such as
"uint32"or an enum declared indeclaration.declarationstringPortable declarations the scalar codec depends on, such as an enum definition.
provenancestringFree-text origin of this definition, kept for inspection and diagnostics.
isLittleEndianbool?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
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
ElementTypeId
Gets the array element or pointer target ID; null for non-composites and for opaque pointers.
public string? ElementTypeId { get; }
Property Value
Fields
Gets the immediate members of a struct or union in metadata order; empty for other kinds.
public IReadOnlyList<MemoryField> Fields { get; }
Property Value
Id
Gets the stable identity that fields, arrays, and pointers refer to.
public string Id { get; }
Property Value
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
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
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
Name
Gets the display name, which may be shared by several definitions.
public string Name { get; }
Property Value
Provenance
Gets the origin of this definition as recorded by its importer, when available.
public string? Provenance { get; }
Property Value
ScalarType
Gets the core codec spelling for a scalar; null for other kinds.
public string? ScalarType { get; }
Property Value
Size
Gets the encoded extent in bytes, including padding.
public int Size { get; }
Property Value
UnselectedMembers
Gets immediate member names deliberately omitted from this composite, in metadata order; their descriptors have not been validated.
public IReadOnlyList<string> UnselectedMembers { get; }