From decb523b3ba850ec8a40c3b23daa09b4dc2ecb56 Mon Sep 17 00:00:00 2001 From: Waldemar Porscha Date: Tue, 6 Apr 2021 20:55:41 +0200 Subject: [PATCH] no runtime error if comobject number is a string --- AssemblyInfo.cs | 6 +++--- Program.cs | 15 ++++++++++----- 2 files changed, 13 insertions(+), 8 deletions(-) diff --git a/AssemblyInfo.cs b/AssemblyInfo.cs index bebbf7c..73739d4 100644 --- a/AssemblyInfo.cs +++ b/AssemblyInfo.cs @@ -13,8 +13,8 @@ [assembly: System.Reflection.AssemblyCompanyAttribute("MultiplyChannels")] [assembly: System.Reflection.AssemblyConfigurationAttribute("Debug")] -[assembly: System.Reflection.AssemblyFileVersionAttribute("2.1.0.0")] -[assembly: System.Reflection.AssemblyInformationalVersionAttribute("2.1.0")] +[assembly: System.Reflection.AssemblyFileVersionAttribute("2.1.2.0")] +[assembly: System.Reflection.AssemblyInformationalVersionAttribute("2.1.2")] [assembly: System.Reflection.AssemblyProductAttribute("MultiplyChannels")] [assembly: System.Reflection.AssemblyTitleAttribute("MultiplyChannels")] -[assembly: System.Reflection.AssemblyVersionAttribute("2.1.0.0")] +[assembly: System.Reflection.AssemblyVersionAttribute("2.1.2.0")] diff --git a/Program.cs b/Program.cs index ef33307..aaea7e6 100644 --- a/Program.cs +++ b/Program.cs @@ -96,7 +96,7 @@ static XmlNode GetNodeById(XmlNode iRootNode, string iId) { private static void CreateComment(XmlDocument iTargetNode, XmlNode iNode, string iId, string iSuffix = "") { string lNodeId = iId.Substring(0, iId.LastIndexOf("_R")); string lTextId = iId; - string lNodeName = "Id-mismatch! Nema not found!"; + string lNodeName = "Id-mismatch! Name not found!"; string lText = "Id-mismatch! Text not found!"; if (gIds.ContainsKey(lNodeId)) lNodeName = gIds[lNodeId].NodeAttr("Name"); if (gIds.ContainsKey(lTextId) && gIds[lTextId].NodeAttr("Text") == "") lTextId = lNodeId; @@ -321,11 +321,16 @@ static bool ProcessSanityChecks(XmlDocument iTargetNode) { lNodes = iTargetNode.SelectNodes("//ComObject[@Number]"); Dictionary lKoNumbers = new Dictionary(); foreach (XmlNode lNode in lNodes) { - int lNumber = int.Parse(lNode.Attributes.GetNamedItem("Number").Value); - if (lKoNumbers.ContainsKey(lNumber)) { - WriteFail(ref lFailPart, "{0} is a duplicate Number in ComObject with name {1}", lNumber, lNode.NodeAttr("Name")); + int lNumber = 0; + bool lIsInt = int.TryParse(lNode.Attributes.GetNamedItem("Number").Value, out lNumber); + if (lIsInt) { + if (lKoNumbers.ContainsKey(lNumber)) { + WriteFail(ref lFailPart, "{0} is a duplicate Number in ComObject with name {1}", lNumber, lNode.NodeAttr("Name")); + } else { + lKoNumbers.Add(lNumber, true); + } } else { - lKoNumbers.Add(lNumber, true); + WriteFail(ref lFailPart, "ComObject.Number is not an Integer in ComObject with name {0}", lNode.NodeAttr("Name")); } } if (!lFailPart) Console.WriteLine(" OK");