Class VBUserDefinedType
Represents any User-Defined Type (UDT) structure.
public record VBUserDefinedType : VBType, IEquatable<VBType>, IVBMemberOwnerType, IEquatable<VBUserDefinedType>
- Inheritance
-
VBUserDefinedType
- Implements
- Derived
- Inherited Members
- Extension Methods
Constructors
VBUserDefinedType(Symbol, ImmutableArray<VBTypeMemberSymbol>)
Represents any User-Defined Type (UDT) structure.
public VBUserDefinedType(Symbol Symbol, ImmutableArray<VBTypeMemberSymbol> Members)
Parameters
SymbolSymbolThe symbol associated with this UDT.
MembersImmutableArray<VBTypeMemberSymbol>The members (fields) of the UDT.
Properties
DefaultValue
Gets the default value for this data type.
public override VBTypedValue DefaultValue { get; }
Property Value
Remarks
⚠️ Derived types must back the implementation of this property with a thread-safe private static readonly Lazy<T>.
Failure to do so would lock up the static context initialization of the StaticSymbol symbols.
Members
The members (fields) of the UDT.
public ImmutableArray<VBTypeMemberSymbol> Members { get; init; }
Property Value
Symbol
The symbol associated with this UDT.
public Symbol Symbol { get; init; }
Property Value
Methods
CreateValue(IBindingHandle)
public override VBTypedValue CreateValue(IBindingHandle handle)
Parameters
handleIBindingHandle
Returns
Remarks
A UDT's field cells live on the value itself, so the value is handed back out of its own binding rather than rebuilt from it — the same way CreateValue(IBindingHandle) hands back its element cells. Rebuilding would silently return a UDT with default fields however much had been assigned to it.
Equals(VBUserDefinedType?)
public virtual bool Equals(VBUserDefinedType? other)
Parameters
otherVBUserDefinedType
Returns
Remarks
Compares by the declaring symbol's Uri instead of the compiler-generated deep
structural comparison: Members can reference field symbols whose own
ResolvedType loops back to this very UDT, which the default record equality has no way
to guard against. Compares Uri.AbsoluteUri as an ordinal string rather than using
Uri's own Equals/GetHashCode: those deliberately ignore
Uri.Fragment, and a symbol's discriminating name/location is encoded entirely in the
fragment here — two distinct UDTs sharing a workspace root would otherwise compare equal.
Field(string)
The field named name, or null when this type has no such field.
public VBUserDefinedTypeFieldSymbol? Field(string name)
Parameters
namestringThe field name, compared case-insensitively as VBA compares identifiers.
Returns
Fields()
This type's fields, in declaration order.
public IEnumerable<VBUserDefinedTypeFieldSymbol> Fields()
Returns
Remarks
Members is typed for members in general and a Type … End Type declares nothing
but fields, so every caller that wanted them was narrowing the same way. The order is the
part that matters: it is the order MS-VBAL §5.4.5.11 writes a record in, and the order
VBUserDefinedTypeLayout assigns offsets in.
GetHashCode()
Serves as the default hash function.
public override int GetHashCode()
Returns
- int
A hash code for the current object.
WithMembers(IEnumerable<VBTypeMemberSymbol>)
Gets a copy of this type with the specified members.
public IVBMemberOwnerType WithMembers(IEnumerable<VBTypeMemberSymbol> members)
Parameters
membersIEnumerable<VBTypeMemberSymbol>The members of the new type.