mirror of
https://github.com/OPCFoundation/UA-.NETStandard.git
synced 2026-10-21 17:16:16 +08:00
be61d598a9
# Description Make startup-composed application NodeManagers participate in the live lifecycle and bind imported NodeSet2 Method argument properties to their typed `MethodState` children. This change: - adopts application NodeManagers created before startup into `INodeManagerLifecycle.Registrations` after server startup succeeds, while keeping diagnostics, configuration, and core managers protected; - retains per-manager startup external-reference ownership and exact routing positions so reload, removal, rollback, overlapping namespaces, synchronous adapters, and server restart preserve existing behavior; counted immutable reference snapshots avoid quadratic startup matching; - rejects duplicate factory output across active, unpublished, and retired lifecycle generations without deleting or disposing the live manager; callers can catch the public `NodeManagerAlreadyRegisteredException`; - binds valid namespace-zero `Argument[]` `PropertyType` `InputArguments` and `OutputArguments` Variables to `MethodState.InputArguments` and `MethodState.OutputArguments` from either `HasProperty` direction, without requiring `ParentNodeId`, including local namespace-URI reference targets; - preserves authored metadata during NodeSet typed-child promotion without changing the initialization behavior of unrelated generated nodes; - retains generic-import guards for custom and malformed signatures, duplicate standard-signature validation, and upstream factory-driven generated-slot replacement and reconciliation callbacks; - updates lifecycle and Runtime NodeSet documentation and clarifies `OnServerStartedAsync` timing for both `StartAsync` overloads, including the unopened default host returned to the caller. This is a focused follow-up to #4418. That PR preserves registrations from multiple fluent builders, but does not change lifecycle ownership or NodeSet child typing. The branch includes upstream `master` through `da7412c42`, including #4396, #4432, #4437, #4438, and #4440. The completed review fixes in `686d0561f` are included. The latest base merge (`a29fc6ca8`) combines them with #4432's shared batch/fluent importer and generated state factories. One iterative linker supports available parent nodes, deferred parent side tables, application-owned handles, and placeholder reconciliation while retaining reference-driven Method argument binding and URI handling. Upstream cancellation, GDS assembly renames, certificate leak scoping, and xRegistry changes are preserved. ## Related Issues - Fixes #4421 - Fixes #4422 ## CI regression fix `e1a4436f0` fixes the GDS failure reported on Ubuntu and macOS. Copying permission metadata in general `NodeState` initialization applied `SecurityAdmin`-only defaults to generated GDS custom certificate groups and denied their existing GDS-admin Browse requests. Metadata preservation is now confined to NodeSet typed-child promotion; imported Method argument permissions remain intact, while unrelated generated nodes retain their existing initialization behavior. Local Release validation also exposed a 260-character certificate path in the startup-failure test added by this PR. Its isolated PKI now uses a short temporary path. No assertions, authorization checks, or CI gates were weakened, and no pre-existing tests were changed. ## macOS ARM64 NativeAOT suspension Per maintainer request, `a15971f32` suspends only the failing `macos-latest` / `osx-arm64` NativeAOT matrix entry. Re-enabling it once the compiler contains the runtime fix is tracked in #4443. Intel macOS, Linux, and Windows NativeAOT coverage, managed macOS tests, and all other CI gates remain enabled. This is an explicit coverage suspension, not a claim that the underlying compiler/linker defect is fixed. The macOS ARM64 NativeAOT job on `a29fc6ca8` fails during native linking with `ld: Assertion failed: (_addend == uniqueIndex && "too many large addends")`. Both attempts of [run 34191755950](https://github.com/OPCFoundation/UA-.NETStandard/actions/runs/34191755950) hit the same assertion before the native test executable can run; the build/test summary failure is downstream. This matches the NativeAOT Mach-O relocation issue in dotnet/runtime#119380, fixed by relocation-anchor emission in dotnet/runtime#124721 and its .NET 10 backport dotnet/runtime#132171. The failing `Microsoft.DotNet.ILCompiler` 10.0.11 package's nuspec points to `dotnet/dotnet` commit `e2f47b0110ed922f21a1522da67279133ce28f32` (July 23); its object writer does not contain the anchor fix merged on August 12. Version 10.0.11 is currently the latest stable package. The base commit passed on the same runner image and SDK, so this is not being dismissed as a generally broken runner or a test flake. The precise PR-specific object-layout trigger has not been isolated. A compiler containing the relocation fix is needed before restoring the lane. No test code, assertions, coverage thresholds, or shared tooling settings were changed. ## Validation Latest base-merge validation on both `net10.0` and `net48`, Release: - Import helpers and argument-binding regressions: 51 passed per framework. - Batch/fluent import, generated-state overlays, runtime/startup lifecycle, cross-source references, routing, reference snapshots, and node-authoring selection: 344 passed per framework. - Merge-specific cases cover available Method parents with forward/inverse and URI/index references while retaining an application-owned `NodeId` handle. - The unchanged upstream `NodeSetImportIntegrationTests.cs:210` CA1861 warning remains; no diagnostic suppression or unrelated cleanup was added. Release CI-fix validation on both `net10.0` and `net48`: - `CustomCertificateGroupIntegrationTest`: 4 passed, including the unchanged CI failure. - `UANodeSetHelpersTests`: 8 passed, including imported security metadata. - `StartupRuntimeNodeSetLifecycleTests`: 5 passed. Earlier Debug merge and review validation on both frameworks: - Lifecycle, RuntimeNodeSet, fluent, and OperationContext selection after merging `978e6d1af`: 638 passed per framework. - Startup/transport-binding and RuntimeNodeSet integration selection after merging `017856f4a`: 28 passed per framework. - Public exception contract and duplicate-registration selection in `fbf08428b`: 6 passed per framework. Targeted test invocations rebuilt the affected projects successfully. The full `UA.slnx` suite was not rerun locally. ## Checklist - [ ] 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. - [ ] 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. - [x] I have addressed **all** PR feedback received. --------- Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> Copilot-Session: 2bb8a834-7695-4ae6-84cb-2471c76d1b12
138 lines
5.3 KiB
C#
138 lines
5.3 KiB
C#
/* ========================================================================
|
|
* Copyright (c) 2005-2026 The OPC Foundation, Inc. All rights reserved.
|
|
*
|
|
* OPC Foundation MIT License 1.00
|
|
*
|
|
* Permission is hereby granted, free of charge, to any person
|
|
* obtaining a copy of this software and associated documentation
|
|
* files (the "Software"), to deal in the Software without
|
|
* restriction, including without limitation the rights to use,
|
|
* copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
* copies of the Software, and to permit persons to whom the
|
|
* Software is furnished to do so, subject to the following
|
|
* conditions:
|
|
*
|
|
* The above copyright notice and this permission notice shall be
|
|
* included in all copies or substantial portions of the Software.
|
|
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
|
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
|
|
* OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
|
* NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
|
|
* HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
|
|
* WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
|
|
* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
|
|
* OTHER DEALINGS IN THE SOFTWARE.
|
|
*
|
|
* The complete license agreement can be found here:
|
|
* http://opcfoundation.org/License/MIT/1.00/
|
|
* ======================================================================*/
|
|
|
|
using System.Collections.Generic;
|
|
using System.Linq;
|
|
using NUnit.Framework;
|
|
using Opc.Ua.Export;
|
|
using Opc.Ua.Tests;
|
|
|
|
namespace Opc.Ua.Core.Tests.Stack.Schema
|
|
{
|
|
/// <summary>
|
|
/// Covers typed argument import together with the generic child-linking contract.
|
|
/// </summary>
|
|
[TestFixture]
|
|
[Category("UANodeSet")]
|
|
[Parallelizable]
|
|
public sealed class UANodeSetMethodArgumentBindingTests
|
|
{
|
|
[TestCase(BrowseNames.InputArguments)]
|
|
[TestCase(BrowseNames.OutputArguments)]
|
|
public void ImportRejectsDuplicateStandardArgumentProperties(string browseName)
|
|
{
|
|
UANodeSet nodeSet = CreateNodeSet(browseName);
|
|
var context = new SystemContext(NUnitTelemetryContext.Create())
|
|
{
|
|
NamespaceUris = new NamespaceTable()
|
|
};
|
|
var nodes = new NodeStateCollection();
|
|
|
|
ServiceResultException exception = Assert.Throws<ServiceResultException>(
|
|
() => nodeSet.Import(context, nodes, linkParentChild: true));
|
|
|
|
Assert.That(exception.StatusCode, Is.EqualTo(StatusCodes.BadDecodingError));
|
|
Assert.That(exception.Message, Does.Contain($"multiple {browseName}"));
|
|
}
|
|
|
|
[TestCase("1:InputArguments")]
|
|
[TestCase("1:OutputArguments")]
|
|
public void ImportKeepsCustomArgumentNamesAsOrdinaryChildren(string browseName)
|
|
{
|
|
UANodeSet nodeSet = CreateNodeSet(browseName);
|
|
var context = new SystemContext(NUnitTelemetryContext.Create())
|
|
{
|
|
NamespaceUris = new NamespaceTable()
|
|
};
|
|
var nodes = new NodeStateCollection();
|
|
|
|
nodeSet.Import(context, nodes, linkParentChild: true);
|
|
|
|
MethodState method = nodes.OfType<MethodState>().Single();
|
|
var children = new List<BaseInstanceState>();
|
|
method.GetChildren(context, children);
|
|
Assert.Multiple(() =>
|
|
{
|
|
Assert.That(method.InputArguments, Is.Null);
|
|
Assert.That(method.OutputArguments, Is.Null);
|
|
Assert.That(children, Has.Count.EqualTo(2));
|
|
Assert.That(children, Is.All.InstanceOf<PropertyState<ArrayOf<Argument>>>());
|
|
Assert.That(children.Select(child => child.Parent), Is.All.SameAs(method));
|
|
Assert.That(
|
|
children.Select(child => child.NodeId),
|
|
Is.EquivalentTo(nodes.OfType<BaseVariableState>().Select(node => node.NodeId)));
|
|
});
|
|
}
|
|
|
|
private static UANodeSet CreateNodeSet(string browseName)
|
|
{
|
|
return new UANodeSet
|
|
{
|
|
NamespaceUris = ["urn:test:typed-method-argument-binding"],
|
|
Items =
|
|
[
|
|
CreateArgument("ns=1;i=1001", browseName),
|
|
CreateArgument("ns=1;i=1002", browseName),
|
|
new UAMethod
|
|
{
|
|
NodeId = "ns=1;i=1000",
|
|
BrowseName = "1:Load"
|
|
}
|
|
]
|
|
};
|
|
}
|
|
|
|
private static UAVariable CreateArgument(string nodeId, string browseName)
|
|
{
|
|
return new UAVariable
|
|
{
|
|
NodeId = nodeId,
|
|
BrowseName = browseName,
|
|
ParentNodeId = "ns=1;i=1000",
|
|
DataType = "i=296",
|
|
ValueRank = ValueRanks.OneDimension,
|
|
References =
|
|
[
|
|
new Reference
|
|
{
|
|
ReferenceType = "i=40",
|
|
Value = "i=68"
|
|
},
|
|
new Reference
|
|
{
|
|
ReferenceType = "i=46",
|
|
IsForward = false,
|
|
Value = "ns=1;i=1000"
|
|
}
|
|
]
|
|
};
|
|
}
|
|
}
|
|
}
|