From a366deaeec526b3421873b2d16fc5e36369c8fe0 Mon Sep 17 00:00:00 2001 From: Randy Armstrong Date: Thu, 18 Jan 2024 18:29:47 -0800 Subject: [PATCH] Fix code generation when not an UA URL. --- .../Design.v105/DemoModel.xml | 35 ++++++++++++++++--- Opc.Ua.ModelCompiler/NodeSetToModelDesign.cs | 5 +-- .../DataTypes/ConstantsGenerator.cs | 2 +- 3 files changed, 35 insertions(+), 7 deletions(-) diff --git a/Opc.Ua.ModelCompiler/Design.v105/DemoModel.xml b/Opc.Ua.ModelCompiler/Design.v105/DemoModel.xml index 4280c82..63c5907 100644 --- a/Opc.Ua.ModelCompiler/Design.v105/DemoModel.xml +++ b/Opc.Ua.ModelCompiler/Design.v105/DemoModel.xml @@ -6,14 +6,14 @@ xmlns:di="http://opcfoundation.org/UA/DI/" xmlns:opc="http://opcfoundation.org/UA/ModelDesign.xsd" xmlns:xsd="http://www.w3.org/2001/XMLSchema" - xmlns="http://www.opcfoundation.org/DemoModel/" - TargetNamespace="http://www.opcfoundation.org/DemoModel/" - TargetXmlNamespace="http://www.opcfoundation.org/DemoModel/" + xmlns="tag:opc-foundation.org,2024-01:DemoModel" + TargetNamespace="tag:opc-foundation.org,2024-01:DemoModel" + TargetXmlNamespace="tag:opc-foundation.org,2024-01:DemoModel" TargetVersion="1.05.03" TargetPublicationDate="2023-12-15T00:00:00Z"> - http://www.opcfoundation.org/DemoModel/ + tag:opc-foundation.org,2024-01:DemoModel http://opcfoundation.org/UA/ http://opcfoundation.org/UA/DI/ @@ -53,7 +53,21 @@ ua:Server_ServerCapabilities_RoleSet + + + Wicked + + + + + + + + + + + @@ -77,6 +91,14 @@ SessionWithSigningAndApplyToBrowseRequired + + + This way + + + comes + + @@ -109,6 +131,11 @@ + + + This way + + diff --git a/Opc.Ua.ModelCompiler/NodeSetToModelDesign.cs b/Opc.Ua.ModelCompiler/NodeSetToModelDesign.cs index 347c9e4..bf92c08 100644 --- a/Opc.Ua.ModelCompiler/NodeSetToModelDesign.cs +++ b/Opc.Ua.ModelCompiler/NodeSetToModelDesign.cs @@ -179,6 +179,7 @@ private static void CollectModels(ModelTableEntry model, List m private static Namespace CreateNamespace(ModelTableEntry model) { Namespace ns = null; + if (model.ModelUri.StartsWith(Namespaces.OpcUa)) { ns = new Namespace() @@ -190,7 +191,7 @@ private static Namespace CreateNamespace(ModelTableEntry model) Version = model.Version }; ns.XmlPrefix = ns.Prefix = "Opc.Ua." + ns.Name; - ns.Name = ns.Name.Replace(".", ""); + ns.Name = ns.Name.Replace(".", "").Replace("-", "").Replace(",", "").Replace(":", ""); } else { @@ -203,7 +204,7 @@ private static Namespace CreateNamespace(ModelTableEntry model) Version = model.Version }; ns.XmlPrefix = ns.Prefix = ns.Name; - ns.Name = ns.Name.Replace(".", ""); + ns.Name = ns.Name.Replace(".", "").Replace("-", "").Replace(",", "").Replace(":", ""); } if (ns.Value == Namespaces.OpcUa) diff --git a/Opc.Ua.ModelCompiler/StackGenerator/DataTypes/ConstantsGenerator.cs b/Opc.Ua.ModelCompiler/StackGenerator/DataTypes/ConstantsGenerator.cs index 6025e84..7d6f557 100644 --- a/Opc.Ua.ModelCompiler/StackGenerator/DataTypes/ConstantsGenerator.cs +++ b/Opc.Ua.ModelCompiler/StackGenerator/DataTypes/ConstantsGenerator.cs @@ -181,7 +181,7 @@ private void WriteTemplate_Constants(string namespacePrefix, string className, L case Language.TypeScript: { - fileName = String.Format(@"{0}\{1}-{2}.ts", OutputDirectory, namespacePrefix.ToLower().Replace(".", ""), className.ToLower()); + fileName = String.Format(@"{0}\{1}-{2}.ts", OutputDirectory, namespacePrefix.ToLower().Replace(".", "").Replace("-", "").Replace(",", "").Replace(":", ""), className.ToLower()); m_templateSuffix = ".ts"; break; }