From 55540d7fff2abd91cc4fa4917fd50004621bf6e1 Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Mon, 19 Jan 2026 10:10:42 +0000 Subject: [PATCH 1/5] Initial plan From 9b0c4d6d9bd4f7c024deb828e5463345b2a16173 Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Mon, 19 Jan 2026 10:17:33 +0000 Subject: [PATCH 2/5] Add version command implementation with tests Co-authored-by: sbouchexbellomie-Philips <182072604+sbouchexbellomie-Philips@users.noreply.github.com> --- .../Commands/VersionCommandTests.cs | 37 +++++++++++ .../MigrationTools.Host.Tests.csproj | 3 + .../Commands/VersionCommand.cs | 62 +++++++++++++++++++ .../Commands/VersionCommandSettings.cs | 9 +++ src/MigrationTools.Host/MigrationToolHost.cs | 4 ++ 5 files changed, 115 insertions(+) create mode 100644 src/MigrationTools.Host.Tests/Commands/VersionCommandTests.cs create mode 100644 src/MigrationTools.Host/Commands/VersionCommand.cs create mode 100644 src/MigrationTools.Host/Commands/VersionCommandSettings.cs diff --git a/src/MigrationTools.Host.Tests/Commands/VersionCommandTests.cs b/src/MigrationTools.Host.Tests/Commands/VersionCommandTests.cs new file mode 100644 index 000000000..8265c5cc3 --- /dev/null +++ b/src/MigrationTools.Host.Tests/Commands/VersionCommandTests.cs @@ -0,0 +1,37 @@ +using Microsoft.Extensions.DependencyInjection; +using Microsoft.Extensions.Hosting; +using Microsoft.VisualStudio.TestTools.UnitTesting; +using MigrationTools.Services; + +namespace MigrationTools.Host.Tests.Commands +{ + [TestClass()] + public class VersionCommandTests + { + private IHost host; + + [TestInitialize] + public void Setup() + { + host = MigrationToolHost.CreateDefaultBuilder(new string[] { "version", "--skipVersionCheck" }).Build(); + } + + [TestMethod, TestCategory("L0")] + public void VersionCommand_ServiceResolution_ShouldSucceed() + { + // Verify that all required services can be resolved + var migrationToolVersion = host.Services.GetRequiredService(); + Assert.IsNotNull(migrationToolVersion); + } + + [TestMethod, TestCategory("L0")] + public void VersionCommand_GetRunningVersion_ShouldReturnVersionInfo() + { + var migrationToolVersion = host.Services.GetRequiredService(); + var versionInfo = migrationToolVersion.GetRunningVersion(); + + Assert.IsNotNull(versionInfo); + Assert.IsNotNull(versionInfo.versionString); + } + } +} diff --git a/src/MigrationTools.Host.Tests/MigrationTools.Host.Tests.csproj b/src/MigrationTools.Host.Tests/MigrationTools.Host.Tests.csproj index de59101b0..a89ebf66e 100644 --- a/src/MigrationTools.Host.Tests/MigrationTools.Host.Tests.csproj +++ b/src/MigrationTools.Host.Tests/MigrationTools.Host.Tests.csproj @@ -9,6 +9,9 @@ Always + + Always + diff --git a/src/MigrationTools.Host/Commands/VersionCommand.cs b/src/MigrationTools.Host/Commands/VersionCommand.cs new file mode 100644 index 000000000..f9c7d2427 --- /dev/null +++ b/src/MigrationTools.Host/Commands/VersionCommand.cs @@ -0,0 +1,62 @@ +using System; +using System.Diagnostics; +using System.Threading.Tasks; +using Microsoft.Extensions.Configuration; +using Microsoft.Extensions.Hosting; +using Microsoft.Extensions.Logging; +using MigrationTools.Host.Services; +using MigrationTools.Services; +using OpenTelemetry.Trace; +using Serilog; +using Spectre.Console; +using Spectre.Console.Cli; + +namespace MigrationTools.Host.Commands +{ + internal class VersionCommand : CommandBase + { + private readonly IMigrationToolVersion _migrationToolVersion; + private readonly ILogger> _logger; + + public VersionCommand( + IHostApplicationLifetime appLifetime, + IServiceProvider services, + IDetectOnlineService detectOnlineService, + IDetectVersionService2 detectVersionService, + ILogger> logger, + ITelemetryLogger telemetryLogger, + IMigrationToolVersion migrationToolVersion, + IConfiguration configuration, + ActivitySource activitySource) + : base(appLifetime, services, detectOnlineService, detectVersionService, logger, telemetryLogger, migrationToolVersion, configuration, activitySource) + { + _migrationToolVersion = migrationToolVersion; + _logger = logger; + } + + internal override Task ExecuteInternalAsync(CommandContext context, VersionCommandSettings settings) + { + try + { + var versionInfo = _migrationToolVersion.GetRunningVersion(); + + AnsiConsole.MarkupLine($"[bold cyan]Version:[/] {versionInfo.versionString}"); + + if (versionInfo.version.Major == 0) + { + AnsiConsole.MarkupLine($"[dim]Git Tag:[/] {ThisAssembly.Git.Tag}"); + AnsiConsole.MarkupLine($"[dim]Git Branch:[/] {ThisAssembly.Git.Branch}"); + AnsiConsole.MarkupLine($"[dim]Git Commits:[/] {ThisAssembly.Git.Commits}"); + } + + return Task.FromResult(0); + } + catch (Exception ex) + { + CommandActivity.RecordException(ex); + _logger.LogError(ex, "Error displaying version information"); + return Task.FromResult(1); + } + } + } +} diff --git a/src/MigrationTools.Host/Commands/VersionCommandSettings.cs b/src/MigrationTools.Host/Commands/VersionCommandSettings.cs new file mode 100644 index 000000000..ff774deb4 --- /dev/null +++ b/src/MigrationTools.Host/Commands/VersionCommandSettings.cs @@ -0,0 +1,9 @@ +using System.ComponentModel; +using Spectre.Console.Cli; + +namespace MigrationTools.Host.Commands +{ + internal class VersionCommandSettings : CommandSettingsBase + { + } +} diff --git a/src/MigrationTools.Host/MigrationToolHost.cs b/src/MigrationTools.Host/MigrationToolHost.cs index 61fa0a045..d6dc0b314 100644 --- a/src/MigrationTools.Host/MigrationToolHost.cs +++ b/src/MigrationTools.Host/MigrationToolHost.cs @@ -125,6 +125,10 @@ public static IHostBuilder CreateDefaultBuilder(string[] args, Action("version") + .WithDescription("Displays the version of the tool") + .WithExample("version"); + extraCommands?.Invoke(config); config.PropagateExceptions(); }); From 92f437444f0fc2f0a641e249f08ce5061a7b8345 Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Mon, 19 Jan 2026 10:20:08 +0000 Subject: [PATCH 3/5] Address code review feedback - remove unused logger field and add test cleanup Co-authored-by: sbouchexbellomie-Philips <182072604+sbouchexbellomie-Philips@users.noreply.github.com> --- .../Commands/VersionCommandTests.cs | 6 ++++++ src/MigrationTools.Host/Commands/VersionCommand.cs | 3 --- 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/src/MigrationTools.Host.Tests/Commands/VersionCommandTests.cs b/src/MigrationTools.Host.Tests/Commands/VersionCommandTests.cs index 8265c5cc3..43aa6bb06 100644 --- a/src/MigrationTools.Host.Tests/Commands/VersionCommandTests.cs +++ b/src/MigrationTools.Host.Tests/Commands/VersionCommandTests.cs @@ -16,6 +16,12 @@ public void Setup() host = MigrationToolHost.CreateDefaultBuilder(new string[] { "version", "--skipVersionCheck" }).Build(); } + [TestCleanup] + public void Cleanup() + { + host?.Dispose(); + } + [TestMethod, TestCategory("L0")] public void VersionCommand_ServiceResolution_ShouldSucceed() { diff --git a/src/MigrationTools.Host/Commands/VersionCommand.cs b/src/MigrationTools.Host/Commands/VersionCommand.cs index f9c7d2427..16e5a0d27 100644 --- a/src/MigrationTools.Host/Commands/VersionCommand.cs +++ b/src/MigrationTools.Host/Commands/VersionCommand.cs @@ -16,7 +16,6 @@ namespace MigrationTools.Host.Commands internal class VersionCommand : CommandBase { private readonly IMigrationToolVersion _migrationToolVersion; - private readonly ILogger> _logger; public VersionCommand( IHostApplicationLifetime appLifetime, @@ -31,7 +30,6 @@ public VersionCommand( : base(appLifetime, services, detectOnlineService, detectVersionService, logger, telemetryLogger, migrationToolVersion, configuration, activitySource) { _migrationToolVersion = migrationToolVersion; - _logger = logger; } internal override Task ExecuteInternalAsync(CommandContext context, VersionCommandSettings settings) @@ -54,7 +52,6 @@ internal override Task ExecuteInternalAsync(CommandContext context, Version catch (Exception ex) { CommandActivity.RecordException(ex); - _logger.LogError(ex, "Error displaying version information"); return Task.FromResult(1); } } From 792f1dfa984c586c4ed3f5e358d7b1c62f2b07f5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?S=C3=A9bastien=20Bouchex=20Bellomi=C3=A9?= Date: Mon, 19 Jan 2026 11:26:03 +0100 Subject: [PATCH 4/5] Fixed typo --- src/MigrationTools.Host/Commands/CommandBase.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/MigrationTools.Host/Commands/CommandBase.cs b/src/MigrationTools.Host/Commands/CommandBase.cs index c7f52db8f..e385b8c64 100644 --- a/src/MigrationTools.Host/Commands/CommandBase.cs +++ b/src/MigrationTools.Host/Commands/CommandBase.cs @@ -120,7 +120,7 @@ public void RunStartupLogic(TSettings settings) Log.Debug(" IsRunningInDebug: {IsRunningInDebug}", _detectVersionService.IsRunningInDebug); Log.Verbose("Full version data: ${_detectVersionService}", _detectVersionService); - Log.Information("Verion Info:"); + Log.Information("Version Info:"); Log.Information(" Running: {RunningVersion}", _detectVersionService.RunningVersion); Log.Information(" Installed: {InstalledVersion}", _detectVersionService.InstalledVersion); Log.Information(" Available: {AvailableVersion}", _detectVersionService.AvailableVersion); From 00781392406177414f4d63c7850cd13b7db5f45e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?S=C3=A9bastien=20Bouchex=20Bellomi=C3=A9?= Date: Mon, 19 Jan 2026 11:44:22 +0100 Subject: [PATCH 5/5] adress comments --- .../Commands/VersionCommand.cs | 37 +++++++------------ 1 file changed, 14 insertions(+), 23 deletions(-) diff --git a/src/MigrationTools.Host/Commands/VersionCommand.cs b/src/MigrationTools.Host/Commands/VersionCommand.cs index 16e5a0d27..d450fbb3b 100644 --- a/src/MigrationTools.Host/Commands/VersionCommand.cs +++ b/src/MigrationTools.Host/Commands/VersionCommand.cs @@ -1,4 +1,4 @@ -using System; +using System; using System.Diagnostics; using System.Threading.Tasks; using Microsoft.Extensions.Configuration; @@ -6,8 +6,6 @@ using Microsoft.Extensions.Logging; using MigrationTools.Host.Services; using MigrationTools.Services; -using OpenTelemetry.Trace; -using Serilog; using Spectre.Console; using Spectre.Console.Cli; @@ -26,34 +24,27 @@ public VersionCommand( ITelemetryLogger telemetryLogger, IMigrationToolVersion migrationToolVersion, IConfiguration configuration, - ActivitySource activitySource) - : base(appLifetime, services, detectOnlineService, detectVersionService, logger, telemetryLogger, migrationToolVersion, configuration, activitySource) + ActivitySource activitySource) + : base(appLifetime, services, detectOnlineService, detectVersionService, logger, telemetryLogger, + migrationToolVersion, configuration, activitySource) { _migrationToolVersion = migrationToolVersion; } internal override Task ExecuteInternalAsync(CommandContext context, VersionCommandSettings settings) { - try - { - var versionInfo = _migrationToolVersion.GetRunningVersion(); - - AnsiConsole.MarkupLine($"[bold cyan]Version:[/] {versionInfo.versionString}"); - - if (versionInfo.version.Major == 0) - { - AnsiConsole.MarkupLine($"[dim]Git Tag:[/] {ThisAssembly.Git.Tag}"); - AnsiConsole.MarkupLine($"[dim]Git Branch:[/] {ThisAssembly.Git.Branch}"); - AnsiConsole.MarkupLine($"[dim]Git Commits:[/] {ThisAssembly.Git.Commits}"); - } - - return Task.FromResult(0); - } - catch (Exception ex) + var versionInfo = _migrationToolVersion.GetRunningVersion(); + + AnsiConsole.MarkupLine($"[bold cyan]Version:[/] {Markup.Escape(versionInfo.versionString)}"); + + if (versionInfo.version.Major == 0) { - CommandActivity.RecordException(ex); - return Task.FromResult(1); + AnsiConsole.MarkupLine($"[dim]Git Tag:[/] {Markup.Escape(ThisAssembly.Git.Tag)}"); + AnsiConsole.MarkupLine($"[dim]Git Branch:[/] {Markup.Escape(ThisAssembly.Git.Branch)}"); + AnsiConsole.MarkupLine($"[dim]Git Commits:[/] {Markup.Escape(ThisAssembly.Git.Commits)}"); } + + return Task.FromResult(0); } } }