diff --git a/packages/GameCult.Thing.Contract/Node.cs b/packages/GameCult.Thing.Contract/Node.cs index 729fbab..8b8bdd6 100644 --- a/packages/GameCult.Thing.Contract/Node.cs +++ b/packages/GameCult.Thing.Contract/Node.cs @@ -17,6 +17,7 @@ namespace GameCult.Thing.Contract; [Union(10, typeof(PlotNode))] [Union(11, typeof(EmbedNode))] [Union(12, typeof(UseNode))] +[Union(13, typeof(SlotNode))] public abstract class Node { internal Node() { } @@ -265,6 +266,22 @@ public sealed class UseNode : Node } } +/// +/// Where a composition body places the nodes passed for its Slot parameter Param. Only a child +/// list of a composition body holds one, and resolve refuses it elsewhere. It carries no +/// : the argument's nodes, keeping their caller-scope ids, replace it. +/// +[MessagePackObject] +public sealed class SlotNode : Node +{ + [Key(0)] public ParamName Param { get; } + + public SlotNode(ParamName param) + { + Param = ThingDomain.Present(param, "Param"); + } +} + [Union(0, typeof(ImageFitContain))] [Union(1, typeof(ImageFitCover))] [Union(2, typeof(ImageFitFill))] diff --git a/packages/GameCult.Thing.Contract/Source.cs b/packages/GameCult.Thing.Contract/Source.cs index bf0ef66..b794345 100644 --- a/packages/GameCult.Thing.Contract/Source.cs +++ b/packages/GameCult.Thing.Contract/Source.cs @@ -4,6 +4,21 @@ using MessagePack; namespace GameCult.Thing.Contract; +/// +/// A parameter named, where Rust's ParamName is a field (). Where it is an +/// arm payload, the arm class (TextSourceParam and the rest) carries Name itself. +/// +[MessagePackObject] +public sealed class ParamName +{ + [Key(0)] public string Name { get; } + + public ParamName(string name) + { + Name = ThingDomain.Present(name, "Name"); + } +} + [Union(0, typeof(TextLiteral))] [Union(1, typeof(TextSourceBound))] [Union(2, typeof(TextSourceParam))] diff --git a/tests/GameCult.Thing.Contract.Tests/Builders.cs b/tests/GameCult.Thing.Contract.Tests/Builders.cs index a2348f2..6a6ce2d 100644 --- a/tests/GameCult.Thing.Contract.Tests/Builders.cs +++ b/tests/GameCult.Thing.Contract.Tests/Builders.cs @@ -263,7 +263,7 @@ internal static class Builders new("act", new ParamKindCommand()), new("body", new ParamKindSlot()), }, - Boxed("panel-root", Text("panel-title", "t"), innerUse)); + Boxed("panel-root", Text("panel-title", "t"), innerUse, new SlotNode(new ParamName("body")))); } public static List<(string Name, CommandResult Result)> Results(CommandInvocation invocation) => new() diff --git a/tests/GameCult.Thing.Contract.Tests/GoldenTests.cs b/tests/GameCult.Thing.Contract.Tests/GoldenTests.cs index e71e7fb..7f56677 100644 --- a/tests/GameCult.Thing.Contract.Tests/GoldenTests.cs +++ b/tests/GameCult.Thing.Contract.Tests/GoldenTests.cs @@ -62,7 +62,7 @@ public sealed class GoldenTests [Test] public void Thing1FlatMapIsRefused() => Refused(typeof(CommandResult), "result-thing1-flat"); - [TestCase("node-unknown-arm", typeof(SurfaceDocument), "Node", "13")] + [TestCase("node-unknown-arm", typeof(SurfaceDocument), "Node", "14")] [TestCase("outcome-unknown-arm", typeof(CommandResult), "Outcome", "4")] public void UnknownArmsAreRefusedNamingUnionAndKey(string golden, Type type, string union, string key) { diff --git a/tests/thing-contract-parity/README.md b/tests/thing-contract-parity/README.md index ea5084b..4b2c59a 100644 --- a/tests/thing-contract-parity/README.md +++ b/tests/thing-contract-parity/README.md @@ -1,6 +1,6 @@ # thing-contract-parity -The names the C# package `GameCult.Thing.Contract` gives its types. The C# package owns them because CultLib's C# reference compares catalog type names when a store reopens, and every runtime package is held to the C# names. +The names the C# package `GameCult.Thing.Contract` gives its types. The C# package owns them because CultLib's C# reference compares catalog type names when a store reopens, and every runtime package is held to the C# names. `ParamName` is in the set as `SlotNode.Param`'s type; the Param arms fold it into their own classes. | File | Rows | |---|---| diff --git a/tests/thing-contract-parity/type-names.txt b/tests/thing-contract-parity/type-names.txt index fa312ec..16fcfce 100644 --- a/tests/thing-contract-parity/type-names.txt +++ b/tests/thing-contract-parity/type-names.txt @@ -118,6 +118,7 @@ GameCult.Thing.Contract.ParamKindCommand GameCult.Thing.Contract.ParamKindNumber GameCult.Thing.Contract.ParamKindSlot GameCult.Thing.Contract.ParamKindText +GameCult.Thing.Contract.ParamName GameCult.Thing.Contract.PendingOutcome GameCult.Thing.Contract.PlotMark GameCult.Thing.Contract.PlotMarkArea @@ -144,6 +145,7 @@ GameCult.Thing.Contract.SelectOption GameCult.Thing.Contract.Size2 GameCult.Thing.Contract.SliderNode GameCult.Thing.Contract.SlotArg +GameCult.Thing.Contract.SlotNode GameCult.Thing.Contract.StateRef GameCult.Thing.Contract.StateSource GameCult.Thing.Contract.StateSourceItem