Table of Contents

Class VBUserDefinedTypeValue

Namespace
RDCore.SDK.Model.Values.Intrinsic
Assembly
RDCore.SDK.dll

Represents a value of a VBUserDefinedType. Like VBObjectValue the value is a MemoryAddress — a UDT has location identity and is never passed by value.

public record VBUserDefinedTypeValue : VBTypedValue, IEquatable<VBTypedValue>, IVBTypedValue<VBUserDefinedTypeValue, MemoryAddress>, IEquatable<IVBTypedValue<VBUserDefinedTypeValue, MemoryAddress>>, IEquatable<VBUserDefinedTypeValue>
Inheritance
VBUserDefinedTypeValue
Implements
Inherited Members

Remarks

👉 The field store is a flat block of cells in declaration order, exactly as VBArrayValue holds its elements and for the same reason: a UDT's real content is its fields, and a scalar IRuntimeValue has nowhere to hold them. Declaration order is not an implementation detail — it is the order MS-VBAL §5.4.5.11 writes a record in, and the order VBUserDefinedTypeLayout assigns offsets in.

Constructors

VBUserDefinedTypeValue(VBUserDefinedType)

public VBUserDefinedTypeValue(VBUserDefinedType typeInfo)

Parameters

typeInfo VBUserDefinedType

VBUserDefinedTypeValue(IBindingHandle, VBUserDefinedType)

public VBUserDefinedTypeValue(IBindingHandle handle, VBUserDefinedType typeInfo)

Parameters

handle IBindingHandle
typeInfo VBUserDefinedType

VBUserDefinedTypeValue(VBUserDefinedTypeValue)

protected VBUserDefinedTypeValue(VBUserDefinedTypeValue original)

Parameters

original VBUserDefinedTypeValue

VBUserDefinedTypeValue(MemoryAddress, VBUserDefinedType)

public VBUserDefinedTypeValue(MemoryAddress reference, VBUserDefinedType typeInfo)

Parameters

reference MemoryAddress
typeInfo VBUserDefinedType

Properties

Fields

This type's fields, in declaration order — the same symbols Fields() reports, held here so that a value can name its own fields without resolving its type again.

public ImmutableArray<VBUserDefinedTypeFieldSymbol> Fields { get; init; }

Property Value

ImmutableArray<VBUserDefinedTypeFieldSymbol>

this[string]

The value of the field named name, or null when there is no such field.

public VBTypedValue? this[string name] { get; }

Parameters

name string

The field name, compared case-insensitively as VBA compares identifiers.

Property Value

VBTypedValue

Layout

Where each of this value's fields sits in memory.

public VBUserDefinedTypeLayout Layout { get; }

Property Value

VBUserDefinedTypeLayout

Size

The in-memory size of this UDT, MS-VBA's own padding included — what LenB reports (MS-VBAL §6.1.2.11).

public override int Size { get; }

Property Value

int

Remarks

Not the size a Put statement writes, which is the unpadded concatenation of the fields and is what Len reports of a UDT instead: "Len returns the size as it will be written to the file". VBUserDefinedTypeLayout holds the padding rule and the reasoning behind it.

Value

Gets the underlying managed value corresponding to this typed value.

public MemoryAddress Value { get; }

Property Value

MemoryAddress

Methods

Equals(IVBTypedValue<VBUserDefinedTypeValue, MemoryAddress>?)

Indicates whether the current object is equal to another object of the same type.

public bool Equals(IVBTypedValue<VBUserDefinedTypeValue, MemoryAddress>? other)

Parameters

other IVBTypedValue<VBUserDefinedTypeValue, MemoryAddress>

An object to compare with this object.

Returns

bool

true if the current object is equal to the other parameter; otherwise, false.

FieldAt(int)

The value of the field at index in declaration order, or null when there is no field there.

public VBTypedValue? FieldAt(int index)

Parameters

index int

Returns

VBTypedValue

Remarks

Declaration order is what a record is written and read in, so a caller walking the fields to serialize them wants this rather than the name-keyed indexer.

GetFieldHandle(string)

The binding of the field named name, or null when there is no such field.

public IBindingHandle? GetFieldHandle(string name)

Parameters

name string

The field name, compared case-insensitively.

Returns

IBindingHandle

Remarks

What a ByRef argument of a UDT field needs, and what an assignment to one writes through — neither of which constructs a value, so neither goes through the indexer.

TryAllocateIn(ISessionStorage, out VBUserDefinedTypeValue?)

Reserves storage sized for this UDT through storage, and returns a copy of this value bound to the resulting address — a UDT's identity is its address, so the allocated copy self-reports the very address it was allocated at.

public bool TryAllocateIn(ISessionStorage storage, out VBUserDefinedTypeValue? allocated)

Parameters

storage ISessionStorage
allocated VBUserDefinedTypeValue

Returns

bool

false if the underlying memory space is exhausted.

TrySetField(string, VBTypedValue)

Replaces the value of the field named name. Mutates the cell in place — field storage is mutable, the way array element storage is.

public bool TrySetField(string name, VBTypedValue value)

Parameters

name string

The field name, compared case-insensitively.

value VBTypedValue

The value to store.

Returns

bool

false when there is no such field.

TrySetFieldAt(int, VBTypedValue)

Replaces the value of the field at index in declaration order.

public bool TrySetFieldAt(int index, VBTypedValue value)

Parameters

index int

The field's position in declaration order.

value VBTypedValue

The value to store.

Returns

bool

false when there is no field there.