mirror of
https://github.com/OPCFoundation/UA-.NETStandard.git
synced 2026-10-17 05:11:13 +08:00
e73e71184d
## Summary Adds OPC UA WoT Connectivity 1.1 to the stack, together with the Types, source generation, Server and xRegistry work it is built on. This branch is the merge point for the fourteen-PR stack that replaced integration PR #4093; every constituent PR was reviewed and approved separately and is listed below. 414 files changed, +108,936 / -3,199. Roughly 46k added lines of product code, 57k of tests, plus samples, tools and documentation. ## Types - Complete `ExtensionObject` raw-body decoding for binary, XML and JSON bodies by resolving the concrete type through the message context's encodeable factory, and simplify the `Variant` structure helpers by delegating to it (#4128). - Add `IAtomicFileReplace` as an optional `IFileSystem` capability so existing external implementations keep working, with atomic publish for `LocalFileSystem` via `File.Replace`/`File.Move` and for `VirtualFileSystem` by re-keying the in-memory entry (#4128). - Add lossless conversion between WoT documents and NodeSet2 (`Opc.Ua.Wot.WotNodeSetConverter`). A byte-exact `uav:nodeSet` envelope is preserved when requested, the structured `uav:nodes` projection is used when the readable vocabulary is incomplete, and NodeSet2 is otherwise synthesized from readable WoT terms. Unmapped JSON members survive a round trip as pointer-addressed residue (#4131). ## Source generation - Improve the NodeSet to ModelDesign conversion and the generated node state (#4132). - Generate OPC UA models directly from WoT Thing Description files (#4134). ## Server - Add live NodeManager shadow and immediate reload. A reload materializes a new generation beside the active one and switches atomically; the superseded generation is retired gracefully so existing MonitoredItems keep being served until they drain, or immediately when the caller asks for it. Includes the request admission and drain machinery that lets an orderly shutdown wait for admitted requests instead of tearing down underneath them (#4147). - Make subscription transfer between sessions transactional, so a failed transfer leaves neither session holding a partially moved subscription (#4150). ## xRegistry - Allow clients to use explicit registry roots rather than assuming a well-known location (#4130). ## WoT Connectivity - Add the WoT Connectivity 1.1 information model: a registry-first revision layered on the abstract xRegistry base model, incorporating the complete published OPC 10100-1 v1.02 surface as deprecated nodes in the same namespace so existing 1.02 clients keep working (#4139). - Add the protocol binding abstractions and planners that compile WoT forms into executable plans (#4140). - Add the HTTP, Modbus, OPC UA and MQTT binding executors (#4144). - Add the registry and its stores, including document versioning, validation, dependency resolution and refresh (#4146). - Add the registry client (#4142). - Materialize WoT Thing Descriptions into the server address space, deriving types from Thing Models and instances from Thing Descriptions (#4154). - Restore the WoT asset registry bridge so the deprecated 1.02 asset surface is backed by the registry (#4171). - Add the WoT Connectivity samples and complete the documentation (#4156), and restore the remaining coverage and docs (#4172). ## New projects `src/Opc.Ua.WotCon.Bindings`, `src/Opc.Ua.WotCon.Bindings.Mqtt`, `tests/Opc.Ua.WotCon.Bindings.Tests`, `tests/Opc.Ua.WotCon.Samples.Tests`, and the `samples/WotCon` AggregationServer, AggregationClient and FlatTagServer samples. ## Constituent pull requests Merged into this branch top-down, each independently approved: | PR | Title | | --- | --- | | #4128 | [Types] Complete ExtensionObject decoding and add an atomic file replace capability | | #4131 | [Types] Add lossless conversion between WoT documents and NodeSet2 | | #4132 | [SourceGeneration] Improve NodeSet to ModelDesign conversion and generated node state | | #4134 | [SourceGeneration] Generate OPC UA models from WoT Thing Description files | | #4147 | [Server] Add live NodeManager shadow and immediate reload | | #4150 | [Server] Make subscription transfer between sessions transactional | | #4130 | [XRegistry] Allow clients to use explicit registry roots | | #4139 | [WotCon] Add the WoT Connectivity 1.1 information model | | #4140 | [WotCon] Add the WoT protocol binding abstractions and planners | | #4144 | [WotCon] Add the HTTP, Modbus, OPC UA and MQTT binding executors | | #4146 | [WotCon] Add the WoT Connectivity registry and its stores | | #4142 | [WotCon] Add the WoT Connectivity registry client | | #4154 | [WotCon] Materialize WoT Thing Descriptions into the server address space | | #4156 | [WotCon] Add the WoT Connectivity samples and complete the documentation | | #4171 | Restore WoT asset registry bridge | | #4172 | Restore WoT coverage and docs | Supersedes #4093. ## Follow-up The WoT Connectivity and WoT Binding drafts have moved to 1.1-draft2 since this work was authored. Aligning with that revision - the removed group vocabulary, the new projection/View construct, the remaining model vocabulary terms and the two new portable-identity validation rules - is tracked separately and will follow in its own pull request. ## Validation Built for every target framework with zero warnings and zero errors, and validated at the tip of the stack with `Opc.Ua.WotCon.Tests` at 999 passed / 0 failed and `Opc.Ua.Server.Tests` at 4024 passed / 0 failed. --------- Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> Copilot-Session: 9e6a5abf-3299-4cd1-9855-010fedbf0ad8
156 lines
9.7 KiB
XML
156 lines
9.7 KiB
XML
<Project>
|
|
<!--
|
|
Per-project opt-in for the CI per-TFM build matrix: when a `.csproj`
|
|
sets `<RestrictForLegacyTfm>true</RestrictForLegacyTfm>` in its main
|
|
`PropertyGroup`, this Directory.Build.targets makes the project a
|
|
no-op build (empty Library, no compile items, no references) for
|
|
`dotnet build … /p:CustomTestTarget=<tfm>` invocations that the
|
|
project cannot take part in. That is the case for
|
|
`<tfm>` in `net472` / `net48` / `netstandard2.0` / `netstandard2.1`,
|
|
and for any project that pins a single `TargetFramework` different
|
|
from `<tfm>`. Use this for projects that are `.NET 8+` only
|
|
(e.g. `PublishAot=true`, `ModelContextProtocol` server, TUnit AOT
|
|
tests) and therefore can't participate in a `UA.slnx` build pinned
|
|
to a legacy TFM via `CustomTestTarget`.
|
|
|
|
The single-`TargetFramework` case matters because `CustomTestTarget`
|
|
only redirects the shared TFM variables in `targets.props`; a project
|
|
that hardcodes, say, `net10.0` keeps compiling against its own
|
|
reference assemblies while the rest of the stack is built for
|
|
`<tfm>`. Mixing the two surfaces as `CS0433` on every BCL type the
|
|
stack polyfills for older frameworks (`System.Threading.Lock` is
|
|
defined by `Opc.Ua.Types` on `net8.0` and by `System.Runtime` on
|
|
`net9.0+`), which is a property of the pinned build rather than of
|
|
the project's own sources.
|
|
|
|
The project still loads in the `.slnx` graph so the matrix prep
|
|
script discovers it, but `Compile` / `ProjectReference` /
|
|
`PackageReference` / `AdditionalFiles` / `None` / `Content` are all
|
|
cleared and `OutputType` flips to `Library`, producing an empty
|
|
assembly without dragging the project's `.NET 8+` source through
|
|
the C# compiler against the restricted dependency set.
|
|
|
|
Targets are deliberately NOT overridden here - same-named targets
|
|
in `Directory.Build.targets` ALWAYS replace the SDK definitions
|
|
(the `Condition` only gates execution, not registration), which
|
|
would silently break the SDK's restore in unrestricted builds
|
|
(e.g. the GitHub Actions `dotnet publish` / `dotnet test` flows
|
|
that don't pass `CustomTestTarget`).
|
|
|
|
Projects that don't set `RestrictForLegacyTfm` are completely
|
|
unaffected by this file - every condition below evaluates to
|
|
false and no items / properties / targets are touched.
|
|
-->
|
|
<PropertyGroup>
|
|
<_RestrictedToLegacyTfm
|
|
Condition="'$(RestrictForLegacyTfm)' == 'true' and ('$(CustomTestTarget)' == 'net48' or '$(CustomTestTarget)' == 'net472' or '$(CustomTestTarget)' == 'netstandard2.0' or '$(CustomTestTarget)' == 'netstandard2.1')">true</_RestrictedToLegacyTfm>
|
|
<!-- Multi-targeted projects follow CustomTestTarget through targets.props,
|
|
so only a project that pins exactly one TargetFramework can end up
|
|
building against a framework the rest of the solution is not using. -->
|
|
<_RestrictedToLegacyTfm
|
|
Condition="'$(RestrictForLegacyTfm)' == 'true' and '$(CustomTestTarget)' != '' and '$(TargetFrameworks)' == '' and '$(TargetFramework)' != '' and '$(CustomTestTarget)' != '$(TargetFramework)'">true</_RestrictedToLegacyTfm>
|
|
</PropertyGroup>
|
|
<PropertyGroup Condition="'$(_RestrictedToLegacyTfm)' == 'true'">
|
|
<OutputType>Library</OutputType>
|
|
<EnableDefaultCompileItems>false</EnableDefaultCompileItems>
|
|
<EnableDefaultEmbeddedResourceItems>false</EnableDefaultEmbeddedResourceItems>
|
|
<EnableDefaultNoneItems>false</EnableDefaultNoneItems>
|
|
<EnableDefaultContentItems>false</EnableDefaultContentItems>
|
|
<IsPackable>false</IsPackable>
|
|
<PackAsTool>false</PackAsTool>
|
|
<PublishAot>false</PublishAot>
|
|
<GenerateAssemblyInfo>false</GenerateAssemblyInfo>
|
|
<GenerateTargetFrameworkAttribute>false</GenerateTargetFrameworkAttribute>
|
|
<NoWarn>$(NoWarn);CS2008;CA1014;CA1016</NoWarn>
|
|
<!-- The no-op shell strips all references, so on netstandard2.x there is no
|
|
assembly providing System.Object; supply an explicit RuntimeMetadataVersion
|
|
so the empty assembly still compiles (net4x get it from the targeting pack). -->
|
|
<RuntimeMetadataVersion Condition="'$(RuntimeMetadataVersion)' == ''">v4.0.30319</RuntimeMetadataVersion>
|
|
</PropertyGroup>
|
|
<ItemGroup Condition="'$(_RestrictedToLegacyTfm)' == 'true'">
|
|
<Compile Remove="@(Compile)" />
|
|
<ProjectReference Remove="@(ProjectReference)" />
|
|
<PackageReference Remove="@(PackageReference)" />
|
|
<AdditionalFiles Remove="@(AdditionalFiles)" />
|
|
<None Remove="@(None)" />
|
|
<Content Remove="@(Content)" />
|
|
</ItemGroup>
|
|
<Target Name="_LogSkippedForLegacyTfm" BeforeTargets="Build" Condition="'$(_RestrictedToLegacyTfm)' == 'true'">
|
|
<Message Importance="high" Text="Skipping $(MSBuildProjectName) for CustomTestTarget=$(CustomTestTarget) (.NET 8+ only)." />
|
|
</Target>
|
|
<!--
|
|
Every package in this repository is licensed under the OPC Foundation MIT
|
|
License 1.00 and ships the shared `LICENSE.txt` that `common.props` wires
|
|
up as `<PackageLicenseFile>`. That license is NOT the plain SPDX `MIT`
|
|
license: it carries the OPC Foundation copyright and preamble, so a package
|
|
declaring `<PackageLicenseExpression>MIT</PackageLicenseExpression>` would
|
|
advertise the wrong license on nuget.org (generic MIT plus a
|
|
`licenses.nuget.org/MIT` URL) instead of the OPC Foundation text.
|
|
|
|
Such a declaration also breaks the build outright: NuGet refuses to pack a
|
|
project that carries both a license expression and the inherited license
|
|
file (`NU5033: Cannot specify both a PackageLicenseExpression and a
|
|
PackageLicenseFile`), which fails `pack` for the whole solution rather than
|
|
just the offending project.
|
|
|
|
`common.props` cannot catch this itself - it is imported from
|
|
`Directory.Build.props`, i.e. before the project body, so it never observes
|
|
a project-level license expression. `Directory.Build.targets` is imported
|
|
after the project body, so it is the earliest place that can, and it fails
|
|
with an actionable message instead of the cryptic NuGet error.
|
|
-->
|
|
<Target Name="_ValidatePackageLicense" BeforeTargets="Build;Pack"
|
|
Condition="'$(IsPackable)' != 'false' AND '$(PackageLicenseExpression)' != ''">
|
|
<Error Code="OPCUA0001"
|
|
Text="$(MSBuildProjectName) sets PackageLicenseExpression=$(PackageLicenseExpression). Every package must ship the OPC Foundation MIT License 1.00 via the shared LICENSE.txt that common.props sets as PackageLicenseFile, which the SPDX expression neither matches nor is allowed to coexist with (NU5033). Remove the PackageLicenseExpression property." />
|
|
</Target>
|
|
<!--
|
|
On netstandard target frameworks two [LoggerMessage] source generators can be active at once:
|
|
the in-box generator shipped in Microsoft.Extensions.Logging(.Abstractions) and the R9
|
|
Microsoft.Gen.Logging generator that flows in transitively from R9 packages such as
|
|
Microsoft.Extensions.Http.Resilience / .Compliance / .Telemetry. Both emit an implementation
|
|
for every partial [LoggerMessage] method, producing CS0757 ("a partial method may not have
|
|
multiple implementing declarations"). On .NET Framework and net8.0+ only the R9 generator runs,
|
|
so removing the R9 analyzer on netstandard leaves exactly one generator on every TFM. The
|
|
Analyzer Remove is a no-op for projects that don't reference Microsoft.Gen.Logging.
|
|
-->
|
|
<Target Name="RemoveDuplicateLoggingGenerator" BeforeTargets="CoreCompile"
|
|
Condition="'$(TargetFrameworkIdentifier)' == '.NETStandard'">
|
|
<ItemGroup>
|
|
<Analyzer Remove="@(Analyzer)"
|
|
Condition="$([System.String]::Copy('%(Analyzer.Identity)').Contains('Microsoft.Gen.Logging'))" />
|
|
</ItemGroup>
|
|
</Target>
|
|
<!--
|
|
A `ProjectReference` with `OutputItemType=Analyzer` hands the compiler only the referenced
|
|
project's own assembly, never its runtime closure. The `Opc.Ua.SourceGeneration*` generators
|
|
need Opc.Ua.SourceGeneration.Core, Opc.Ua.Types and the Microsoft.Extensions.Logging /
|
|
System.Text.Json graph at generator-load time, so without those paths the compiler cannot
|
|
resolve them and the generators fail to initialize (CS8784).
|
|
|
|
Registering the closure as `Analyzer` items mirrors the `analyzers/dotnet/<roslyn>/cs`
|
|
payload the generator NuGet packages ship (see tools/SourceGeneratorPack.targets), which
|
|
NuGet registers the same way for package consumers. The closure is discovered by globbing
|
|
the generator's output directory, so a new dependency never needs a project file change.
|
|
|
|
Assemblies the compiler itself supplies are excluded. Handing the compiler a second copy
|
|
of Microsoft.CodeAnalysis*, System.Collections.Immutable or System.Reflection.Metadata
|
|
splits the identity of types that cross Roslyn's own API surface and breaks generator
|
|
initialization. See roslyn.props.
|
|
-->
|
|
<Target Name="AddSourceGeneratorAnalyzerDependencies" BeforeTargets="CoreCompile">
|
|
<ItemGroup>
|
|
<_SourceGeneratorAnalyzer Include="@(Analyzer)"
|
|
Condition="'%(Analyzer.MSBuildSourceProjectFile)' != '' AND
|
|
$([System.String]::Copy('%(Analyzer.Filename)').StartsWith('Opc.Ua.SourceGeneration'))" />
|
|
<_SourceGeneratorAnalyzerDependency
|
|
Include="%(_SourceGeneratorAnalyzer.RootDir)%(_SourceGeneratorAnalyzer.Directory)*.dll"
|
|
Exclude="@(_SourceGeneratorAnalyzer);
|
|
%(_SourceGeneratorAnalyzer.RootDir)%(_SourceGeneratorAnalyzer.Directory)Microsoft.CodeAnalysis*.dll;
|
|
%(_SourceGeneratorAnalyzer.RootDir)%(_SourceGeneratorAnalyzer.Directory)System.Collections.Immutable.dll;
|
|
%(_SourceGeneratorAnalyzer.RootDir)%(_SourceGeneratorAnalyzer.Directory)System.Reflection.Metadata.dll" />
|
|
<Analyzer Include="@(_SourceGeneratorAnalyzerDependency->Distinct())" />
|
|
</ItemGroup>
|
|
</Target>
|
|
</Project>
|