diff --git a/SemanticData/BuildingErrorsHandling/BuildErrors.partial.cs b/SemanticData/BuildingErrorsHandling/BuildErrors.partial.cs index cd0d5cc1..4ce687fa 100644 --- a/SemanticData/BuildingErrorsHandling/BuildErrors.partial.cs +++ b/SemanticData/BuildingErrorsHandling/BuildErrors.partial.cs @@ -1,83 +1,88 @@ //___________________________________________________________________________________ // -// Copyright (C) 2019, Mariusz Postol LODZ POLAND. +// Copyright (C) 2021, Mariusz Postol LODZ POLAND. // // To be in touch join the community at GITTER: https://gitter.im/mpostol/OPC-UA-OOI //___________________________________________________________________________________ namespace UAOOI.SemanticData.BuildingErrorsHandling { - /// /// Enum Focus /// public enum Focus { - /// /// The reference /// Reference, + /// /// The diagnostic /// Diagnostic, + /// /// The NodeClass /// NodeClass, + /// - /// The XML error + /// The XML error /// XML, + /// /// The non categorized error, e.g. exception during execution. /// NonCategorized, + /// /// The data encoding errors - the syntax is validated against OPC UA XML encoding. /// DataEncoding, + /// /// The data type definition error - eny error that relates to custom DataType definion. /// DataType, + /// /// The naming /// Naming - } + /// - /// Class BuildError - provides building descriptions of building errors. + /// Class BuildError - provides building descriptions of building errors. /// public partial class BuildError { - /// /// Gets the focus. /// /// The focus. public Focus Focus { get; set; } + /// /// Gets or sets the unique identifier of the error. /// /// The identifier. public string Identifier { get; set; } + /// /// Gets or sets the descriptor of the error. /// /// The descriptor. public string Descriptor { get; set; } + /// /// Returns a that represents this instance. /// /// A that represents this instance. public override string ToString() { - return string.Format("Focus:{0}, ErrorID: {1} Info: {2}", Focus, Identifier, Descriptor); + return string.Format("Focus: {0}, Identifier: {1} Description: {2}", Focus, Identifier, Descriptor); } - } - -} +} \ No newline at end of file diff --git a/SemanticData/Tests/USNodeSetValidationUnitTestProject/Helpers/TracedAddressSpaceContext.cs b/SemanticData/Tests/USNodeSetValidationUnitTestProject/Helpers/TracedAddressSpaceContext.cs index dbe931eb..438b4b58 100644 --- a/SemanticData/Tests/USNodeSetValidationUnitTestProject/Helpers/TracedAddressSpaceContext.cs +++ b/SemanticData/Tests/USNodeSetValidationUnitTestProject/Helpers/TracedAddressSpaceContext.cs @@ -7,6 +7,7 @@ using System; using System.Collections.Generic; +using System.Diagnostics; using UAOOI.SemanticData.BuildingErrorsHandling; namespace UAOOI.SemanticData.UANodeSetValidation.Helpers @@ -33,7 +34,7 @@ internal void Clear() private void TraceDiagnostic(TraceMessage msg, List errors, ref int diagnosticCounter) { - Console.WriteLine(msg.ToString()); + Debug.WriteLine(msg.ToString()); if (msg.BuildError.Focus == Focus.Diagnostic) diagnosticCounter++; else diff --git a/SemanticData/Tests/USNodeSetValidationUnitTestProject/SemanticData.UANodeSetValidation.UnitTest.csproj b/SemanticData/Tests/USNodeSetValidationUnitTestProject/SemanticData.UANodeSetValidation.UnitTest.csproj index 04f420d3..942d2faf 100644 --- a/SemanticData/Tests/USNodeSetValidationUnitTestProject/SemanticData.UANodeSetValidation.UnitTest.csproj +++ b/SemanticData/Tests/USNodeSetValidationUnitTestProject/SemanticData.UANodeSetValidation.UnitTest.csproj @@ -80,24 +80,23 @@ - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + True True diff --git a/SemanticData/Tests/USNodeSetValidationUnitTestProject/XMLModelsProblemsToReportUnitTest.cs b/SemanticData/Tests/USNodeSetValidationUnitTestProject/XMLModelsProblemsToReportUnitTest.cs index 935d1d42..e430d732 100644 --- a/SemanticData/Tests/USNodeSetValidationUnitTestProject/XMLModelsProblemsToReportUnitTest.cs +++ b/SemanticData/Tests/USNodeSetValidationUnitTestProject/XMLModelsProblemsToReportUnitTest.cs @@ -7,10 +7,12 @@ using Microsoft.VisualStudio.TestTools.UnitTesting; using System; +using System.Diagnostics; using System.IO; using System.Linq; using UAOOI.SemanticData.BuildingErrorsHandling; using UAOOI.SemanticData.UANodeSetValidation.Helpers; +using UAOOI.SemanticData.UANodeSetValidation.InformationModelFactory; namespace UAOOI.SemanticData.UANodeSetValidation { @@ -57,11 +59,15 @@ public void eoursel510Test() using (TracedAddressSpaceContext traceContext = new TracedAddressSpaceContext()) { IAddressSpaceContext addressSpace = traceContext.CreateAddressSpaceContext(); + InformationModelFactoryBase testingModelFixture = new InformationModelFactoryBase(); + addressSpace.InformationModelFactory = testingModelFixture; Uri model = addressSpace.ImportUANodeSet(_testDataFileInfo); Assert.AreEqual(0, traceContext.TraceList.Count); traceContext.Clear(); addressSpace.ValidateAndExportModel(model); Assert.AreEqual(0, traceContext.TraceList.Count); + Assert.AreEqual(8, testingModelFixture.NumberOfNodes); + Debug.WriteLine($"After removing inherited and instance declaration nodes the recovered information model contains {testingModelFixture.NumberOfNodes}"); } } diff --git a/SemanticData/UANodeSetValidation/AddressSpaceContext.cs b/SemanticData/UANodeSetValidation/AddressSpaceContext.cs index 91a6742a..89d61356 100644 --- a/SemanticData/UANodeSetValidation/AddressSpaceContext.cs +++ b/SemanticData/UANodeSetValidation/AddressSpaceContext.cs @@ -409,12 +409,12 @@ private void ValidateAndExportModel(int nameSpaceIndex) string _msg = null; if (m_TraceEvent.Errors == 0) { - _msg = string.Format("Finishing Validator.ValidateExportModel - the model contains {0} nodes.", _nodes.Count); + _msg = $"Finishing Validator.ValidateExportModel - the model contains {_nodes.Count} nodes and no errors/warnings reported"; m_TraceEvent.TraceEvent(TraceMessage.DiagnosticTraceMessage(_msg)); } else { - _msg = $"Finishing Validator.ValidateExportModel - the model contains {_nodes.Count} nodes and {m_TraceEvent.Errors} errors."; + _msg = $"Finishing Validator.ValidateExportModel - the model contains {_nodes.Count} nodes and {m_TraceEvent.Errors} errors reported."; m_TraceEvent.TraceEvent(TraceMessage.BuildErrorTraceMessage(BuildError.ModelContainsErrors, _msg)); } } diff --git a/SemanticData/UANodeSetValidation/InformationModelFactory/InformationModelFactoryBase.cs b/SemanticData/UANodeSetValidation/InformationModelFactory/InformationModelFactoryBase.cs index ca0949b9..e129592d 100644 --- a/SemanticData/UANodeSetValidation/InformationModelFactory/InformationModelFactoryBase.cs +++ b/SemanticData/UANodeSetValidation/InformationModelFactory/InformationModelFactoryBase.cs @@ -28,6 +28,8 @@ internal class InformationModelFactoryBase : NodesContainer, IModelFactory /// The version of the model defined in the UANodeSet. This is a human readable string and not intended for programmatic comparisons. /// The set of objects that the OPC Unified Architecture server makes available to clients is referred to as its Address Space. The namespace is provided to make the BrowseName unique in the Address Space. public void CreateNamespace(string uri, string publicationDate, string version) { } + + public int NumberOfNodes => this.m_Nodes.Count; } } diff --git a/SemanticData/UANodeSetValidation/InformationModelFactory/NodesContainer.cs b/SemanticData/UANodeSetValidation/InformationModelFactory/NodesContainer.cs index cae7354e..0ecc4299 100644 --- a/SemanticData/UANodeSetValidation/InformationModelFactory/NodesContainer.cs +++ b/SemanticData/UANodeSetValidation/InformationModelFactory/NodesContainer.cs @@ -1,6 +1,6 @@ //___________________________________________________________________________________ // -// Copyright (C) 2019, Mariusz Postol LODZ POLAND. +// Copyright (C) 2021, Mariusz Postol LODZ POLAND. // // To be in touch join the community at GITTER: https://gitter.im/mpostol/OPC-UA-OOI //___________________________________________________________________________________ @@ -50,7 +50,7 @@ internal abstract class NodesContainer : INodeContainer m_Nodes.Add(_df); return (NodeFactory)(INodeFactory)_df; } - protected List m_Nodes = new List(); + protected List m_Nodes = new List(); } -} +} \ No newline at end of file diff --git a/SemanticData/UANodeSetValidation/UANodeContext.cs b/SemanticData/UANodeSetValidation/UANodeContext.cs index ab75f07a..2967a1df 100644 --- a/SemanticData/UANodeSetValidation/UANodeContext.cs +++ b/SemanticData/UANodeSetValidation/UANodeContext.cs @@ -142,6 +142,7 @@ public XmlQualifiedName ExportNodeBrowseName() /// The node container. /// The validator. /// must not be null. + //TODO Add a warning that the AS contains nodes orphaned and inaccessible for browsing starting from the Root node #529 void IUANodeBase.CalculateNodeReferences(INodeFactory nodeFactory, IValidator validator) { if (nodeFactory == null) @@ -182,7 +183,7 @@ void IUANodeBase.CalculateNodeReferences(INodeFactory nodeFactory, IValidator va case ReferenceKindEnum.HasSubtype: break; - case ReferenceKindEnum.HasTypeDefinition: //Recognize problems with P3.7.13 HasTypeDefinition ReferenceType #39 + case ReferenceKindEnum.HasTypeDefinition: //TODO Recognize problems with P3.7.13 HasTypeDefinition ReferenceType #39 IsProperty = _rfx.TargetNode.IsPropertyVariableType; break; } @@ -196,7 +197,10 @@ void IUANodeBase.CalculateNodeReferences(INodeFactory nodeFactory, IValidator va if (!string.IsNullOrEmpty(_rc.TargetNode.BrowseName.Name)) _instanceDeclaration = _derivedChildren.ContainsKey(_rc.TargetNode.BrowseName.Name) ? _derivedChildren[_rc.TargetNode.BrowseName.Name] : null; if (_rc.TargetNode.Equals(_instanceDeclaration)) + { + //_TraceEvent(TraceMessage.DiagnosticTraceMessage($"Removing instance declaration {_rc.TargetNode.ToString()}")); continue; + } _rc.TargetNode.RemoveInheritedValues(_instanceDeclaration); validator.ValidateExportNode(_rc.TargetNode, nodeFactory, _rc); }