mirror of
https://github.com/OPCFoundation/UA-.NETStandard.git
synced 2026-10-16 21:02:51 +08:00
61edaa1ed0
# Description Drops support for **netstandard2.1** and **.NET Framework 4.7.2**. Libraries now target `net48`, `net8.0`, `net9.0` and `net10.0`. `Opc.Ua.Types` and `Opc.Ua.SourceGeneration.Core` still also target `netstandard2.0`, but only because the Roslyn source generators load them. There is no general netstandard2.0 support. **Preprocessor directives** (112 files) - Every `#if`/`#elif` mentioning `NETSTANDARD2_1*`, `NET472*`, `NET_STANDARD_TESTS`, `SKIP_ECC_CERTIFICATE_REQUEST_SIGNING` or `NETSTANDARD*` was evaluated against the remaining TFM set (net48, net8/9/10, plus netstandard2.0 inside `Opc.Ua.Types`/`tools`) and simplified. Dead branches were removed. - Example: `NETSTANDARD2_1 || NET8_0_OR_GREATER` → `NET8_0_OR_GREATER`. - Example: `NET8_0_OR_GREATER || NET472_OR_GREATER` → removed (always true). - Netstandard-only code was removed: `UnixFileModeShim`, the CRDT reflection path in `ReplicatedGossipOptions.CreateReaderOptions`, and the netstandard2.1-only test variants. **Custom test logic** - `targets.props` drops the `net472`, `netstandard2.0` and `netstandard2.1` `CustomTestTarget` profiles, `NetStandardTests` and `SKIP_ECC_CERTIFICATE_REQUEST_SIGNING`. Supported values are now `net48`, `net8.0`, `net9.0`, `net10.0`. - The `NET_STANDARD_TESTS` define is removed from 29 test projects. - The "build netstandard shells as net10.0" overrides are removed from 18 projects. - `RestrictForLegacyTfm` now only applies to `net48`. - `tests/customtest.bat` is updated to the new values. **Build / packaging / CI** - MSBuild TFM conditions are simplified: Kestrel package choice, MQTTnet v4 (net48 only), BouncyCastle, Di/OpenUsd/Vision/Stress test excludes, and `System.IO.FileSystem.AccessControl` (dropped from Core). - The MigrationAnalyzer nuspec drops its net472/netstandard2.1 lib groups. The Azure signing lists are updated. - `get-ci-matrix.ps1` removes the net472/netstandard test profiles (including the PR-gating `linux-netstandard2.1`) and the matching build legs. **Breaking API change (2.0 preview):** removed `HttpsTransportListener.IsWssTransportSupported` and `ReplicatedGossipOptions.IsGossipStateDecodingSupported`. They only returned `false` on netstandard2.1 and are now always `true`. The test guards that used them were removed as well. **Docs** - NuGet READMEs, `README.md`, `DeveloperGuide.md`, `PubSub.md`, the certificate/ECC/identity docs and the 2.0 migration guide (plus its `.agents` skill mirror) are updated. - The migration guide notes that 4.7.2 consumers must move to 4.8 and netstandard2.1 consumers to net8.0+. ### Reviewer notes - The `System.IO.FileSystem.AccessControl` `PackageVersion` pin is left in `Directory.Packages.props`. It has no direct reference any more, but transitive pinning is on, so it was kept to avoid shifting resolved versions. - The `#if` rewrite was done mechanically by a truth-table evaluator. The diff in the `.cs` files is limited to directive lines, removed dead branches, and stale-comment updates. ### Verified locally - `dotnet build UA.slnx -p:CustomTestTarget=net48`: 0 errors. - `dotnet build UA.slnx -p:CustomTestTarget=net10.0`: 0 errors. - Default multi-target builds (no `CustomTestTarget`) of Opc.Ua.Types, Bindings.Https, PubSub.Mqtt and Redundancy.Server succeeded. - net10.0 tests: - Opc.Ua.Redundancy.Server.Tests: 840/840 passed. - Opc.Ua.Types.Tests: 11363 passed, 1 skipped. - ModelDependencyScanner tests: 20/20 passed. - The full test suite was **not** run locally. ## Related Issues - None ## 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. - [ ] 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. - [ ] 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. - [ ] I have addressed **all** PR feedback received. 🤖 Generated with [Claude Code](https://claude.com/claude-code) --------- Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
163 lines
9.8 KiB
XML
163 lines
9.8 KiB
XML
<Project>
|
|
<Import Project="version.targets" />
|
|
|
|
<!--
|
|
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>` = `net48`,
|
|
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'">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>
|
|
<!-- An Exe project that names an entry point still passes /main to the
|
|
compiler, which is CS2017 once the shell downgrades it to a library. -->
|
|
<StartupObject />
|
|
<GenerateProgramFile>false</GenerateProgramFile>
|
|
<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 shell is an empty assembly, so there is nothing to test. Leaving it
|
|
marked as a test project makes `dotnet test` on a legacy leg launch a
|
|
test host for output the leg cannot load. -->
|
|
<IsTestProject>false</IsTestProject>
|
|
<IsTestingPlatformApplication>false</IsTestingPlatformApplication>
|
|
</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>
|