review(Driver.AbCip): fix declared UDT array members read as scalar (Medium)
Re-review at 7286d320. AbCip-016 (Medium): two cooperating defects made a declared array
member (e.g. REAL[4]) read one scalar/null — fan-out dropped ElementCount/IsArray, and
UdtMemberLayout.TryBuild ignored array members (mis-placing later members). Fix: thread
array shape through fan-out + opt whole-UDT grouping out when any member is an array + TDD.
AbCip-017 (severity-read StatusCode, Low) deferred.
This commit is contained in:
@@ -74,4 +74,29 @@ public sealed class AbCipUdtMemberLayoutTests
|
||||
{
|
||||
AbCipUdtMemberLayout.TryBuild(Array.Empty<AbCipStructureMember>()).ShouldBeNull();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Driver.AbCip-016 — declaration-only layout returns null when any member is a 1-D array.
|
||||
/// The whole-UDT grouped read path decodes one scalar per member at its offset
|
||||
/// (<c>DecodeValueAt</c>) and cannot return an array, and the scalar-size cursor advance
|
||||
/// would mis-place every member after the array. Opting the whole group out sends array
|
||||
/// members through the per-tag read path, which reads them as typed arrays.
|
||||
/// </summary>
|
||||
[Fact]
|
||||
public void Returns_Null_When_A_Member_Is_An_Array()
|
||||
{
|
||||
// Explicit IsArray flag (even a 1-element array).
|
||||
AbCipUdtMemberLayout.TryBuild(new[]
|
||||
{
|
||||
new AbCipStructureMember("A", AbCipDataType.DInt),
|
||||
new AbCipStructureMember("Buf", AbCipDataType.Real, IsArray: true, ElementCount: 1),
|
||||
}).ShouldBeNull();
|
||||
|
||||
// Legacy ElementCount > 1 with the flag unset.
|
||||
AbCipUdtMemberLayout.TryBuild(new[]
|
||||
{
|
||||
new AbCipStructureMember("A", AbCipDataType.DInt),
|
||||
new AbCipStructureMember("Setpoints", AbCipDataType.Real, ElementCount: 4),
|
||||
}).ShouldBeNull();
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user