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

60 lines
2.6 KiB
XML

<?xml version="1.0" encoding="utf-8"?>
<!--
Objects organized by nodes of DI whose NodeIds give the same stand-in name
when only the identifier text is used: i=5001 and s=5001, s=A.B and s=A/B.
Every reference must keep its own target NodeId.
-->
<UANodeSet xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:xsd="http://www.w3.org/2001/XMLSchema"
xmlns="http://opcfoundation.org/UA/2011/03/UANodeSet.xsd">
<NamespaceUris>
<Uri>http://test.org/UA/ExternalTargetCollisions/</Uri>
<Uri>http://opcfoundation.org/UA/DI/</Uri>
</NamespaceUris>
<Models>
<Model ModelUri="http://test.org/UA/ExternalTargetCollisions/" 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="Organizes">i=35</Alias>
<Alias Alias="HasTypeDefinition">i=40</Alias>
<Alias Alias="HasSubtype">i=45</Alias>
</Aliases>
<UAObjectType NodeId="ns=1;i=1000" BrowseName="1:CollisionTargetType">
<DisplayName>CollisionTargetType</DisplayName>
<References>
<Reference ReferenceType="HasSubtype" IsForward="false">i=58</Reference>
</References>
</UAObjectType>
<UAObject NodeId="ns=1;i=5001" BrowseName="1:NumericTarget">
<DisplayName>NumericTarget</DisplayName>
<References>
<Reference ReferenceType="HasTypeDefinition">ns=1;i=1000</Reference>
<Reference ReferenceType="Organizes" IsForward="false">ns=2;i=5001</Reference>
</References>
</UAObject>
<UAObject NodeId="ns=1;i=5002" BrowseName="1:StringTarget">
<DisplayName>StringTarget</DisplayName>
<References>
<Reference ReferenceType="HasTypeDefinition">ns=1;i=1000</Reference>
<Reference ReferenceType="Organizes" IsForward="false">ns=2;s=5001</Reference>
</References>
</UAObject>
<UAObject NodeId="ns=1;i=5003" BrowseName="1:DottedTarget">
<DisplayName>DottedTarget</DisplayName>
<References>
<Reference ReferenceType="HasTypeDefinition">ns=1;i=1000</Reference>
<Reference ReferenceType="Organizes" IsForward="false">ns=2;s=A.B</Reference>
</References>
</UAObject>
<UAObject NodeId="ns=1;i=5004" BrowseName="1:SlashedTarget">
<DisplayName>SlashedTarget</DisplayName>
<References>
<Reference ReferenceType="HasTypeDefinition">ns=1;i=1000</Reference>
<Reference ReferenceType="Organizes" IsForward="false">ns=2;s=A/B</Reference>
</References>
</UAObject>
</UANodeSet>