mirror of
https://github.com/OPCFoundation/UA-.NETStandard.git
synced 2026-10-21 09:06:37 +08:00
c03c128384
# Description `TreatWarningsAsErrors` was already enabled, but `CodeAnalysisTreatWarningsAsErrors` was `false`, so Microsoft Code Analysis (`CAxxxx`) warnings were non-fatal. This PR sets it to `true` in `common.props` and fixes all 55 analyzer warnings the net10.0 build reported. **Production code** - `SamplingGroup.cs`: CA2213 is a false positive here because the detached `CancellationTokenSource` is disposed by `CancelSamplingLoop` once the loop completes. It is suppressed with a pragma, a justification and a TODO, following the existing pattern in `ServerBase.RequestQueue.cs`. **Tests** - CA1861: constant array arguments are moved to `static readonly` fields or replaced with `ArrayOf<T>` collection expressions. In the legacy interop server I used locals instead, because those arrays become node values that writes can change in place. - CA2025: tasks that finish before disposal (`Assert.ThrowsAsync`, or awaited before `using` scope exit) are suppressed with justification comments, following existing test patterns. - CA1812: classes created by the DI container are suppressed with a comment and a TODO. - CA2208: benchmark switch defaults now throw `InvalidOperationException`. - CA1845: `Substring(0, 8)` is replaced with `[..8]`. - CA1307: `string.Replace` is replaced with `Split`/`Join`, which also works on net48. - CA5394: `Random` is replaced with `RandomNumberGenerator`. **Docs** - `docs/DeveloperGuide.md` now says CA warnings also fail the build, and that any suppression needs a comment explaining why plus a TODO. **Validation** - I fixed the 55 warnings from a net10.0 build of `UA.slnx` (`CustomTestTarget=net10.0`). That build ran before the setting was turned on, and I have not rebuilt net10.0 since the fixes. - `CustomTestTarget=net48` build of `UA.slnx`: 0 warnings, 0 errors. - I also started a full build across all target frameworks with the setting on. Its log showed no errors or warnings while it ran, but I couldn't read its final result. - No tests have been run yet; CI should confirm the multi-TFM build and the tests. ## Related Issues - N/A ## 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. --------- Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com> Co-authored-by: romanett <7413710+romanett@users.noreply.github.com> Co-authored-by: Marc Schier <marcschier@users.noreply.github.com>
144 lines
7.1 KiB
XML
144 lines
7.1 KiB
XML
<Project>
|
|
<PropertyGroup>
|
|
<Product>OPC UA .NET Standard Library</Product>
|
|
<RepositoryUrl>https://github.com/OPCFoundation/UA-.NETStandard</RepositoryUrl>
|
|
<VersionPrefix>2.0</VersionPrefix>
|
|
<VersionSuffix>preview-$([System.DateTime]::Now.ToString("yyyyMMdd"))</VersionSuffix>
|
|
<Copyright>Copyright © 2004-2025 OPC Foundation, Inc</Copyright>
|
|
<PackagePrefix>OPCFoundation.NetStandard</PackagePrefix>
|
|
<AssemblyPrefix>Opc.Ua</AssemblyPrefix>
|
|
<Company>OPC Foundation</Company>
|
|
<Authors>OPC Foundation</Authors>
|
|
<NeutralLanguage>en-US</NeutralLanguage>
|
|
<HighEntropyVA>true</HighEntropyVA>
|
|
<IsPackable>false</IsPackable>
|
|
<PlatformTarget>AnyCPU</PlatformTarget>
|
|
<TreatWarningsAsErrors>true</TreatWarningsAsErrors>
|
|
<ProduceReferenceAssembly>true</ProduceReferenceAssembly>
|
|
<LangVersion>14.0</LangVersion>
|
|
<!-- to enable package validation, uncomment here -->
|
|
<!--<EnablePackageValidation>true</EnablePackageValidation>-->
|
|
<!-- to check the package validation on a release build, uncomment here -->
|
|
<!--<PackageValidationBaselineVersion>1.5.374.27</PackageValidationBaselineVersion>-->
|
|
<!-- to regenerate the compatibility suppression file, uncomment here -->
|
|
<!--<GenerateCompatibilitySuppressionFile>true</GenerateCompatibilitySuppressionFile>-->
|
|
<NuGetAuditMode>all</NuGetAuditMode>
|
|
<NuGetAudit>true</NuGetAudit>
|
|
</PropertyGroup>
|
|
<PropertyGroup>
|
|
<AccelerateBuildsInVisualStudio>true</AccelerateBuildsInVisualStudio>
|
|
<EnableNETAnalyzers>true</EnableNETAnalyzers>
|
|
<RunAnalyzersDuringBuild Condition="'$(RunAnalyzersDuringBuild)' == ''">true</RunAnalyzersDuringBuild>
|
|
<CodeAnalysisTreatWarningsAsErrors>true</CodeAnalysisTreatWarningsAsErrors>
|
|
<AnalysisLevel>preview</AnalysisLevel>
|
|
<AnalysisMode>all</AnalysisMode>
|
|
<AnalysisModeStyle>default</AnalysisModeStyle>
|
|
</PropertyGroup>
|
|
<PropertyGroup Condition="'$(BuildingInsideVisualStudio)' == 'true'">
|
|
<EmitCompilerGeneratedFiles>true</EmitCompilerGeneratedFiles>
|
|
</PropertyGroup>
|
|
<ItemGroup Condition="'$(NoRoslynatorAnalzers)' == ''">
|
|
<PackageReference Include="Roslynator.Analyzers" PrivateAssets="All" />
|
|
<PackageReference Include="Roslynator.Formatting.Analyzers" PrivateAssets="All" />
|
|
</ItemGroup>
|
|
<PropertyGroup>
|
|
<NoWarn>$(NoWarn);NU1510</NoWarn>
|
|
<PackageIcon>images/logo.jpg</PackageIcon>
|
|
<PackageProjectUrl>$(RepositoryUrl)</PackageProjectUrl>
|
|
<PackageRequireLicenseAcceptance>true</PackageRequireLicenseAcceptance>
|
|
<!--
|
|
Every package ships the OPC Foundation MIT License 1.00 as a license
|
|
file. Do NOT replace this with
|
|
<PackageLicenseExpression>MIT</PackageLicenseExpression>: the SPDX `MIT`
|
|
license is a different text than the OPC Foundation one, and NuGet
|
|
rejects a project that carries both an expression and a license file
|
|
(NU5033). `Directory.Build.targets` enforces this.
|
|
-->
|
|
<PackageLicenseFile>LICENSE.txt</PackageLicenseFile>
|
|
<PackageReleaseNotes>$(RepositoryUrl)/releases</PackageReleaseNotes>
|
|
<!--
|
|
Every package ships its own package-local README (`NugetREADME.md`
|
|
next to the csproj, or the established `McpREADME.md` for the
|
|
command-line tool package). Per-package READMEs are wired in each
|
|
csproj via <PackageReadmeFile> + a matching <None Include=...
|
|
Pack="true">. A generic shared README at this `common.props`
|
|
level was deliberately removed in favor of per-package READMEs
|
|
because it was misleading on nuget.org (every package described
|
|
itself identically).
|
|
-->
|
|
<PackageTags>OPCFoundation OPC UA ios linux dotnet net netcore</PackageTags>
|
|
</PropertyGroup>
|
|
<PropertyGroup Condition="'$(SignAssembly)' == 'true'">
|
|
<!-- OPC Foundation public key -->
|
|
<PublicKey>0024000004800000940000000602000000240000</PublicKey>
|
|
<PublicKey>$(PublicKey)525341310004000001000100d987b12f068b3580</PublicKey>
|
|
<PublicKey>$(PublicKey)429f3dde01397508880fc7e62621397618456ca1</PublicKey>
|
|
<PublicKey>$(PublicKey)549aeacfbdb90c62adfe918f05ce3677b390f783</PublicKey>
|
|
<PublicKey>$(PublicKey)57b8745cb6e1334655afce1a9527ac92fc829ff5</PublicKey>
|
|
<PublicKey>$(PublicKey)85ea79f007e52ba0f83ead627e3edda40bec5ae5</PublicKey>
|
|
<PublicKey>$(PublicKey)74128fc9342cb57cb8285aa4e5b589c0ebef3be5</PublicKey>
|
|
<PublicKey>$(PublicKey)71b5c8f2ab1067f7c880e8f8882a73c80a12a1ef</PublicKey>
|
|
</PropertyGroup>
|
|
<Choose>
|
|
<When Condition="$([MSBuild]::IsTargetFrameworkCompatible('$(TargetFramework)', 'net5.0'))">
|
|
<PropertyGroup>
|
|
<!-- Disable strongname warning as that's not been enforced since .net 5.-->
|
|
<NoWarn>$(NoWarn);CS8002</NoWarn>
|
|
</PropertyGroup>
|
|
</When>
|
|
<Otherwise>
|
|
<PropertyGroup>
|
|
<!-- Disable nullable warning as it is not as meaningful on .net framework as on .net -->
|
|
<NoWarn>$(NoWarn);nullable</NoWarn>
|
|
</PropertyGroup>
|
|
</Otherwise>
|
|
</Choose>
|
|
<PropertyGroup Condition="'$(TargetFramework)' == 'net48'">
|
|
<!--
|
|
The Microsoft.Extensions.* graph used across the stack (Http.Resilience and
|
|
its transitive Telemetry / AmbientMetadata / Diagnostics packages) ships
|
|
net462 assets that build and run on .NET Framework, but their buildTransitive
|
|
support targets still emit "doesn't support net48" warnings. These are
|
|
benign on net462-compatible TFMs, so suppress them once here for all projects
|
|
instead of scattering per-project SuppressTfmSupportBuildWarnings blocks.
|
|
TODO: remove when the library matrix drops .NET Framework or the packages stop warning.
|
|
-->
|
|
<SuppressTfmSupportBuildWarnings>true</SuppressTfmSupportBuildWarnings>
|
|
</PropertyGroup>
|
|
<ItemGroup Condition="'$(IsPackable)' != 'false'">
|
|
<None
|
|
Include="$(MSBuildThisFileDirectory)/LICENSE.txt"
|
|
Pack="true"
|
|
PackagePath="$(PackageLicenseFile)"
|
|
/>
|
|
<None
|
|
Include="$(MSBuildThisFileDirectory)/nuget/logo.jpg"
|
|
Pack="true"
|
|
PackagePath="$(PackageIcon)"
|
|
/>
|
|
<!--
|
|
Each NuGet package owns its own package-local README -
|
|
`NugetREADME.md` next to the csproj, or the established
|
|
`McpREADME.md` for the command-line tool package. Each csproj
|
|
wires its README via <PackageReadmeFile> and packs the file at
|
|
the package root with
|
|
<None Include="..." Pack="true" PackagePath="\" />.
|
|
A generic shared README would be misleading on nuget.org because
|
|
every package would describe itself identically.
|
|
-->
|
|
</ItemGroup>
|
|
<ItemGroup Condition="'$(NBGV_PublicRelease)' != ''">
|
|
<PackageReference Include="Microsoft.SourceLink.GitHub" PrivateAssets="All" />
|
|
</ItemGroup>
|
|
<!-- Deterministic build is currently not supported for code coverage tests. -->
|
|
<PropertyGroup Condition="'$(CollectCoverage)' != 'true' AND ('$(TF_BUILD)' == 'true' OR '$(GITHUB_ACTIONS)' == 'true')">
|
|
<ContinuousIntegrationBuild>true</ContinuousIntegrationBuild>
|
|
</PropertyGroup>
|
|
<PropertyGroup>
|
|
<IncludeSymbols>true</IncludeSymbols>
|
|
<SymbolPackageFormat>snupkg</SymbolPackageFormat>
|
|
<PublishRepositoryUrl>true</PublishRepositoryUrl>
|
|
<EmbedUntrackedSources>true</EmbedUntrackedSources>
|
|
</PropertyGroup>
|
|
</Project>
|