thing-contract (TS): list slots name ImmutableArray, as C#

This commit is contained in:
Meta Vens 2026-11-28 01:21:09 +01:00
commit b9920b20cd

View file

@ -25,13 +25,13 @@ const named = (name: string): string => `GameCult.Thing.Contract.${name}`;
const blob = present(bytes);
// The C# member type of a list slot is IReadOnlyList<T>; cultcache-ts names only List<T> (a stopgap, until
// thing2:follow_up:cultcache-ts-readonly-list-name lands). A list slot is required.
// The C# member type of a list slot is ImmutableArray<T>, a whole-value holder; cultcache-ts names only List<T>
// (a stopgap, until thing2:follow_up:cultcache-ts-readonly-list-name lands). A list slot is required.
const readOnlyList = <TItem>(item: Codec<TItem>): Codec<TItem[]> => {
const inner = sequence(item);
const readOnly: Codec<TItem[]> = {
get typeName() {
return item.typeName === undefined ? undefined : `System.Collections.Generic.IReadOnlyList<${item.typeName}>`;
return item.typeName === undefined ? undefined : `System.Collections.Immutable.ImmutableArray<${item.typeName}>`;
},
encode: (value) => inner.encode(value),
decode: (raw) => inner.decode(raw),