Skip to content

ArgumentException and invalid ObjectTypes/ObjectTypeIds constant definitions when compiling specific ObjectType hierarchy #220

@berndbr

Description

@berndbr

When using the docker container version 2.6.0 compiling the NodeSet2 XML contained in (ObjectTypeCompileTest.zip) results in this ArgumentException:

[ArgumentException] Invalid name character in 'OT_CustomType_Types/ObjectTypes/BaseObjectType/OT_BaseObjectType/OT_SubType_2/OT_CustomType'. The '/' character, hexadecimal value 0x2F, cannot be included in a name.'. The '/' character, hexadecimal value 0x2F, cannot be included in a name.

========================
   at System.Xml.XmlWellFormedWriter.CheckNCName(String ncname)
   at System.Xml.XmlWellFormedWriter.WriteStartElement(String prefix, String localName, String ns)
   at Opc.Ua.XmlEncoder.Push(String fieldName, String namespaceUri)
   at Opc.Ua.NodeState.SaveAsXml(ISystemContext context, XmlEncoder encoder)
   at Opc.Ua.NodeStateCollection.SaveAsXml(ISystemContext context, Stream ostrm, Boolean keepStreamOpen)
   at Opc.Ua.NodeStateCollection.SaveAsXml(ISystemContext context, Stream ostrm)
   at ModelCompiler.ModelGenerator2.WriteTemplate_XmlExport(String filePath) in /source/Opc.Ua.ModelCompiler/ModelGenerator2.cs:line 664
   at ModelCompiler.ModelGenerator2.GenerateMultipleFiles(String filePath, Boolean useXmlInitializers, IList`1 excludedCategories, Boolean includeDisplayNames) in /source/Opc.Ua.ModelCompiler/ModelGenerator2.cs:line 158
   at ModelCompiler.ModelCompilerApplication.<>c__DisplayClass13_0.<Compile>b__0() in /source/Opc.Ua.ModelCompiler/ModelCompilerApplication.cs:line 558
   at McMaster.Extensions.CommandLineUtils.CommandLineApplication.<>c__DisplayClass143_0.<OnExecute>b__0(CancellationToken _)
   at McMaster.Extensions.CommandLineUtils.CommandLineApplication.ExecuteAsync(String[] args, CancellationToken cancellationToken)
   at McMaster.Extensions.CommandLineUtils.CommandLineApplication.Execute(String[] args)
   at ModelCompiler.ModelCompilerApplication.Run(String[] args) in /source/Opc.Ua.ModelCompiler/ModelCompilerApplication.cs:line 31
   at Program.<Main>$(String[] args) in /source/Opc.Ua.ModelCompiler/Program.cs:line 43
========================

Used commandline:
docker run --rm -v "$(pwd)":/data ghcr.io/opcfoundation/ua-modelcompiler:2.6.0 compile -d2 /data/ObjectTypeCompileTest.xml,CompileTest -version v105 -exclude Draft -o2 /data/_generated

In addition the generated CompileTest.Constants.cs contains invalid definitions of the ObjectType identifier and the ObjectTypeIds NodeId:

public const string OT_CustomType_Types/ObjectTypes/BaseObjectType/OT_BaseObjectType/OT_SubType_2/OT_CustomType = "Types/ObjectTypes/BaseObjectType/OT_BaseObjectType/OT_SubType_2/OT_CustomType";

public static readonly ExpandedNodeId OT_CustomType_Types/ObjectTypes/BaseObjectType/OT_BaseObjectType/OT_SubType_2/OT_CustomType = new ExpandedNodeId(CompileTest.ObjectTypes.OT_CustomType_Types/ObjectTypes/BaseObjectType/OT_BaseObjectType/OT_SubType_2/OT_CustomType, CompileTest.Namespaces.testcommodelcompiler);

For me it looks like that compiling NodeSets that contains object types defined with the same name (BrowseName) result in that errors.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions