From e27e6170acb12b826bd334fd80240595bed476b6 Mon Sep 17 00:00:00 2001 From: Meta Vens Date: Sat, 28 Nov 2026 01:47:42 +0100 Subject: [PATCH] C# tests: a default ImmutableArray in a contract list is refused --- tests/GameCult.Thing.Contract.Tests/ReadOnlyListTests.cs | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/tests/GameCult.Thing.Contract.Tests/ReadOnlyListTests.cs b/tests/GameCult.Thing.Contract.Tests/ReadOnlyListTests.cs index 5345c60..cd79648 100644 --- a/tests/GameCult.Thing.Contract.Tests/ReadOnlyListTests.cs +++ b/tests/GameCult.Thing.Contract.Tests/ReadOnlyListTests.cs @@ -106,6 +106,11 @@ public sealed class ReadOnlyListTests args[index] = null; var list = Assert.Throws(() => door.Call(args), $"{door.Name}: nil list")!; Assert.That(list.Bound, Is.EqualTo("present"), door.Name); + + // What a nil list decodes to: a default (uninitialised) ImmutableArray, which throws on first use. + args[index] = Activator.CreateInstance(typeof(System.Collections.Immutable.ImmutableArray<>).MakeGenericType(element)); + var uninitialised = Assert.Throws(() => door.Call(args), $"{door.Name}: default array")!; + Assert.That(uninitialised.Bound, Is.EqualTo("present"), door.Name); } }