Files
Wolfgang Colsman 2de64d7d93 Source generator: keep NodeSet2 references to nodes of referenced models (#4796)
# Description

A reference in a NodeSet2 input whose target is a node of another model
was
dropped without a diagnostic when that model is supplied by a referenced
assembly rather than by an AdditionalFiles input. The dependency
metadata
of a referenced assembly carries types only, so the importer could not
resolve an instance such as DI's DeviceSet and skipped every reference
to
it: a device organized by DeviceSet (inverse Organizes) lost that
reference, and so did any non-hierarchical reference to such a node.

When the target of a reference is in another, non-zero namespace and no
loaded design defines it, the importer now creates a stand-in that
carries
only the NodeId the generated AddReference call needs. The stand-in is
not
generated. References whose reference type is unknown are still skipped.

Tests generate a DI-style NodeSet2 whose device is organized by
DeviceSet
against DI supplied as a referenced assembly and as an AdditionalFile,
and
compile the result against the stack.

## Related Issues

None.

## Checklist

- [x] I have signed the
[CLA](https://opcfoundation.org/license/cla/ContributorLicenseAgreementv1.0.pdf)
and read the
[CONTRIBUTING](https://github.com/OPCFoundation/UA-.NETStandard/blob/master/CONTRIBUTING.md)
doc.
- [x] I have added tests that prove my fix is effective or that my
feature works and increased code coverage.
- [x] I have added all necessary documentation.
- [x] I have verified that my changes do not introduce (new) build or
analyzer warnings.
- [x] I ran **all** tests locally using the **UA.slnx** solution against
at least .net **framework** and .net **10**, and all passed.
- [x] I fixed **all** failing and flaky tests in the CI pipelines and
**all** CodeQL warnings.
- [ ] I have addressed **all** PR feedback received.

---------

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Co-authored-by: Marc Schier <marcschier@users.noreply.github.com>
2026-10-16 20:09:14 +02:00

120 lines
5.4 KiB
XML

<?xml version="1.0" encoding="utf-8"?>
<!--
A DI-style companion model: a DeviceType subtype and one device instance
that DI's DeviceSet organizes. The instance declares every Mandatory child
of its type with its own NodeId. Several Variables carry no Value.
-->
<UANodeSet xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:xsd="http://www.w3.org/2001/XMLSchema"
xmlns:uax="http://opcfoundation.org/UA/2008/02/Types.xsd"
xmlns="http://opcfoundation.org/UA/2011/03/UANodeSet.xsd">
<NamespaceUris>
<Uri>http://test.org/UA/DeviceSetPump/</Uri>
<Uri>http://opcfoundation.org/UA/DI/</Uri>
</NamespaceUris>
<Models>
<Model ModelUri="http://test.org/UA/DeviceSetPump/" Version="1.0.0" PublicationDate="2026-10-01T00:00:00Z">
<RequiredModel ModelUri="http://opcfoundation.org/UA/" Version="1.05.04" PublicationDate="2025-01-08T00:00:00Z" />
<RequiredModel ModelUri="http://opcfoundation.org/UA/DI/" Version="1.05.0" PublicationDate="2025-11-15T00:00:00Z" />
</Model>
</Models>
<Aliases>
<Alias Alias="Double">i=11</Alias>
<Alias Alias="Int32">i=6</Alias>
<Alias Alias="String">i=12</Alias>
<Alias Alias="LocalizedText">i=21</Alias>
<Alias Alias="Organizes">i=35</Alias>
<Alias Alias="HasModellingRule">i=37</Alias>
<Alias Alias="HasTypeDefinition">i=40</Alias>
<Alias Alias="HasSubtype">i=45</Alias>
<Alias Alias="HasProperty">i=46</Alias>
</Aliases>
<UAObjectType NodeId="ns=1;i=1000" BrowseName="1:PumpType">
<DisplayName>PumpType</DisplayName>
<References>
<Reference ReferenceType="HasSubtype" IsForward="false">ns=2;i=1002</Reference>
<Reference ReferenceType="HasProperty">ns=1;i=6000</Reference>
</References>
</UAObjectType>
<UAVariable NodeId="ns=1;i=6000" BrowseName="1:RatedFlow" ParentNodeId="ns=1;i=1000" DataType="Double">
<DisplayName>RatedFlow</DisplayName>
<References>
<Reference ReferenceType="HasTypeDefinition">i=68</Reference>
<Reference ReferenceType="HasModellingRule">i=78</Reference>
</References>
</UAVariable>
<UAObject NodeId="ns=1;i=5000" BrowseName="1:Pump1">
<DisplayName>Pump1</DisplayName>
<References>
<Reference ReferenceType="HasTypeDefinition">ns=1;i=1000</Reference>
<Reference ReferenceType="Organizes" IsForward="false">ns=2;i=5001</Reference>
<Reference ReferenceType="HasProperty">ns=1;i=6010</Reference>
<Reference ReferenceType="HasProperty">ns=1;i=6011</Reference>
<Reference ReferenceType="HasProperty">ns=1;i=6012</Reference>
<Reference ReferenceType="HasProperty">ns=1;i=6013</Reference>
<Reference ReferenceType="HasProperty">ns=1;i=6014</Reference>
<Reference ReferenceType="HasProperty">ns=1;i=6015</Reference>
<Reference ReferenceType="HasProperty">ns=1;i=6016</Reference>
<Reference ReferenceType="HasProperty">ns=1;i=6017</Reference>
<Reference ReferenceType="HasProperty">ns=1;i=6018</Reference>
</References>
</UAObject>
<UAVariable NodeId="ns=1;i=6010" BrowseName="1:RatedFlow" ParentNodeId="ns=1;i=5000" DataType="Double">
<DisplayName>RatedFlow</DisplayName>
<References>
<Reference ReferenceType="HasTypeDefinition">i=68</Reference>
</References>
</UAVariable>
<UAVariable NodeId="ns=1;i=6011" BrowseName="2:SerialNumber" ParentNodeId="ns=1;i=5000" DataType="String">
<DisplayName>SerialNumber</DisplayName>
<References>
<Reference ReferenceType="HasTypeDefinition">i=68</Reference>
</References>
<Value>
<uax:String>SN-0001</uax:String>
</Value>
</UAVariable>
<UAVariable NodeId="ns=1;i=6012" BrowseName="2:RevisionCounter" ParentNodeId="ns=1;i=5000" DataType="Int32">
<DisplayName>RevisionCounter</DisplayName>
<References>
<Reference ReferenceType="HasTypeDefinition">i=68</Reference>
</References>
</UAVariable>
<UAVariable NodeId="ns=1;i=6013" BrowseName="2:Manufacturer" ParentNodeId="ns=1;i=5000" DataType="LocalizedText">
<DisplayName>Manufacturer</DisplayName>
<References>
<Reference ReferenceType="HasTypeDefinition">i=68</Reference>
</References>
</UAVariable>
<UAVariable NodeId="ns=1;i=6014" BrowseName="2:Model" ParentNodeId="ns=1;i=5000" DataType="LocalizedText">
<DisplayName>Model</DisplayName>
<References>
<Reference ReferenceType="HasTypeDefinition">i=68</Reference>
</References>
</UAVariable>
<UAVariable NodeId="ns=1;i=6015" BrowseName="2:HardwareRevision" ParentNodeId="ns=1;i=5000" DataType="String">
<DisplayName>HardwareRevision</DisplayName>
<References>
<Reference ReferenceType="HasTypeDefinition">i=68</Reference>
</References>
</UAVariable>
<UAVariable NodeId="ns=1;i=6016" BrowseName="2:SoftwareRevision" ParentNodeId="ns=1;i=5000" DataType="String">
<DisplayName>SoftwareRevision</DisplayName>
<References>
<Reference ReferenceType="HasTypeDefinition">i=68</Reference>
</References>
</UAVariable>
<UAVariable NodeId="ns=1;i=6017" BrowseName="2:DeviceRevision" ParentNodeId="ns=1;i=5000" DataType="String">
<DisplayName>DeviceRevision</DisplayName>
<References>
<Reference ReferenceType="HasTypeDefinition">i=68</Reference>
</References>
</UAVariable>
<UAVariable NodeId="ns=1;i=6018" BrowseName="2:DeviceManual" ParentNodeId="ns=1;i=5000" DataType="String">
<DisplayName>DeviceManual</DisplayName>
<References>
<Reference ReferenceType="HasTypeDefinition">i=68</Reference>
</References>
</UAVariable>
</UANodeSet>