Files
UA-.NETStandard/tools/Opc.Ua.MigrationAnalyzer.Generator/Diagnostics/GeneratorDiagnostics.cs
Marc SchierandCopilot 7fe8b30cc3 Publish migration plugin marketplace and update NuGet dependencies (#4358)
# Description

- Replace the Azure DevOps continuous-preview feed with the GitHub
Packages
NuGet feed, including its classic PAT `read:packages` requirement, while
  retaining nuget.org for official public 2.0 preview releases.
- Document one-shot MCP execution with `dotnet tool exec` and `dnx`.
- Make this repository registerable as the `opcua-dotnet` Copilot
marketplace
  and package `opcua-v20-migration` as an installable plugin.
- Bundle the 15 thematic migration documents for offline plugin use and
add a
  CI check that keeps the bundle and marketplace metadata synchronized.
- Align the migration analyzer guidance with current master, including
the new
`UA0030` analyzer while retaining `UA0029` as a runtime-shim-only marker
with
  reserved diagnostic metadata.
- Restrict generated collection-shim type discovery to consumer source
declarations before the exact `System.<Type>` / `Opc.Ua.<Type>` metadata
  fallback, with regression coverage for dependency-only metadata.
- Update 52 unpinned NuGet package IDs across 60 central entries, plus
two
  schema-test overrides, while preserving documented compatibility and
  security pins.

## Related Issues

- Fixes #4330

## Validation

- `dotnet build UA.slnx -c Release --no-restore`: 0 warnings, 0 errors.
- Migration analyzer tests across net472, net48, net8.0, net9.0, and
net10.0:
  795 passed, 0 failed, 0 skipped.
- The migration plugin bundle, manifests, PowerShell, XML, links, and
isolated
  marketplace installation validate successfully.
- The direct and transitive NuGet vulnerability audit reports no known
  vulnerabilities.
- A full solution test run was completed before merging current master.
Its
remaining failures were existing locale, path-length, GPU, shared-state,
and
flaky integration failures. Persistent cases reproduced on the
pre-update
commit, while isolated reruns cleared the dependency-relevant Core, GDS,
  Sessions, Subscriptions, and durable-queue failures.

## 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.
- [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: e0ecb0e9-e5ef-4b2f-9922-41a7d42b0372
2026-08-31 19:42:24 +00:00

76 lines
3.9 KiB
C#

/* ========================================================================
* Copyright (c) 2005-2025 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 Microsoft.CodeAnalysis;
namespace Opc.Ua.MigrationAnalyzer.Generator
{
/// <summary>
/// Diagnostic descriptors emitted by <see cref="MigrationGenerator"/>.
/// </summary>
/// <remarks>
/// These ids use the <c>MIG</c> prefix to distinguish them from the analyzer's
/// <c>UA00xx</c> rules. Today the generator emits exactly one diagnostic; the
/// surface is centralized so future generator-time hints can land here without
/// touching the main pipeline.
/// </remarks>
internal static class GeneratorDiagnostics
{
public const string Category = "OpcUa.Migration";
/// <summary>
/// MIG01 — fires when the generator detects an unresolvable
/// <c>&lt;Foo&gt;Collection</c> identifier and cannot find a unique element
/// type <c>Foo</c> in the consumer's source declarations or the supported
/// standard metadata namespaces. The user is told to migrate the site
/// manually or define the wrapper explicitly.
/// </summary>
public static readonly DiagnosticDescriptor UnresolvableElementType = new(
id: "MIG01",
title: "Cannot resolve collection element type for migration shim",
messageFormat: "Cannot resolve a unique element type '{0}' for legacy wrapper '{1}'. " +
"The generator discovers consumer source declarations plus exact System.<Type> " +
"or Opc.Ua.<Type> metadata names only. Migrate the reference manually to the " +
"intended List<T> / ArrayOf<T>, or define the wrapper type explicitly.",
category: Category,
defaultSeverity: DiagnosticSeverity.Warning,
isEnabledByDefault: true,
description: "The OPC UA migration source generator emits a public " +
"[Obsolete] shim subclass of List<T> for every legacy <Type>Collection " +
"wrapper the consumer references. It resolves consumer source declarations " +
"by short name and metadata types named exactly System.<Type> or Opc.Ua.<Type>. " +
"When the element type can't be uniquely resolved, the shim cannot be synthesized.",
helpLinkUri:
"https://github.com/OPCFoundation/UA-.NETStandard/blob/master/" +
"docs/migrate/2.0.x/source-generation.md" +
"#mig01-resolution-playbook",
customTags: WellKnownDiagnosticTags.Telemetry);
}
}