Files
UA-.NETStandard/tests/Opc.Ua.Server.Tests/CoverageNodeSet/Assets/Opc.Ua.CoverageTestSecondary.NodeSet2.xml
romanett 333de8305b Add kitchen-sink coverage NodeSet2 with three load pipelines (#4251) (#4272)
# Description

Regression fence for the NodeSet2 import + code-generation surface. This
adds a single, purpose-authored "kitchen-sink" NodeSet2
(`Opc.Ua.CoverageTest.NodeSet2.xml`) plus a small dependent secondary
model that deliberately flip a broad set of the knobs defined by
`UANodeSet.xsd` (every node class, every `Definition` shape, custom
reference types, all five modelling rules, scalar/array/matrix values, a
deep branching instance tree, and a wide set of reference relations).
The same bytes are then loaded into **real** servers (`ServerFixture<T>`
+ `ReferenceServer`) through three independent pipelines and validated
node-by-node, attribute-by-attribute, reference-by-reference:

1. **Source-generation, hand-written manager** - the XML is consumed at
compile time via `<AdditionalFiles
ModelSourceGeneratorPrefix="Opc.Ua.CoverageTest">`; the generated
`AddOpcUaCoverageTest(context)` composes the predefined nodes inside a
`CustomNodeManager2`, so every node materialises as its generated
`NodeState` subclass.
2. **Runtime import** - the identical XML is imported at startup through
`RuntimeNodeSetNodeManagerFactory` / `AddRuntimeNodeSet`.
3. **Source-generation, generated fluent manager** - a
`[NodeManager]`-attributed partial makes the generator emit the whole
`FluentNodeManagerBase` manager, factory and typed fluent-builder
surface.

A shared, data-driven `[TestCaseSource]` battery runs the identical
assertions against all three servers, and a cross-pipeline equivalence
fixture asserts the three address spaces agree. A dependent **second
namespace** (`.../Secondary/`) exercises cross-namespace
`HasTypeDefinition`, `HasSubtype` and `HasComponent` references in every
pipeline.

Authoring the model surfaced two latent source-generator bugs, both
fixed here:

- `NodeSetToModelDesign` crashed on a top-level `<ServerUris>` table
(`StringTable.Append(null)` for the reserved local-server slot). Added a
null guard plus a focused regression test (`NodesetServerUrisTests`).
- `FluentBuilderGenerator` emitted colliding typed-builder accessors for
any model with more than one structure encoding, because
`DataTypeEncoding` objects hang off their `DataType` and surfaced as
parent-less "root" instances sharing the reserved
`DefaultBinary`/`DefaultXml`/`DefaultJson` symbolic names. They are
encoding metadata, never fluent-wired, so they are now excluded from the
typed builder.

A few edges are intentionally not asserted for cross-pipeline
equivalence because the pipelines legitimately differ (documented in
`CoverageNodeSet/README.md`): type-dictionary / `DataTypeDescription`
nodes (the generator regenerates schema rather than emitting them), a
handful of ambiguous duplicate-hierarchical / View-`Organizes` edges,
and runtime structure stand-ins (structure definitions are validated via
the `DataTypeDefinition` round-trip instead).

## Related Issues

- Fixes #4251

## Checklist

_Put an `x` in the boxes that apply. You can complete these step by step
after opening the PR._

- [ ] 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.
- [ ] 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 App <223556219+Copilot@users.noreply.github.com>
Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com>
Co-authored-by: romanett <7413710+romanett@users.noreply.github.com>
2026-08-17 14:59:58 -07:00

60 lines
2.9 KiB
XML

<?xml version="1.0" encoding="utf-8"?>
<!-- ========================================================================
Secondary model for the coverage harness (issue #4251 follow-up). It
declares its own namespace and depends on the primary CoverageTest model
(RequiredModel), so it exercises cross-namespace NodeIds and references:
- SecondaryObjectType is a HasSubtype of the primary CoverageObjectType.
- SecondaryInstance is a HasComponent child of the primary CoverageRoot
(a cross-namespace / cross-NodeManager reference resolved through the
master's reverse-reference mechanism).
======================================================================== -->
<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://opcfoundation.org/UA/CoverageTest/</Uri>
<Uri>http://opcfoundation.org/UA/CoverageTest/Secondary/</Uri>
</NamespaceUris>
<Models>
<Model ModelUri="http://opcfoundation.org/UA/CoverageTest/Secondary/"
Version="1.0.0"
PublicationDate="2024-06-01T00:00:00Z">
<RequiredModel ModelUri="http://opcfoundation.org/UA/"
PublicationDate="2023-12-15T00:00:00Z"
Version="1.05.03" />
<RequiredModel ModelUri="http://opcfoundation.org/UA/CoverageTest/"
PublicationDate="2024-06-01T00:00:00Z"
Version="1.2.3" />
</Model>
</Models>
<Aliases>
<Alias Alias="Int32">i=6</Alias>
<Alias Alias="HasModellingRule">i=37</Alias>
<Alias Alias="HasTypeDefinition">i=40</Alias>
<Alias Alias="HasSubtype">i=45</Alias>
<Alias Alias="HasComponent">i=47</Alias>
</Aliases>
<!-- Object type in the secondary namespace, subtyped from the primary
CoverageObjectType (cross-namespace HasSubtype). -->
<UAObjectType NodeId="ns=2;i=6001" BrowseName="2:SecondaryObjectType">
<DisplayName>SecondaryObjectType</DisplayName>
<Description>Secondary-namespace object type derived from the primary type.</Description>
<References>
<Reference ReferenceType="HasSubtype" IsForward="false">ns=1;i=5210</Reference>
</References>
</UAObjectType>
<!-- Instance in the secondary namespace, HasComponent child of the primary
CoverageRoot (cross-namespace / cross-NodeManager reference). -->
<UAObject NodeId="ns=2;i=6010" BrowseName="2:SecondaryInstance" ParentNodeId="ns=1;i=5400">
<DisplayName>SecondaryInstance</DisplayName>
<Description>Secondary-namespace instance parented under the primary root.</Description>
<References>
<Reference ReferenceType="HasTypeDefinition">ns=2;i=6001</Reference>
<Reference ReferenceType="HasComponent" IsForward="false">ns=1;i=5400</Reference>
</References>
</UAObject>
</UANodeSet>