Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Incorrect Export of namespace index #689

Closed
PMarinov1994 opened this issue Apr 1, 2019 · 2 comments
Closed

Incorrect Export of namespace index #689

PMarinov1994 opened this issue Apr 1, 2019 · 2 comments

Comments

@PMarinov1994
Copy link

PMarinov1994 commented Apr 1, 2019

When a NodeStateCollection.SaveAsNodeSet2 is called and nodes are written to xml elements, the reference namespace index (i.e. ns=id) is incorrect. In the UaNodeSetHelpers.cs class the function private string Export(Opc.Ua.ExpandedNodeId source, NamespaceTable namespaceUris, StringTable serverUris) checks if the source has a valid NamespaceUri string. If it does it calls private ushort ExportNamespaceUri(string namespaceUri, NamespaceTable namespaceUris) otherwise it will call private ushort ExportNamespaceIndex(ushort namespaceIndex, NamespaceTable namespaceUris). The two functions do the exact same job, only in different ways. When a new namespace needs to be added in the xml list, a correct namespace index needs to be assigned. At the end the ExportNamespaceIndex function returns the newly created array with namespaces's count as the index, which is correct, but the ExportNamespaceUri function returns the count + 1 (return (ushort)(count + 1);). I think that the + 1 should not be there. This result in an incorrect reference to a namespace index that is not present in the list.

@PMarinov1994
Copy link
Author

Also I have notices that when a Opc.Ua.NodeStateCollection with no nodeStates inside (i.e. Items.Count == 0) the exported xml does NOT contain the <NamespaceUris></NamespaceUris> xml node that defines the name of this node set namespace uri. The exported xml is useless without the name of namespace of the collection.

@cristipogacean
Copy link
Contributor

@PMarinov1994, thank you for bringing this up! I can confirm the return (ushort)(count+1) is a bug and will be fixed shortly.
Regarding the second point you brought up - Opc.Ua.NodeStateCollection with no nodeStates - we would like to get a bit more details on the use-case. If there are no nodes in collection, I believe there are no namespaces to be exported as well, therefore nothing to export.

cristipogacean added a commit that referenced this issue Sep 15, 2021
mrsuciu pushed a commit that referenced this issue Sep 16, 2021
* fix bug - nodeset2 export of namespace index #689

* the actual fix for #689
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

4 participants