OPCFoundation / UA-ModelCompiler

ModelCompiler converts XML files into C# and ANSI C
MIT License
151 stars 94 forks source link

Generated code for two or more dimensional arrays is wrong #101

Closed elliot-gawthrop closed 1 year ago

elliot-gawthrop commented 2 years ago

When a variable is modelled as 2+ dimensions, the ModelCompiler generates C# code as if it is a scalar value.

When this is run through the ModelCompiler:

<ObjectType SymbolicName="TypeWithTwoDimensionalVariable" BaseType="ua:BaseObjectType">
  <Children>
    <Variable SymbolicName="X" DataType="ua:Int32" ValueRank="OneOrMoreDimensions" ArrayDimensions="0,0" ModellingRule="Optional"/>
  </Children>
</ObjectType>

the type of the generated C# code is BaseDataVariableState<int>. I expected it to be BaseDataVariableState<int[,]>.

The NodeSet2.xml seems to be correct, showing:

<UAVariable NodeId="ns=1;i=422" BrowseName="65535:X" ParentNodeId="ns=1;i=421" DataType="Int32" ValueRank="2" ArrayDimensions="0,0">
  <DisplayName>X</DisplayName>
  <References>
    <Reference ReferenceType="HasTypeDefinition">i=63</Reference>
    <Reference ReferenceType="HasModellingRule">i=80</Reference>
    <Reference ReferenceType="HasComponent" IsForward="false">ns=1;i=421</Reference>
  </References>
</UAVariable>
opcfoundation-org commented 2 years ago

Fixed