Thing contract, C#: SlotNode at union key 13 and a ParamName type for its slot; names and golden key 14
Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
This commit is contained in:
parent
3ded0c688c
commit
db3fe05aa0
6 changed files with 37 additions and 3 deletions
|
|
@ -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
|
|||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Where a composition body places the nodes passed for its Slot parameter <c>Param</c>. Only a child
|
||||
/// list of a composition body holds one, and resolve refuses it elsewhere. It carries no
|
||||
/// <see cref="NodeCommon"/>: the argument's nodes, keeping their caller-scope ids, replace it.
|
||||
/// </summary>
|
||||
[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))]
|
||||
|
|
|
|||
|
|
@ -4,6 +4,21 @@ using MessagePack;
|
|||
|
||||
namespace GameCult.Thing.Contract;
|
||||
|
||||
/// <summary>
|
||||
/// A parameter named, where Rust's ParamName is a field (<see cref="SlotNode.Param"/>). Where it is an
|
||||
/// arm payload, the arm class (TextSourceParam and the rest) carries Name itself.
|
||||
/// </summary>
|
||||
[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))]
|
||||
|
|
|
|||
|
|
@ -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()
|
||||
|
|
|
|||
|
|
@ -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)
|
||||
{
|
||||
|
|
|
|||
|
|
@ -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 |
|
||||
|---|---|
|
||||
|
|
|
|||
|
|
@ -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
|
||||
|
|
|
|||
Loading…
Reference in a new issue