GameCult.Thing.Contract: a unit arm is its arm type; the 58 static instances are gone
Deleted the 38 + 17 + 3 internal static Instance fields and public static unit-arm properties. Unit arms are built with new ImageFitContain() and told by a type test; the arm constructors are public. Builders rewritten (65 uses); UnitArmTests replaces the SameAs assertions: every decoded unit arm is its arm type, no union base exposes a static member of its own kind, and new ImageFitFill() still writes 92 02 90. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
parent
ee80246cd0
commit
a6a7a97634
6 changed files with 236 additions and 358 deletions
|
|
@ -272,42 +272,30 @@ public sealed class UseNode : Node
|
|||
public abstract class ImageFit
|
||||
{
|
||||
internal ImageFit() { }
|
||||
public static ImageFit Contain => ImageFitContain.Instance;
|
||||
public static ImageFit Cover => ImageFitCover.Instance;
|
||||
public static ImageFit Fill => ImageFitFill.Instance;
|
||||
public static ImageFit Unscaled => ImageFitUnscaled.Instance;
|
||||
}
|
||||
|
||||
[MessagePackObject(AllowPrivate = true)]
|
||||
[MessagePackObject]
|
||||
public sealed class ImageFitContain : ImageFit
|
||||
{
|
||||
internal static readonly ImageFitContain Instance = new ImageFitContain();
|
||||
|
||||
[SerializationConstructor] private ImageFitContain() { }
|
||||
public ImageFitContain() { }
|
||||
}
|
||||
|
||||
[MessagePackObject(AllowPrivate = true)]
|
||||
[MessagePackObject]
|
||||
public sealed class ImageFitCover : ImageFit
|
||||
{
|
||||
internal static readonly ImageFitCover Instance = new ImageFitCover();
|
||||
|
||||
[SerializationConstructor] private ImageFitCover() { }
|
||||
public ImageFitCover() { }
|
||||
}
|
||||
|
||||
[MessagePackObject(AllowPrivate = true)]
|
||||
[MessagePackObject]
|
||||
public sealed class ImageFitFill : ImageFit
|
||||
{
|
||||
internal static readonly ImageFitFill Instance = new ImageFitFill();
|
||||
|
||||
[SerializationConstructor] private ImageFitFill() { }
|
||||
public ImageFitFill() { }
|
||||
}
|
||||
|
||||
[MessagePackObject(AllowPrivate = true)]
|
||||
[MessagePackObject]
|
||||
public sealed class ImageFitUnscaled : ImageFit
|
||||
{
|
||||
internal static readonly ImageFitUnscaled Instance = new ImageFitUnscaled();
|
||||
|
||||
[SerializationConstructor] private ImageFitUnscaled() { }
|
||||
public ImageFitUnscaled() { }
|
||||
}
|
||||
|
||||
[Union(0, typeof(InputKindText))]
|
||||
|
|
@ -315,24 +303,18 @@ public sealed class ImageFitUnscaled : ImageFit
|
|||
public abstract class InputKind
|
||||
{
|
||||
internal InputKind() { }
|
||||
public static InputKind Text => InputKindText.Instance;
|
||||
public static InputKind Number => InputKindNumber.Instance;
|
||||
}
|
||||
|
||||
[MessagePackObject(AllowPrivate = true)]
|
||||
[MessagePackObject]
|
||||
public sealed class InputKindText : InputKind
|
||||
{
|
||||
internal static readonly InputKindText Instance = new InputKindText();
|
||||
|
||||
[SerializationConstructor] private InputKindText() { }
|
||||
public InputKindText() { }
|
||||
}
|
||||
|
||||
[MessagePackObject(AllowPrivate = true)]
|
||||
[MessagePackObject]
|
||||
public sealed class InputKindNumber : InputKind
|
||||
{
|
||||
internal static readonly InputKindNumber Instance = new InputKindNumber();
|
||||
|
||||
[SerializationConstructor] private InputKindNumber() { }
|
||||
public InputKindNumber() { }
|
||||
}
|
||||
|
||||
[Union(0, typeof(LiteralOptions))]
|
||||
|
|
@ -373,15 +355,12 @@ public sealed class BoundOptions : OptionList
|
|||
public abstract class Anchor
|
||||
{
|
||||
internal Anchor() { }
|
||||
public static Anchor Viewport => AnchorViewport.Instance;
|
||||
}
|
||||
|
||||
[MessagePackObject(AllowPrivate = true)]
|
||||
[MessagePackObject]
|
||||
public sealed class AnchorViewport : Anchor
|
||||
{
|
||||
internal static readonly AnchorViewport Instance = new AnchorViewport();
|
||||
|
||||
[SerializationConstructor] private AnchorViewport() { }
|
||||
public AnchorViewport() { }
|
||||
}
|
||||
|
||||
[MessagePackObject]
|
||||
|
|
@ -401,33 +380,24 @@ public sealed class AnchorNode : Anchor
|
|||
public abstract class PlotMark
|
||||
{
|
||||
internal PlotMark() { }
|
||||
public static PlotMark Line => PlotMarkLine.Instance;
|
||||
public static PlotMark Bar => PlotMarkBar.Instance;
|
||||
public static PlotMark Area => PlotMarkArea.Instance;
|
||||
}
|
||||
|
||||
[MessagePackObject(AllowPrivate = true)]
|
||||
[MessagePackObject]
|
||||
public sealed class PlotMarkLine : PlotMark
|
||||
{
|
||||
internal static readonly PlotMarkLine Instance = new PlotMarkLine();
|
||||
|
||||
[SerializationConstructor] private PlotMarkLine() { }
|
||||
public PlotMarkLine() { }
|
||||
}
|
||||
|
||||
[MessagePackObject(AllowPrivate = true)]
|
||||
[MessagePackObject]
|
||||
public sealed class PlotMarkBar : PlotMark
|
||||
{
|
||||
internal static readonly PlotMarkBar Instance = new PlotMarkBar();
|
||||
|
||||
[SerializationConstructor] private PlotMarkBar() { }
|
||||
public PlotMarkBar() { }
|
||||
}
|
||||
|
||||
[MessagePackObject(AllowPrivate = true)]
|
||||
[MessagePackObject]
|
||||
public sealed class PlotMarkArea : PlotMark
|
||||
{
|
||||
internal static readonly PlotMarkArea Instance = new PlotMarkArea();
|
||||
|
||||
[SerializationConstructor] private PlotMarkArea() { }
|
||||
public PlotMarkArea() { }
|
||||
}
|
||||
|
||||
[Union(0, typeof(TextArg))]
|
||||
|
|
@ -533,69 +503,48 @@ public sealed class SlotArg : ArgValue
|
|||
public abstract class ParamKind
|
||||
{
|
||||
internal ParamKind() { }
|
||||
public static ParamKind Text => ParamKindText.Instance;
|
||||
public static ParamKind Number => ParamKindNumber.Instance;
|
||||
public static ParamKind Bool => ParamKindBool.Instance;
|
||||
public static ParamKind Bind => ParamKindBind.Instance;
|
||||
public static ParamKind Collection => ParamKindCollection.Instance;
|
||||
public static ParamKind Command => ParamKindCommand.Instance;
|
||||
public static ParamKind Slot => ParamKindSlot.Instance;
|
||||
}
|
||||
|
||||
[MessagePackObject(AllowPrivate = true)]
|
||||
[MessagePackObject]
|
||||
public sealed class ParamKindText : ParamKind
|
||||
{
|
||||
internal static readonly ParamKindText Instance = new ParamKindText();
|
||||
|
||||
[SerializationConstructor] private ParamKindText() { }
|
||||
public ParamKindText() { }
|
||||
}
|
||||
|
||||
[MessagePackObject(AllowPrivate = true)]
|
||||
[MessagePackObject]
|
||||
public sealed class ParamKindNumber : ParamKind
|
||||
{
|
||||
internal static readonly ParamKindNumber Instance = new ParamKindNumber();
|
||||
|
||||
[SerializationConstructor] private ParamKindNumber() { }
|
||||
public ParamKindNumber() { }
|
||||
}
|
||||
|
||||
[MessagePackObject(AllowPrivate = true)]
|
||||
[MessagePackObject]
|
||||
public sealed class ParamKindBool : ParamKind
|
||||
{
|
||||
internal static readonly ParamKindBool Instance = new ParamKindBool();
|
||||
|
||||
[SerializationConstructor] private ParamKindBool() { }
|
||||
public ParamKindBool() { }
|
||||
}
|
||||
|
||||
[MessagePackObject(AllowPrivate = true)]
|
||||
[MessagePackObject]
|
||||
public sealed class ParamKindBind : ParamKind
|
||||
{
|
||||
internal static readonly ParamKindBind Instance = new ParamKindBind();
|
||||
|
||||
[SerializationConstructor] private ParamKindBind() { }
|
||||
public ParamKindBind() { }
|
||||
}
|
||||
|
||||
[MessagePackObject(AllowPrivate = true)]
|
||||
[MessagePackObject]
|
||||
public sealed class ParamKindCollection : ParamKind
|
||||
{
|
||||
internal static readonly ParamKindCollection Instance = new ParamKindCollection();
|
||||
|
||||
[SerializationConstructor] private ParamKindCollection() { }
|
||||
public ParamKindCollection() { }
|
||||
}
|
||||
|
||||
[MessagePackObject(AllowPrivate = true)]
|
||||
[MessagePackObject]
|
||||
public sealed class ParamKindCommand : ParamKind
|
||||
{
|
||||
internal static readonly ParamKindCommand Instance = new ParamKindCommand();
|
||||
|
||||
[SerializationConstructor] private ParamKindCommand() { }
|
||||
public ParamKindCommand() { }
|
||||
}
|
||||
|
||||
[MessagePackObject(AllowPrivate = true)]
|
||||
[MessagePackObject]
|
||||
public sealed class ParamKindSlot : ParamKind
|
||||
{
|
||||
internal static readonly ParamKindSlot Instance = new ParamKindSlot();
|
||||
|
||||
[SerializationConstructor] private ParamKindSlot() { }
|
||||
public ParamKindSlot() { }
|
||||
}
|
||||
|
||||
[MessagePackObject]
|
||||
|
|
|
|||
|
|
@ -144,7 +144,6 @@ public sealed class BoolSourceParam : BoolSource
|
|||
public abstract class StateSource
|
||||
{
|
||||
internal StateSource() { }
|
||||
public static StateSource Item => StateSourceItem.Instance;
|
||||
}
|
||||
|
||||
[MessagePackObject]
|
||||
|
|
@ -162,12 +161,10 @@ public sealed class StateRef : StateSource
|
|||
}
|
||||
}
|
||||
|
||||
[MessagePackObject(AllowPrivate = true)]
|
||||
[MessagePackObject]
|
||||
public sealed class StateSourceItem : StateSource
|
||||
{
|
||||
internal static readonly StateSourceItem Instance = new StateSourceItem();
|
||||
|
||||
[SerializationConstructor] private StateSourceItem() { }
|
||||
public StateSourceItem() { }
|
||||
}
|
||||
|
||||
[Union(0, typeof(MemberName))]
|
||||
|
|
@ -206,8 +203,6 @@ public sealed class MemberIndex : MemberStep
|
|||
public abstract class Format
|
||||
{
|
||||
internal Format() { }
|
||||
public static Format Duration => FormatDuration.Instance;
|
||||
public static Format Timestamp => FormatTimestamp.Instance;
|
||||
}
|
||||
|
||||
[MessagePackObject]
|
||||
|
|
@ -225,20 +220,16 @@ public sealed class NumberFormat : Format
|
|||
}
|
||||
}
|
||||
|
||||
[MessagePackObject(AllowPrivate = true)]
|
||||
[MessagePackObject]
|
||||
public sealed class FormatDuration : Format
|
||||
{
|
||||
internal static readonly FormatDuration Instance = new FormatDuration();
|
||||
|
||||
[SerializationConstructor] private FormatDuration() { }
|
||||
public FormatDuration() { }
|
||||
}
|
||||
|
||||
[MessagePackObject(AllowPrivate = true)]
|
||||
[MessagePackObject]
|
||||
public sealed class FormatTimestamp : Format
|
||||
{
|
||||
internal static readonly FormatTimestamp Instance = new FormatTimestamp();
|
||||
|
||||
[SerializationConstructor] private FormatTimestamp() { }
|
||||
public FormatTimestamp() { }
|
||||
}
|
||||
|
||||
[MessagePackObject]
|
||||
|
|
|
|||
|
|
@ -12,8 +12,6 @@ namespace GameCult.Thing.Contract;
|
|||
public abstract class Dimension
|
||||
{
|
||||
internal Dimension() { }
|
||||
public static Dimension Auto => DimensionAuto.Instance;
|
||||
public static Dimension Content => DimensionContent.Instance;
|
||||
}
|
||||
|
||||
[MessagePackObject]
|
||||
|
|
@ -49,20 +47,16 @@ public sealed class DimensionFr : Dimension
|
|||
}
|
||||
}
|
||||
|
||||
[MessagePackObject(AllowPrivate = true)]
|
||||
[MessagePackObject]
|
||||
public sealed class DimensionAuto : Dimension
|
||||
{
|
||||
internal static readonly DimensionAuto Instance = new DimensionAuto();
|
||||
|
||||
[SerializationConstructor] private DimensionAuto() { }
|
||||
public DimensionAuto() { }
|
||||
}
|
||||
|
||||
[MessagePackObject(AllowPrivate = true)]
|
||||
[MessagePackObject]
|
||||
public sealed class DimensionContent : Dimension
|
||||
{
|
||||
internal static readonly DimensionContent Instance = new DimensionContent();
|
||||
|
||||
[SerializationConstructor] private DimensionContent() { }
|
||||
public DimensionContent() { }
|
||||
}
|
||||
|
||||
[Union(0, typeof(DisplayFlex))]
|
||||
|
|
@ -71,33 +65,24 @@ public sealed class DimensionContent : Dimension
|
|||
public abstract class Display
|
||||
{
|
||||
internal Display() { }
|
||||
public static Display Flex => DisplayFlex.Instance;
|
||||
public static Display Grid => DisplayGrid.Instance;
|
||||
public static Display Block => DisplayBlock.Instance;
|
||||
}
|
||||
|
||||
[MessagePackObject(AllowPrivate = true)]
|
||||
[MessagePackObject]
|
||||
public sealed class DisplayFlex : Display
|
||||
{
|
||||
internal static readonly DisplayFlex Instance = new DisplayFlex();
|
||||
|
||||
[SerializationConstructor] private DisplayFlex() { }
|
||||
public DisplayFlex() { }
|
||||
}
|
||||
|
||||
[MessagePackObject(AllowPrivate = true)]
|
||||
[MessagePackObject]
|
||||
public sealed class DisplayGrid : Display
|
||||
{
|
||||
internal static readonly DisplayGrid Instance = new DisplayGrid();
|
||||
|
||||
[SerializationConstructor] private DisplayGrid() { }
|
||||
public DisplayGrid() { }
|
||||
}
|
||||
|
||||
[MessagePackObject(AllowPrivate = true)]
|
||||
[MessagePackObject]
|
||||
public sealed class DisplayBlock : Display
|
||||
{
|
||||
internal static readonly DisplayBlock Instance = new DisplayBlock();
|
||||
|
||||
[SerializationConstructor] private DisplayBlock() { }
|
||||
public DisplayBlock() { }
|
||||
}
|
||||
|
||||
[Union(0, typeof(DirectionRow))]
|
||||
|
|
@ -107,42 +92,30 @@ public sealed class DisplayBlock : Display
|
|||
public abstract class Direction
|
||||
{
|
||||
internal Direction() { }
|
||||
public static Direction Row => DirectionRow.Instance;
|
||||
public static Direction Column => DirectionColumn.Instance;
|
||||
public static Direction RowReverse => DirectionRowReverse.Instance;
|
||||
public static Direction ColumnReverse => DirectionColumnReverse.Instance;
|
||||
}
|
||||
|
||||
[MessagePackObject(AllowPrivate = true)]
|
||||
[MessagePackObject]
|
||||
public sealed class DirectionRow : Direction
|
||||
{
|
||||
internal static readonly DirectionRow Instance = new DirectionRow();
|
||||
|
||||
[SerializationConstructor] private DirectionRow() { }
|
||||
public DirectionRow() { }
|
||||
}
|
||||
|
||||
[MessagePackObject(AllowPrivate = true)]
|
||||
[MessagePackObject]
|
||||
public sealed class DirectionColumn : Direction
|
||||
{
|
||||
internal static readonly DirectionColumn Instance = new DirectionColumn();
|
||||
|
||||
[SerializationConstructor] private DirectionColumn() { }
|
||||
public DirectionColumn() { }
|
||||
}
|
||||
|
||||
[MessagePackObject(AllowPrivate = true)]
|
||||
[MessagePackObject]
|
||||
public sealed class DirectionRowReverse : Direction
|
||||
{
|
||||
internal static readonly DirectionRowReverse Instance = new DirectionRowReverse();
|
||||
|
||||
[SerializationConstructor] private DirectionRowReverse() { }
|
||||
public DirectionRowReverse() { }
|
||||
}
|
||||
|
||||
[MessagePackObject(AllowPrivate = true)]
|
||||
[MessagePackObject]
|
||||
public sealed class DirectionColumnReverse : Direction
|
||||
{
|
||||
internal static readonly DirectionColumnReverse Instance = new DirectionColumnReverse();
|
||||
|
||||
[SerializationConstructor] private DirectionColumnReverse() { }
|
||||
public DirectionColumnReverse() { }
|
||||
}
|
||||
|
||||
[Union(0, typeof(WrapNoWrap))]
|
||||
|
|
@ -151,33 +124,24 @@ public sealed class DirectionColumnReverse : Direction
|
|||
public abstract class Wrap
|
||||
{
|
||||
internal Wrap() { }
|
||||
public static Wrap NoWrap => WrapNoWrap.Instance;
|
||||
public static Wrap Wrapped => WrapWrap.Instance;
|
||||
public static Wrap WrapReverse => WrapWrapReverse.Instance;
|
||||
}
|
||||
|
||||
[MessagePackObject(AllowPrivate = true)]
|
||||
[MessagePackObject]
|
||||
public sealed class WrapNoWrap : Wrap
|
||||
{
|
||||
internal static readonly WrapNoWrap Instance = new WrapNoWrap();
|
||||
|
||||
[SerializationConstructor] private WrapNoWrap() { }
|
||||
public WrapNoWrap() { }
|
||||
}
|
||||
|
||||
[MessagePackObject(AllowPrivate = true)]
|
||||
[MessagePackObject]
|
||||
public sealed class WrapWrap : Wrap
|
||||
{
|
||||
internal static readonly WrapWrap Instance = new WrapWrap();
|
||||
|
||||
[SerializationConstructor] private WrapWrap() { }
|
||||
public WrapWrap() { }
|
||||
}
|
||||
|
||||
[MessagePackObject(AllowPrivate = true)]
|
||||
[MessagePackObject]
|
||||
public sealed class WrapWrapReverse : Wrap
|
||||
{
|
||||
internal static readonly WrapWrapReverse Instance = new WrapWrapReverse();
|
||||
|
||||
[SerializationConstructor] private WrapWrapReverse() { }
|
||||
public WrapWrapReverse() { }
|
||||
}
|
||||
|
||||
[Union(0, typeof(PositionRelative))]
|
||||
|
|
@ -185,24 +149,18 @@ public sealed class WrapWrapReverse : Wrap
|
|||
public abstract class Position
|
||||
{
|
||||
internal Position() { }
|
||||
public static Position Relative => PositionRelative.Instance;
|
||||
public static Position Absolute => PositionAbsolute.Instance;
|
||||
}
|
||||
|
||||
[MessagePackObject(AllowPrivate = true)]
|
||||
[MessagePackObject]
|
||||
public sealed class PositionRelative : Position
|
||||
{
|
||||
internal static readonly PositionRelative Instance = new PositionRelative();
|
||||
|
||||
[SerializationConstructor] private PositionRelative() { }
|
||||
public PositionRelative() { }
|
||||
}
|
||||
|
||||
[MessagePackObject(AllowPrivate = true)]
|
||||
[MessagePackObject]
|
||||
public sealed class PositionAbsolute : Position
|
||||
{
|
||||
internal static readonly PositionAbsolute Instance = new PositionAbsolute();
|
||||
|
||||
[SerializationConstructor] private PositionAbsolute() { }
|
||||
public PositionAbsolute() { }
|
||||
}
|
||||
|
||||
[Union(0, typeof(OverflowVisible))]
|
||||
|
|
@ -211,33 +169,24 @@ public sealed class PositionAbsolute : Position
|
|||
public abstract class Overflow
|
||||
{
|
||||
internal Overflow() { }
|
||||
public static Overflow Visible => OverflowVisible.Instance;
|
||||
public static Overflow Clip => OverflowClip.Instance;
|
||||
public static Overflow Scroll => OverflowScroll.Instance;
|
||||
}
|
||||
|
||||
[MessagePackObject(AllowPrivate = true)]
|
||||
[MessagePackObject]
|
||||
public sealed class OverflowVisible : Overflow
|
||||
{
|
||||
internal static readonly OverflowVisible Instance = new OverflowVisible();
|
||||
|
||||
[SerializationConstructor] private OverflowVisible() { }
|
||||
public OverflowVisible() { }
|
||||
}
|
||||
|
||||
[MessagePackObject(AllowPrivate = true)]
|
||||
[MessagePackObject]
|
||||
public sealed class OverflowClip : Overflow
|
||||
{
|
||||
internal static readonly OverflowClip Instance = new OverflowClip();
|
||||
|
||||
[SerializationConstructor] private OverflowClip() { }
|
||||
public OverflowClip() { }
|
||||
}
|
||||
|
||||
[MessagePackObject(AllowPrivate = true)]
|
||||
[MessagePackObject]
|
||||
public sealed class OverflowScroll : Overflow
|
||||
{
|
||||
internal static readonly OverflowScroll Instance = new OverflowScroll();
|
||||
|
||||
[SerializationConstructor] private OverflowScroll() { }
|
||||
public OverflowScroll() { }
|
||||
}
|
||||
|
||||
[Union(0, typeof(ItemAlignAuto))]
|
||||
|
|
@ -249,60 +198,42 @@ public sealed class OverflowScroll : Overflow
|
|||
public abstract class ItemAlign
|
||||
{
|
||||
internal ItemAlign() { }
|
||||
public static ItemAlign Auto => ItemAlignAuto.Instance;
|
||||
public static ItemAlign Start => ItemAlignStart.Instance;
|
||||
public static ItemAlign End => ItemAlignEnd.Instance;
|
||||
public static ItemAlign Center => ItemAlignCenter.Instance;
|
||||
public static ItemAlign Stretch => ItemAlignStretch.Instance;
|
||||
public static ItemAlign Baseline => ItemAlignBaseline.Instance;
|
||||
}
|
||||
|
||||
[MessagePackObject(AllowPrivate = true)]
|
||||
[MessagePackObject]
|
||||
public sealed class ItemAlignAuto : ItemAlign
|
||||
{
|
||||
internal static readonly ItemAlignAuto Instance = new ItemAlignAuto();
|
||||
|
||||
[SerializationConstructor] private ItemAlignAuto() { }
|
||||
public ItemAlignAuto() { }
|
||||
}
|
||||
|
||||
[MessagePackObject(AllowPrivate = true)]
|
||||
[MessagePackObject]
|
||||
public sealed class ItemAlignStart : ItemAlign
|
||||
{
|
||||
internal static readonly ItemAlignStart Instance = new ItemAlignStart();
|
||||
|
||||
[SerializationConstructor] private ItemAlignStart() { }
|
||||
public ItemAlignStart() { }
|
||||
}
|
||||
|
||||
[MessagePackObject(AllowPrivate = true)]
|
||||
[MessagePackObject]
|
||||
public sealed class ItemAlignEnd : ItemAlign
|
||||
{
|
||||
internal static readonly ItemAlignEnd Instance = new ItemAlignEnd();
|
||||
|
||||
[SerializationConstructor] private ItemAlignEnd() { }
|
||||
public ItemAlignEnd() { }
|
||||
}
|
||||
|
||||
[MessagePackObject(AllowPrivate = true)]
|
||||
[MessagePackObject]
|
||||
public sealed class ItemAlignCenter : ItemAlign
|
||||
{
|
||||
internal static readonly ItemAlignCenter Instance = new ItemAlignCenter();
|
||||
|
||||
[SerializationConstructor] private ItemAlignCenter() { }
|
||||
public ItemAlignCenter() { }
|
||||
}
|
||||
|
||||
[MessagePackObject(AllowPrivate = true)]
|
||||
[MessagePackObject]
|
||||
public sealed class ItemAlignStretch : ItemAlign
|
||||
{
|
||||
internal static readonly ItemAlignStretch Instance = new ItemAlignStretch();
|
||||
|
||||
[SerializationConstructor] private ItemAlignStretch() { }
|
||||
public ItemAlignStretch() { }
|
||||
}
|
||||
|
||||
[MessagePackObject(AllowPrivate = true)]
|
||||
[MessagePackObject]
|
||||
public sealed class ItemAlignBaseline : ItemAlign
|
||||
{
|
||||
internal static readonly ItemAlignBaseline Instance = new ItemAlignBaseline();
|
||||
|
||||
[SerializationConstructor] private ItemAlignBaseline() { }
|
||||
public ItemAlignBaseline() { }
|
||||
}
|
||||
|
||||
[Union(0, typeof(ContentAlignAuto))]
|
||||
|
|
@ -316,78 +247,54 @@ public sealed class ItemAlignBaseline : ItemAlign
|
|||
public abstract class ContentAlign
|
||||
{
|
||||
internal ContentAlign() { }
|
||||
public static ContentAlign Auto => ContentAlignAuto.Instance;
|
||||
public static ContentAlign Start => ContentAlignStart.Instance;
|
||||
public static ContentAlign End => ContentAlignEnd.Instance;
|
||||
public static ContentAlign Center => ContentAlignCenter.Instance;
|
||||
public static ContentAlign Stretch => ContentAlignStretch.Instance;
|
||||
public static ContentAlign SpaceBetween => ContentAlignSpaceBetween.Instance;
|
||||
public static ContentAlign SpaceAround => ContentAlignSpaceAround.Instance;
|
||||
public static ContentAlign SpaceEvenly => ContentAlignSpaceEvenly.Instance;
|
||||
}
|
||||
|
||||
[MessagePackObject(AllowPrivate = true)]
|
||||
[MessagePackObject]
|
||||
public sealed class ContentAlignAuto : ContentAlign
|
||||
{
|
||||
internal static readonly ContentAlignAuto Instance = new ContentAlignAuto();
|
||||
|
||||
[SerializationConstructor] private ContentAlignAuto() { }
|
||||
public ContentAlignAuto() { }
|
||||
}
|
||||
|
||||
[MessagePackObject(AllowPrivate = true)]
|
||||
[MessagePackObject]
|
||||
public sealed class ContentAlignStart : ContentAlign
|
||||
{
|
||||
internal static readonly ContentAlignStart Instance = new ContentAlignStart();
|
||||
|
||||
[SerializationConstructor] private ContentAlignStart() { }
|
||||
public ContentAlignStart() { }
|
||||
}
|
||||
|
||||
[MessagePackObject(AllowPrivate = true)]
|
||||
[MessagePackObject]
|
||||
public sealed class ContentAlignEnd : ContentAlign
|
||||
{
|
||||
internal static readonly ContentAlignEnd Instance = new ContentAlignEnd();
|
||||
|
||||
[SerializationConstructor] private ContentAlignEnd() { }
|
||||
public ContentAlignEnd() { }
|
||||
}
|
||||
|
||||
[MessagePackObject(AllowPrivate = true)]
|
||||
[MessagePackObject]
|
||||
public sealed class ContentAlignCenter : ContentAlign
|
||||
{
|
||||
internal static readonly ContentAlignCenter Instance = new ContentAlignCenter();
|
||||
|
||||
[SerializationConstructor] private ContentAlignCenter() { }
|
||||
public ContentAlignCenter() { }
|
||||
}
|
||||
|
||||
[MessagePackObject(AllowPrivate = true)]
|
||||
[MessagePackObject]
|
||||
public sealed class ContentAlignStretch : ContentAlign
|
||||
{
|
||||
internal static readonly ContentAlignStretch Instance = new ContentAlignStretch();
|
||||
|
||||
[SerializationConstructor] private ContentAlignStretch() { }
|
||||
public ContentAlignStretch() { }
|
||||
}
|
||||
|
||||
[MessagePackObject(AllowPrivate = true)]
|
||||
[MessagePackObject]
|
||||
public sealed class ContentAlignSpaceBetween : ContentAlign
|
||||
{
|
||||
internal static readonly ContentAlignSpaceBetween Instance = new ContentAlignSpaceBetween();
|
||||
|
||||
[SerializationConstructor] private ContentAlignSpaceBetween() { }
|
||||
public ContentAlignSpaceBetween() { }
|
||||
}
|
||||
|
||||
[MessagePackObject(AllowPrivate = true)]
|
||||
[MessagePackObject]
|
||||
public sealed class ContentAlignSpaceAround : ContentAlign
|
||||
{
|
||||
internal static readonly ContentAlignSpaceAround Instance = new ContentAlignSpaceAround();
|
||||
|
||||
[SerializationConstructor] private ContentAlignSpaceAround() { }
|
||||
public ContentAlignSpaceAround() { }
|
||||
}
|
||||
|
||||
[MessagePackObject(AllowPrivate = true)]
|
||||
[MessagePackObject]
|
||||
public sealed class ContentAlignSpaceEvenly : ContentAlign
|
||||
{
|
||||
internal static readonly ContentAlignSpaceEvenly Instance = new ContentAlignSpaceEvenly();
|
||||
|
||||
[SerializationConstructor] private ContentAlignSpaceEvenly() { }
|
||||
public ContentAlignSpaceEvenly() { }
|
||||
}
|
||||
|
||||
[Union(0, typeof(ThemeToken))]
|
||||
|
|
@ -435,69 +342,48 @@ public sealed class Rgba : ColorRef
|
|||
public abstract class Role
|
||||
{
|
||||
internal Role() { }
|
||||
public static Role Group => RoleGroup.Instance;
|
||||
public static Role Region => RoleRegion.Instance;
|
||||
public static Role List => RoleList.Instance;
|
||||
public static Role ListItem => RoleListItem.Instance;
|
||||
public static Role Heading => RoleHeading.Instance;
|
||||
public static Role Dialog => RoleDialog.Instance;
|
||||
public static Role Toolbar => RoleToolbar.Instance;
|
||||
}
|
||||
|
||||
[MessagePackObject(AllowPrivate = true)]
|
||||
[MessagePackObject]
|
||||
public sealed class RoleGroup : Role
|
||||
{
|
||||
internal static readonly RoleGroup Instance = new RoleGroup();
|
||||
|
||||
[SerializationConstructor] private RoleGroup() { }
|
||||
public RoleGroup() { }
|
||||
}
|
||||
|
||||
[MessagePackObject(AllowPrivate = true)]
|
||||
[MessagePackObject]
|
||||
public sealed class RoleRegion : Role
|
||||
{
|
||||
internal static readonly RoleRegion Instance = new RoleRegion();
|
||||
|
||||
[SerializationConstructor] private RoleRegion() { }
|
||||
public RoleRegion() { }
|
||||
}
|
||||
|
||||
[MessagePackObject(AllowPrivate = true)]
|
||||
[MessagePackObject]
|
||||
public sealed class RoleList : Role
|
||||
{
|
||||
internal static readonly RoleList Instance = new RoleList();
|
||||
|
||||
[SerializationConstructor] private RoleList() { }
|
||||
public RoleList() { }
|
||||
}
|
||||
|
||||
[MessagePackObject(AllowPrivate = true)]
|
||||
[MessagePackObject]
|
||||
public sealed class RoleListItem : Role
|
||||
{
|
||||
internal static readonly RoleListItem Instance = new RoleListItem();
|
||||
|
||||
[SerializationConstructor] private RoleListItem() { }
|
||||
public RoleListItem() { }
|
||||
}
|
||||
|
||||
[MessagePackObject(AllowPrivate = true)]
|
||||
[MessagePackObject]
|
||||
public sealed class RoleHeading : Role
|
||||
{
|
||||
internal static readonly RoleHeading Instance = new RoleHeading();
|
||||
|
||||
[SerializationConstructor] private RoleHeading() { }
|
||||
public RoleHeading() { }
|
||||
}
|
||||
|
||||
[MessagePackObject(AllowPrivate = true)]
|
||||
[MessagePackObject]
|
||||
public sealed class RoleDialog : Role
|
||||
{
|
||||
internal static readonly RoleDialog Instance = new RoleDialog();
|
||||
|
||||
[SerializationConstructor] private RoleDialog() { }
|
||||
public RoleDialog() { }
|
||||
}
|
||||
|
||||
[MessagePackObject(AllowPrivate = true)]
|
||||
[MessagePackObject]
|
||||
public sealed class RoleToolbar : Role
|
||||
{
|
||||
internal static readonly RoleToolbar Instance = new RoleToolbar();
|
||||
|
||||
[SerializationConstructor] private RoleToolbar() { }
|
||||
public RoleToolbar() { }
|
||||
}
|
||||
|
||||
[MessagePackObject]
|
||||
|
|
|
|||
|
|
@ -29,7 +29,7 @@ internal static class Builders
|
|||
public static BindParts RecordBind(MemberPath member, Format? format) =>
|
||||
new(new StateRef("provider.a", "gamecult.thing.test.v1", "row-1"), member, format);
|
||||
|
||||
public static BindParts ItemBind(MemberPath member) => new(StateSource.Item, member, null);
|
||||
public static BindParts ItemBind(MemberPath member) => new(new StateSourceItem(), member, null);
|
||||
|
||||
public static CommandRef Command(string id) => new CommandIdRef(id);
|
||||
|
||||
|
|
@ -55,32 +55,32 @@ internal static class Builders
|
|||
List<Dimension>? gridColumns = null,
|
||||
List<Dimension>? gridRows = null) =>
|
||||
new(
|
||||
display ?? Display.Flex,
|
||||
direction ?? Direction.Column,
|
||||
wrap ?? Wrap.NoWrap,
|
||||
display ?? new DisplayFlex(),
|
||||
direction ?? new DirectionColumn(),
|
||||
wrap ?? new WrapNoWrap(),
|
||||
Size(Px(4), Px(8)),
|
||||
AllEdges(Px(2)),
|
||||
AllEdges(Dimension.Auto),
|
||||
Size(new DimensionPercent(100), Dimension.Content),
|
||||
AllEdges(new DimensionAuto()),
|
||||
Size(new DimensionPercent(100), new DimensionContent()),
|
||||
Size(Px(0), Px(0)),
|
||||
Size(Dimension.Auto, Dimension.Auto),
|
||||
position ?? Position.Relative,
|
||||
AllEdges(Dimension.Auto),
|
||||
overflow ?? Overflow.Visible,
|
||||
alignItems ?? ItemAlign.Stretch,
|
||||
alignSelf ?? ItemAlign.Auto,
|
||||
alignContent ?? ContentAlign.Start,
|
||||
justifyContent ?? ContentAlign.SpaceBetween,
|
||||
Size(new DimensionAuto(), new DimensionAuto()),
|
||||
position ?? new PositionRelative(),
|
||||
AllEdges(new DimensionAuto()),
|
||||
overflow ?? new OverflowVisible(),
|
||||
alignItems ?? new ItemAlignStretch(),
|
||||
alignSelf ?? new ItemAlignAuto(),
|
||||
alignContent ?? new ContentAlignStart(),
|
||||
justifyContent ?? new ContentAlignSpaceBetween(),
|
||||
1.0,
|
||||
0.0,
|
||||
basis ?? Dimension.Auto,
|
||||
basis ?? new DimensionAuto(),
|
||||
gridColumns ?? new List<Dimension>(),
|
||||
gridRows ?? new List<Dimension>());
|
||||
|
||||
public static Paint PlainPaint() => new(null, null, 0.0);
|
||||
|
||||
public static Node Boxed(string id, params Node[] children) =>
|
||||
new BoxNode(Common(id), Style(), PlainPaint(), Role.Group, children.ToList());
|
||||
new BoxNode(Common(id), Style(), PlainPaint(), new RoleGroup(), children.ToList());
|
||||
|
||||
public static Node Text(string id, string content) =>
|
||||
new TextNode(Common(id), LitText(content), "body", true, null, false);
|
||||
|
|
@ -115,8 +115,8 @@ internal static class Builders
|
|||
return new List<BindParts>
|
||||
{
|
||||
RecordBind(indexed, number),
|
||||
RecordBind(Names("elapsed"), Format.Duration),
|
||||
RecordBind(Names("at"), Format.Timestamp),
|
||||
RecordBind(Names("elapsed"), new FormatDuration()),
|
||||
RecordBind(Names("at"), new FormatTimestamp()),
|
||||
RecordBind(Names("price"), affix),
|
||||
RecordBind(Names("plain"), null),
|
||||
ItemBind(Names("name")),
|
||||
|
|
@ -133,19 +133,19 @@ internal static class Builders
|
|||
var painted = new BoxNode(
|
||||
new NodeCommon("painted", new BoolSourceParam("show"), new TextSourceParam("label")),
|
||||
Style(
|
||||
display: Display.Grid,
|
||||
direction: Direction.RowReverse,
|
||||
wrap: Wrap.WrapReverse,
|
||||
position: Position.Absolute,
|
||||
overflow: Overflow.Scroll,
|
||||
alignItems: ItemAlign.Baseline,
|
||||
alignSelf: ItemAlign.Center,
|
||||
alignContent: ContentAlign.SpaceAround,
|
||||
justifyContent: ContentAlign.SpaceEvenly,
|
||||
display: new DisplayGrid(),
|
||||
direction: new DirectionRowReverse(),
|
||||
wrap: new WrapWrapReverse(),
|
||||
position: new PositionAbsolute(),
|
||||
overflow: new OverflowScroll(),
|
||||
alignItems: new ItemAlignBaseline(),
|
||||
alignSelf: new ItemAlignCenter(),
|
||||
alignContent: new ContentAlignSpaceAround(),
|
||||
justifyContent: new ContentAlignSpaceEvenly(),
|
||||
gridColumns: new List<Dimension> { new DimensionFr(1), Px(120) },
|
||||
gridRows: new List<Dimension> { Dimension.Content }),
|
||||
gridRows: new List<Dimension> { new DimensionContent() }),
|
||||
new Paint(new ThemeToken("surface.raised"), new Border(new Rgba(1, 2, 3, 255), 1.5), 4.0),
|
||||
Role.Region,
|
||||
new RoleRegion(),
|
||||
new List<Node> { Text("deep-text", "deep") });
|
||||
|
||||
var repeat = new RepeatNode(
|
||||
|
|
@ -157,12 +157,12 @@ internal static class Builders
|
|||
var leaves = new List<Node>
|
||||
{
|
||||
new TextNode(Common("t-bound"), boundText, "label", true, null, false),
|
||||
new ImageNode(Common("img"), "icons", "gear", ImageFit.Cover, LitText("a gear")),
|
||||
new ImageNode(Common("img"), "icons", "gear", new ImageFitCover(), LitText("a gear")),
|
||||
new ButtonNode(Common("go"), new List<Node> { Text("go-label", "Go") }, Command("go"), boundBool),
|
||||
new ToggleNode(Common("flag"), boundBool, new CommandRefParam("toggle")),
|
||||
new SliderNode(Common("level"), 0.0, 1.0, 0.25, boundNumber, Command("set-level")),
|
||||
new TextInputNode(Common("name-input"), true, InputKind.Number, LitText("name"), new TextSourceParam("initial"), Command("rename")),
|
||||
new TextInputNode(Common("title-input"), false, InputKind.Text, LitText("title"), new TextSourceParam("initial"), Command("retitle")),
|
||||
new TextInputNode(Common("name-input"), true, new InputKindNumber(), LitText("name"), new TextSourceParam("initial"), Command("rename")),
|
||||
new TextInputNode(Common("title-input"), false, new InputKindText(), LitText("title"), new TextSourceParam("initial"), Command("retitle")),
|
||||
new SelectNode(
|
||||
Common("pick"),
|
||||
new LiteralOptions(new List<SelectOption> { new("a", "Alpha") }),
|
||||
|
|
@ -175,8 +175,8 @@ internal static class Builders
|
|||
Command("pick")),
|
||||
repeat,
|
||||
new OverlayNode(Common("menu"), new AnchorNode("go"), false, Command("close"), new List<Node> { Text("menu-item", "one") }),
|
||||
new OverlayNode(Common("dialog"), Anchor.Viewport, true, Command("close"), new List<Node>()),
|
||||
new PlotNode(Common("trend"), binds[1].ToBind(), PlotMark.Area, 0.0, null, null, 100.0),
|
||||
new OverlayNode(Common("dialog"), new AnchorViewport(), true, Command("close"), new List<Node>()),
|
||||
new PlotNode(Common("trend"), binds[1].ToBind(), new PlotMarkArea(), 0.0, null, null, 100.0),
|
||||
new EmbedNode(Common("viewport"), "world.scene", "main", 640.0, 480.0),
|
||||
new UseNode(
|
||||
Common("kv"),
|
||||
|
|
@ -188,16 +188,16 @@ internal static class Builders
|
|||
foreach (var id in new[] { "d3", "d2", "d1" }) deep = Boxed(id, deep);
|
||||
var children = new List<Node> { deep };
|
||||
children.AddRange(leaves);
|
||||
children.Add(new PlotNode(Common("trend-line"), binds[2].ToBind(), PlotMark.Line, null, null, null, null));
|
||||
children.Add(new PlotNode(Common("trend-bar"), binds[2].ToBind(), PlotMark.Bar, null, null, null, null));
|
||||
var fits = new[] { ImageFit.Contain, ImageFit.Fill, ImageFit.Unscaled };
|
||||
children.Add(new PlotNode(Common("trend-line"), binds[2].ToBind(), new PlotMarkLine(), null, null, null, null));
|
||||
children.Add(new PlotNode(Common("trend-bar"), binds[2].ToBind(), new PlotMarkBar(), null, null, null, null));
|
||||
var fits = new[] { new ImageFitContain(), new ImageFitFill(), new ImageFitUnscaled() };
|
||||
for (var index = 0; index < fits.Length; index++)
|
||||
children.Add(new ImageNode(Common($"img-fit-{index}"), "icons", "gear", fits[index], LitText("")));
|
||||
var roles = new[] { Role.List, Role.ListItem, Role.Heading, Role.Dialog, Role.Toolbar };
|
||||
var roles = new[] { new RoleList(), new RoleListItem(), new RoleHeading(), new RoleDialog(), new RoleToolbar() };
|
||||
for (var index = 0; index < roles.Length; index++)
|
||||
{
|
||||
var roleStyle = index == 0
|
||||
? Style(direction: Direction.Row, alignContent: ContentAlign.Auto, justifyContent: ContentAlign.Stretch)
|
||||
? Style(direction: new DirectionRow(), alignContent: new ContentAlignAuto(), justifyContent: new ContentAlignStretch())
|
||||
: Style();
|
||||
children.Add(new BoxNode(Common($"role-{index}"), roleStyle, PlainPaint(), roles[index], new List<Node>()));
|
||||
}
|
||||
|
|
@ -205,17 +205,17 @@ internal static class Builders
|
|||
children.Add(new BoxNode(
|
||||
Common("block"),
|
||||
Style(
|
||||
display: Display.Block,
|
||||
direction: Direction.ColumnReverse,
|
||||
wrap: Wrap.Wrapped,
|
||||
overflow: Overflow.Clip,
|
||||
alignContent: ContentAlign.Center,
|
||||
justifyContent: ContentAlign.End,
|
||||
alignItems: ItemAlign.End,
|
||||
alignSelf: ItemAlign.Start,
|
||||
basis: Dimension.Content),
|
||||
display: new DisplayBlock(),
|
||||
direction: new DirectionColumnReverse(),
|
||||
wrap: new WrapWrap(),
|
||||
overflow: new OverflowClip(),
|
||||
alignContent: new ContentAlignCenter(),
|
||||
justifyContent: new ContentAlignEnd(),
|
||||
alignItems: new ItemAlignEnd(),
|
||||
alignSelf: new ItemAlignStart(),
|
||||
basis: new DimensionContent()),
|
||||
PlainPaint(),
|
||||
Role.Group,
|
||||
new RoleGroup(),
|
||||
new List<Node>()));
|
||||
children.Add(new TextNode(Common("t-param"), new TextSourceParam("title"), "title", true, null, false));
|
||||
children.Add(new ToggleNode(new NodeCommon("literal-number", new BoolSourceParam("v"), null), LitBool(false), Command("toggle")));
|
||||
|
|
@ -255,13 +255,13 @@ internal static class Builders
|
|||
3,
|
||||
new List<ParamDecl>
|
||||
{
|
||||
new("title", ParamKind.Text),
|
||||
new("count", ParamKind.Number),
|
||||
new("on", ParamKind.Bool),
|
||||
new("source", ParamKind.Bind),
|
||||
new("rows", ParamKind.Collection),
|
||||
new("act", ParamKind.Command),
|
||||
new("body", ParamKind.Slot),
|
||||
new("title", new ParamKindText()),
|
||||
new("count", new ParamKindNumber()),
|
||||
new("on", new ParamKindBool()),
|
||||
new("source", new ParamKindBind()),
|
||||
new("rows", new ParamKindCollection()),
|
||||
new("act", new ParamKindCommand()),
|
||||
new("body", new ParamKindSlot()),
|
||||
},
|
||||
Boxed("panel-root", Text("panel-title", "t"), innerUse));
|
||||
}
|
||||
|
|
|
|||
|
|
@ -139,16 +139,4 @@ public sealed class FactoriesOnlyTests
|
|||
var failed = (FailedOutcome)CommandResult.Failed(invocation, 1, "broke").Outcome;
|
||||
Assert.That(failed.Reason, Is.EqualTo("broke"));
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void UnitArmsAreSharedInstancesAndWriteAnEmptySlotArray()
|
||||
{
|
||||
Assert.That(ImageFit.Contain, Is.SameAs(ImageFit.Contain));
|
||||
Assert.That(ImageFit.Contain, Is.Not.SameAs(ImageFit.Cover));
|
||||
// [key, []]: array(2), the key, array(0).
|
||||
Assert.That(MessagePackSerializer.Serialize<ImageFit>(ImageFit.Fill, Wire.Options), Is.EqualTo(new byte[] { 0x92, 0x02, 0x90 }));
|
||||
Assert.That(MessagePackSerializer.Serialize<InputKind>(InputKind.Number, Wire.Options), Is.EqualTo(new byte[] { 0x92, 0x01, 0x90 }));
|
||||
var read = MessagePackSerializer.Deserialize<ImageFit>(new byte[] { 0x92, 0x03, 0x90 }, Wire.Options);
|
||||
Assert.That(read, Is.TypeOf(ImageFit.Unscaled.GetType()));
|
||||
}
|
||||
}
|
||||
|
|
|
|||
64
tests/GameCult.Thing.Contract.Tests/UnitArmTests.cs
Normal file
64
tests/GameCult.Thing.Contract.Tests/UnitArmTests.cs
Normal file
|
|
@ -0,0 +1,64 @@
|
|||
using System.Reflection;
|
||||
using MessagePack;
|
||||
|
||||
namespace GameCult.Thing.Contract.Tests;
|
||||
|
||||
/// <summary>
|
||||
/// A unit arm is its arm type: there is one way to build it (<c>new ImageFitFill()</c>) and one way to tell it (a type
|
||||
/// test). No union base exposes a static instance, so no code can compare by reference and see a decoded arm differ.
|
||||
/// </summary>
|
||||
public sealed class UnitArmTests
|
||||
{
|
||||
private static IEnumerable<Type> Unions() =>
|
||||
typeof(CommandResult).Assembly.GetExportedTypes().Where(t => t.IsAbstract && t.GetCustomAttributes<UnionAttribute>(false).Any());
|
||||
|
||||
private static IEnumerable<(Type Union, UnionAttribute Arm)> UnitArms() =>
|
||||
Unions().SelectMany(u => u.GetCustomAttributes<UnionAttribute>(false).Select(a => (u, a)))
|
||||
.Where(x => x.a.SubType.GetConstructor(Type.EmptyTypes) != null);
|
||||
|
||||
[Test]
|
||||
public void EveryDecodedUnitArmIsItsArmType()
|
||||
{
|
||||
var arms = UnitArms().ToList();
|
||||
Assert.That(arms, Has.Count.EqualTo(58));
|
||||
foreach (var (union, arm) in arms)
|
||||
{
|
||||
var bytes = new byte[] { 0x92, (byte)arm.Key, 0x90 };
|
||||
var read = MessagePackSerializer.Deserialize(union, bytes, Wire.Options);
|
||||
Assert.That(read, Is.TypeOf(arm.SubType), $"{union.Name} key {arm.Key}");
|
||||
Assert.That(MessagePackSerializer.Serialize(union, read, Wire.Options), Is.EqualTo(bytes), $"{union.Name} key {arm.Key}");
|
||||
}
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void NoUnionBaseExposesAStaticMemberOfItsOwnKind()
|
||||
{
|
||||
var offenders = new List<string>();
|
||||
var unions = Unions().ToList();
|
||||
Assert.That(unions, Has.Count.GreaterThan(25));
|
||||
foreach (var union in unions)
|
||||
{
|
||||
foreach (var member in union.GetMembers(BindingFlags.Public | BindingFlags.Static | BindingFlags.DeclaredOnly))
|
||||
{
|
||||
var type = member switch
|
||||
{
|
||||
PropertyInfo p => p.PropertyType,
|
||||
FieldInfo f => f.FieldType,
|
||||
MethodInfo m => m.ReturnType,
|
||||
_ => null,
|
||||
};
|
||||
if (type != null && type.IsAssignableTo(union)) offenders.Add($"{union.Name}.{member.Name}");
|
||||
}
|
||||
}
|
||||
|
||||
Assert.That(offenders, Is.Empty);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void ConstructingAUnitArmWritesAnEmptySlotArray()
|
||||
{
|
||||
// [key, []]: array(2), the key, array(0).
|
||||
Assert.That(MessagePackSerializer.Serialize<ImageFit>(new ImageFitFill(), Wire.Options), Is.EqualTo(new byte[] { 0x92, 0x02, 0x90 }));
|
||||
Assert.That(MessagePackSerializer.Serialize<InputKind>(new InputKindNumber(), Wire.Options), Is.EqualTo(new byte[] { 0x92, 0x01, 0x90 }));
|
||||
}
|
||||
}
|
||||
Loading…
Reference in a new issue