fix(abcip): isArray:true without a positive arrayLength is scalar (review I-2 consistency)

This commit is contained in:
Joseph Doherty
2026-06-16 22:30:11 -04:00
parent d30fb77e31
commit 5f7a2acd27
2 changed files with 35 additions and 5 deletions
@@ -201,6 +201,34 @@ public sealed class AbCipArrayTests
def.IsArray.ShouldBeFalse();
}
/// <summary>
/// Review finding I-2 — <c>isArray:true</c> with NO <c>arrayLength</c> is a DEGENERATE input
/// that must parse as SCALAR (IsArray false, ElementCount 1), matching every other driver
/// (Modbus, S7, TwinCAT, AbLegacy). The AdminUI validator blocks authoring this combination,
/// but the parser contract must still be consistent cross-driver.
/// </summary>
[Fact]
public void Parser_isArray_true_without_arrayLength_parses_as_scalar()
{
var json = """{"tagPath":"Recipe","dataType":"DInt","isArray":true}""";
AbCipEquipmentTagParser.TryParse(json, out var def).ShouldBeTrue();
def!.IsArray.ShouldBeFalse();
def.ElementCount.ShouldBe(1);
}
/// <summary>
/// Review finding I-2 — <c>isArray:true</c> with an invalid (zero) <c>arrayLength</c> also
/// parses as SCALAR, consistent with the cross-driver rule.
/// </summary>
[Fact]
public void Parser_isArray_true_with_zero_arrayLength_parses_as_scalar()
{
var json = """{"tagPath":"Recipe","dataType":"DInt","isArray":true,"arrayLength":0}""";
AbCipEquipmentTagParser.TryParse(json, out var def).ShouldBeTrue();
def!.IsArray.ShouldBeFalse();
def.ElementCount.ShouldBe(1);
}
/// <summary>
/// Review finding I-1 — a 1-element array (<c>isArray:true, arrayLength:1</c>) is a valid
/// 1-element array, NOT a scalar: the parser sets <see cref="AbCipTagDefinition.IsArray"/>