Skip to content

Commit 0934225

Browse files
ArrayDimensions only appear if there is a value in the nodeset. (#107)
1 parent 17e0ee1 commit 0934225

File tree

2 files changed

+16
-10
lines changed

2 files changed

+16
-10
lines changed

NodeSetToAML.cs

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2541,11 +2541,14 @@ private void SetArrayDimensions( AttributeSequence attributes, string arrayDimen
25412541
}
25422542
}
25432543

2544-
AddModifyAttribute( attributes,
2545-
"ArrayDimensions",
2546-
Opc.Ua.DataTypeIds.UInt32,
2547-
new Variant( arrayValues.ToArray() ),
2548-
bListOf: true );
2544+
if (arrayValues.Count > 0)
2545+
{
2546+
AddModifyAttribute(attributes,
2547+
"ArrayDimensions",
2548+
Opc.Ua.DataTypeIds.UInt32,
2549+
new Variant(arrayValues.ToArray()),
2550+
bListOf: true);
2551+
}
25492552
}
25502553

25512554
#endregion

SystemTest/TestMultiDimensionalArray.cs

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -33,10 +33,13 @@ public void TestArray( string nodeId, string valueRank, string arrayDimensions,
3333
Assert.AreEqual( valueRank, valueRankAttribute.Value );
3434

3535
AttributeType arrayDimensionsAttribute = objectToTest.Attribute[ "ArrayDimensions" ];
36-
Assert.IsNotNull( arrayDimensionsAttribute, "Unable to find ArrayDimensions" );
37-
if( arrayDimensions.Length == 0 )
36+
if (string.IsNullOrEmpty(arrayDimensions))
3837
{
39-
Assert.IsNull( arrayDimensionsAttribute.Value );
38+
Assert.IsNull(arrayDimensionsAttribute);
39+
}
40+
else
41+
{
42+
Assert.IsNotNull(arrayDimensionsAttribute, "Unable to find ArrayDimensions");
4043
}
4144

4245
AttributeType valueAttribute = objectToTest.Attribute[ "Value" ];
@@ -100,10 +103,10 @@ public void TestMethodClassAttributes()
100103

101104
[TestMethod, Timeout( TestHelper.UnitTestTimeout )]
102105
[DataRow( "2330", "", false, true, DisplayName = "SUC HistoryServerCapabilitiesType should not have ArrayDimensions" )]
103-
[DataRow( "24186", "", true, true, DisplayName = "SUC FailureCode should have empty ArrayDimensions" )]
106+
[DataRow( "24186", "", false, true, DisplayName = "SUC FailureCode should not have ArrayDimensions" )]
104107
[DataRow( "24187", "0,8", true, true, DisplayName = "SUC FailureSystemIdentifier ArrayDimensions" )]
105108
[DataRow( "5013", "", false, false, DisplayName = "Folder should not have ArrayDimensions" )]
106-
[DataRow( "6190", "", true, false, DisplayName = "Scalar Value should not have ArrayDimension elements" )]
109+
[DataRow( "6190", "", false, false, DisplayName = "Scalar Value should not have ArrayDimension elements" )]
107110
[DataRow( "6126", "10", true, false, DisplayName = "Single ArrayDimension element" )]
108111
[DataRow( "6129", "3,3,3", true, false, DisplayName = "Three ArrayDimension elements" )]
109112
[DataRow( "6128", "2,2,2,2,2", true, false, DisplayName = "Five ArrayDimension elements" )]

0 commit comments

Comments
 (0)