TS names test: list slots are ImmutableArray

This commit is contained in:
Meta Vens 2026-11-28 01:27:23 +01:00
commit 553070571c

View file

@ -1,6 +1,6 @@
// The type names the package gives its codecs are the C# package's (tests/thing-contract-parity), and the member names
// follow the owner's: Rust names that C# flattens into arm classes have one codec per arm, a list slot names
// IReadOnlyList<T>, and TextInputNode's slot 2 is inputKind, the camelCase of C# InputKind.
// ImmutableArray<T>, and TextInputNode's slot 2 is inputKind, the camelCase of C# InputKind.
import assert from "node:assert/strict";
import { join } from "node:path";
import test from "node:test";
@ -35,13 +35,13 @@ test("Scalar is a Rust name the C# package does not have; ParamName is its type
}
});
test("a list slot is named IReadOnlyList, never List, and the element is a type of the C# package", () => {
test("a list slot is named ImmutableArray, never List, and the element is a type of the C# package", () => {
let lists = 0;
for (const [key, codec] of entries) {
for (const member of codec.members ?? []) {
if (!/List</u.test(member.typeName)) continue;
if (!/(List|ImmutableArray)</u.test(member.typeName)) continue;
lists++;
const element = /^System\.Collections\.Generic\.IReadOnlyList<(.+)>$/u.exec(member.typeName);
const element = /^System\.Collections\.Immutable\.ImmutableArray<(.+)>$/u.exec(member.typeName);
assert.ok(element !== null, `${key}: ${member.typeName}`);
assert.ok(element[1] === "System.String" || names.has(element[1]), `${key}: ${member.typeName}`);
}