Phase 0 — mechanical rename ZB.MOM.WW.LmxOpcUa.* → ZB.MOM.WW.OtOpcUa.*

Renames all 11 projects (5 src + 6 tests), the .slnx solution file, all source-file namespaces, all axaml namespace references, and all v1 documentation references in CLAUDE.md and docs/*.md (excluding docs/v2/ which is already in OtOpcUa form). Also updates the TopShelf service registration name from "LmxOpcUa" to "OtOpcUa" per Phase 0 Task 0.6.

Preserves runtime identifiers per Phase 0 Out-of-Scope rules to avoid breaking v1/v2 client trust during coexistence: OPC UA `ApplicationUri` defaults (`urn:{GalaxyName}:LmxOpcUa`), server `EndpointPath` (`/LmxOpcUa`), `ServerName` default (feeds cert subject CN), `MxAccessConfiguration.ClientName` default (defensive — stays "LmxOpcUa" for MxAccess audit-trail consistency), client OPC UA identifiers (`ApplicationName = "LmxOpcUaClient"`, `ApplicationUri = "urn:localhost:LmxOpcUaClient"`, cert directory `%LocalAppData%\LmxOpcUaClient\pki\`), and the `LmxOpcUaServer` class name (class rename out of Phase 0 scope per Task 0.5 sed pattern; happens in Phase 1 alongside `LmxNodeManager → GenericDriverNodeManager` Core extraction). 23 LmxOpcUa references retained, all enumerated and justified in `docs/v2/implementation/exit-gate-phase-0.md`.

Build clean: 0 errors, 30 warnings (lower than baseline 167). Tests at strict improvement over baseline: 821 passing / 1 failing vs baseline 820 / 2 (one flaky pre-existing failure passed this run; the other still fails — both pre-existing and unrelated to the rename). `Client.UI.Tests`, `Historian.Aveva.Tests`, `Client.Shared.Tests`, `IntegrationTests` all match baseline exactly. Exit gate compliance results recorded in `docs/v2/implementation/exit-gate-phase-0.md` with all 7 checks PASS or DEFERRED-to-PR-review (#7 service install verification needs Windows service permissions on the reviewer's box).

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
This commit is contained in:
Joseph Doherty
2026-04-17 13:57:47 -04:00
parent 5b8d708c58
commit 3b2defd94f
293 changed files with 841 additions and 722 deletions

View File

@@ -0,0 +1,124 @@
using CliFx;
using CliFx.Attributes;
using CliFx.Infrastructure;
using Serilog;
using ZB.MOM.WW.OtOpcUa.Client.Shared;
using ZB.MOM.WW.OtOpcUa.Client.Shared.Helpers;
using ZB.MOM.WW.OtOpcUa.Client.Shared.Models;
namespace ZB.MOM.WW.OtOpcUa.Client.CLI;
/// <summary>
/// Abstract base class for all CLI commands providing common connection options and helpers.
/// </summary>
public abstract class CommandBase : ICommand
{
internal static readonly IOpcUaClientServiceFactory DefaultFactory = new OpcUaClientServiceFactory();
private readonly IOpcUaClientServiceFactory _factory;
/// <summary>
/// Initializes a CLI command with the shared OPC UA client factory used to create per-command sessions.
/// </summary>
/// <param name="factory">The factory that creates the shared client service for the command execution.</param>
protected CommandBase(IOpcUaClientServiceFactory factory)
{
_factory = factory;
}
/// <summary>
/// Gets the primary OPC UA endpoint URL the command should connect to.
/// </summary>
[CommandOption("url", 'u', Description = "OPC UA server endpoint URL", IsRequired = true)]
public string Url { get; init; } = default!;
/// <summary>
/// Gets the optional username used for authenticated OPC UA sessions.
/// </summary>
[CommandOption("username", 'U', Description = "Username for authentication")]
public string? Username { get; init; }
/// <summary>
/// Gets the optional password paired with <see cref="Username" /> for authenticated OPC UA sessions.
/// </summary>
[CommandOption("password", 'P', Description = "Password for authentication")]
public string? Password { get; init; }
/// <summary>
/// Gets the transport security mode requested by the operator for this CLI session.
/// </summary>
[CommandOption("security", 'S',
Description = "Transport security: none, sign, encrypt, signandencrypt (default: none)")]
public string Security { get; init; } = "none";
/// <summary>
/// Gets the optional comma-separated failover endpoints that should be tried if the primary endpoint is unavailable.
/// </summary>
[CommandOption("failover-urls", 'F', Description = "Comma-separated failover endpoint URLs for redundancy")]
public string? FailoverUrls { get; init; }
/// <summary>
/// Gets a value indicating whether verbose Serilog output should be enabled for troubleshooting.
/// </summary>
[CommandOption("verbose", Description = "Enable verbose/debug logging")]
public bool Verbose { get; init; }
/// <summary>
/// Executes the command-specific workflow against the configured OPC UA endpoint.
/// </summary>
/// <param name="console">The CLI console used for output and cancellation handling.</param>
public abstract ValueTask ExecuteAsync(IConsole console);
/// <summary>
/// Creates a <see cref="ConnectionSettings" /> from the common command options.
/// </summary>
protected ConnectionSettings CreateConnectionSettings()
{
var securityMode = SecurityModeMapper.FromString(Security);
var failoverUrls = !string.IsNullOrWhiteSpace(FailoverUrls)
? FailoverUrlParser.Parse(Url, FailoverUrls)
: null;
var settings = new ConnectionSettings
{
EndpointUrl = Url,
FailoverUrls = failoverUrls,
Username = Username,
Password = Password,
SecurityMode = securityMode,
AutoAcceptCertificates = true
};
return settings;
}
/// <summary>
/// Creates a new <see cref="IOpcUaClientService" />, connects it using the common options,
/// and returns both the service and the connection info.
/// </summary>
/// <param name="ct">The cancellation token that aborts connection setup for the command.</param>
protected async Task<(IOpcUaClientService Service, ConnectionInfo Info)> CreateServiceAndConnectAsync(
CancellationToken ct)
{
var service = _factory.Create();
var settings = CreateConnectionSettings();
var info = await service.ConnectAsync(settings, ct);
return (service, info);
}
/// <summary>
/// Configures Serilog based on the verbose flag.
/// </summary>
protected void ConfigureLogging()
{
var config = new LoggerConfiguration();
if (Verbose)
config.MinimumLevel.Debug()
.WriteTo.Console();
else
config.MinimumLevel.Warning()
.WriteTo.Console();
Log.Logger = config.CreateLogger();
}
}