From 2e252ef57cfe6729efb564dc65742d4e60fc3423 Mon Sep 17 00:00:00 2001 From: Erich Barnstedt Date: Tue, 9 Jul 2024 22:36:34 +0200 Subject: [PATCH] Fix nullable object access in NodeState.AccessRestrictions. --- .../NodesetModelFactoryOpc.cs | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/CESMII.OpcUa.NodeSetModel.Factory.Opc/NodesetModelFactoryOpc.cs b/CESMII.OpcUa.NodeSetModel.Factory.Opc/NodesetModelFactoryOpc.cs index aa51f2e..3783fe7 100644 --- a/CESMII.OpcUa.NodeSetModel.Factory.Opc/NodesetModelFactoryOpc.cs +++ b/CESMII.OpcUa.NodeSetModel.Factory.Opc/NodesetModelFactoryOpc.cs @@ -94,7 +94,7 @@ public static Task> LoadNodeSetAsync(IOpcUaContext opcContext } } } - + // Ensure references that are implicitly used by the importer get resolved into the OPC model ReferenceTypeModelFactoryOpc.Create(opcContext, opcContext.GetNode(ReferenceTypes.HasSubtype), null, out _); ReferenceTypeModelFactoryOpc.Create(opcContext, opcContext.GetNode(ReferenceTypes.HasModellingRule), null, out _); @@ -789,7 +789,7 @@ public static List GetBaseTypes(IOpcUaContext opcContext, BaseTyp } else if (nodeModel is MethodModel method) { - nodesetModel.Methods.Add(method); + nodesetModel.Methods.Add(method); } else if (nodeModel is ReferenceTypeModel referenceType) { @@ -938,7 +938,7 @@ protected override void Initialize(IOpcUaContext opcContext, NodeState opcNode, InitializeDataTypeInfo(_model, opcContext, variableNode, recursionDepth); if (variableNode.AccessLevelEx != 1) _model.AccessLevel = variableNode.AccessLevelEx; // deprecated if (variableNode.UserAccessLevel != 1) _model.UserAccessLevel = variableNode.UserAccessLevel; - if (variableNode.AccessRestrictions != 0) _model.AccessRestrictions = (ushort)variableNode.AccessRestrictions; + if (variableNode.AccessRestrictions.HasValue && (variableNode.AccessRestrictions != 0)) _model.AccessRestrictions = (ushort)variableNode.AccessRestrictions; if (variableNode.WriteMask != 0) _model.WriteMask = (uint)variableNode.WriteMask; if (variableNode.UserWriteMask != 0) _model.UserWriteMask = (uint)variableNode.UserWriteMask; if (variableNode.MinimumSamplingInterval != 0) @@ -1105,7 +1105,7 @@ private void ProcessMethodArguments(MethodModel methodModel, string browseName, } } } - + //if (argumentVariable.OtherReferencedNodes?.Any() != true && argumentVariable.OtherReferencingNodes?.Any() != true) //{ // var argumentProperty = NodeModelOpcExtensions.GetArgumentProperty(methodModel, browseName, modelArguments, opcContext);