From 751fe5658f51bc6f956a2796f66e4481582f7a37 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Thu, 19 Jun 2025 21:26:20 +0000 Subject: [PATCH 1/3] Bump Microsoft.OpenApi.OData and 3 others Bumps Microsoft.OpenApi.OData from 2.0.0-preview.15 to 2.0.0-preview9 Bumps System.CommandLine to 2.0.0-beta5.25306.1 Bumps System.CommandLine.Hosting from 0.4.0-alpha.22272.1 to 0.4.0-alpha.25306.1 Bumps System.Text.Json to 9.0.6 --- updated-dependencies: - dependency-name: Microsoft.OpenApi.OData dependency-version: 2.0.0-preview9 dependency-type: direct:production update-type: version-update:semver-patch - dependency-name: System.CommandLine dependency-version: 2.0.0-beta5.25306.1 dependency-type: direct:production update-type: version-update:semver-patch - dependency-name: System.CommandLine dependency-version: 2.0.0-beta5.25306.1 dependency-type: direct:production update-type: version-update:semver-patch - dependency-name: System.CommandLine.Hosting dependency-version: 0.4.0-alpha.25306.1 dependency-type: direct:production update-type: version-update:semver-patch - dependency-name: System.Text.Json dependency-version: 9.0.6 dependency-type: direct:production update-type: version-update:semver-major - dependency-name: System.Text.Json dependency-version: 9.0.6 dependency-type: direct:production update-type: version-update:semver-major ... Signed-off-by: dependabot[bot] --- performance/resultsComparer/resultsComparer.csproj | 2 +- src/Microsoft.OpenApi.Hidi/Microsoft.OpenApi.Hidi.csproj | 6 +++--- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/performance/resultsComparer/resultsComparer.csproj b/performance/resultsComparer/resultsComparer.csproj index d42ecb451..294fcc217 100644 --- a/performance/resultsComparer/resultsComparer.csproj +++ b/performance/resultsComparer/resultsComparer.csproj @@ -12,7 +12,7 @@ - + diff --git a/src/Microsoft.OpenApi.Hidi/Microsoft.OpenApi.Hidi.csproj b/src/Microsoft.OpenApi.Hidi/Microsoft.OpenApi.Hidi.csproj index 5049653fe..4a884926b 100644 --- a/src/Microsoft.OpenApi.Hidi/Microsoft.OpenApi.Hidi.csproj +++ b/src/Microsoft.OpenApi.Hidi/Microsoft.OpenApi.Hidi.csproj @@ -36,11 +36,11 @@ runtime; build; native; contentfiles; analyzers; buildtransitive all - + - + - + From d49d0aebf95ba6d97af7f7d9f3ce22c868ddb4d4 Mon Sep 17 00:00:00 2001 From: Vincent Biret Date: Fri, 20 Jun 2025 07:50:02 -0400 Subject: [PATCH 2/3] chore: reverts yoko upgrade --- src/Microsoft.OpenApi.Hidi/Microsoft.OpenApi.Hidi.csproj | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Microsoft.OpenApi.Hidi/Microsoft.OpenApi.Hidi.csproj b/src/Microsoft.OpenApi.Hidi/Microsoft.OpenApi.Hidi.csproj index 4a884926b..44692376c 100644 --- a/src/Microsoft.OpenApi.Hidi/Microsoft.OpenApi.Hidi.csproj +++ b/src/Microsoft.OpenApi.Hidi/Microsoft.OpenApi.Hidi.csproj @@ -38,7 +38,7 @@ - + From a5f8721a18e93ee881cfee371ba6d23ce0c55ae4 Mon Sep 17 00:00:00 2001 From: Vincent Biret Date: Mon, 30 Jun 2025 09:14:55 -0400 Subject: [PATCH 3/3] fix: migration of hidi to the latest version of system.commandline Signed-off-by: Vincent Biret --- performance/resultsComparer/Program.cs | 38 +++-- .../handlers/AsyncCommandHandler.cs | 14 -- .../handlers/CompareCommandHandler.cs | 24 ++- .../Extensions/CommandExtensions.cs | 2 +- .../Handlers/AsyncCommandHandler.cs | 14 -- .../Handlers/PluginCommandHandler.cs | 9 +- .../Handlers/ShowCommandHandler.cs | 9 +- .../Handlers/TransformCommandHandler.cs | 9 +- .../Handlers/ValidateCommandHandler.cs | 9 +- .../Options/CommandOptions.cs | 139 +++++++++++------- .../Options/HidiOptions.cs | 38 ++--- src/Microsoft.OpenApi.Hidi/Program.cs | 15 +- .../Services/OpenApiServiceTests.cs | 15 +- 13 files changed, 182 insertions(+), 153 deletions(-) delete mode 100644 performance/resultsComparer/handlers/AsyncCommandHandler.cs delete mode 100644 src/Microsoft.OpenApi.Hidi/Handlers/AsyncCommandHandler.cs diff --git a/performance/resultsComparer/Program.cs b/performance/resultsComparer/Program.cs index 1c6fb7bc2..9d3c0f871 100644 --- a/performance/resultsComparer/Program.cs +++ b/performance/resultsComparer/Program.cs @@ -11,7 +11,8 @@ public class Program public static async Task Main(string[] args) { var rootCommand = CreateRootCommand(); - return await rootCommand.InvokeAsync(args); + var parseResult = rootCommand.Parse(args); + return await parseResult.InvokeAsync(); } internal static RootCommand CreateRootCommand() { @@ -21,25 +22,40 @@ internal static RootCommand CreateRootCommand() { Description = "Compare the benchmark results." }; - var oldResultsPathArgument = new Argument("existingReportPath", () => ExistingReportPath, "The path to the existing benchmark report."); - compareCommand.AddArgument(oldResultsPathArgument); - var newResultsPathArgument = new Argument("newReportPath", () => ExistingReportPath, "The path to the new benchmark report."); - compareCommand.AddArgument(newResultsPathArgument); - var logLevelOption = new Option(["--log-level", "-l"], () => LogLevel.Warning, "The log level to use."); - compareCommand.AddOption(logLevelOption); + var oldResultsPathArgument = new Argument("existingReportPath") + { + DefaultValueFactory = (_) => ExistingReportPath, + Description = "The path to the existing benchmark report.", + }; + compareCommand.Arguments.Add(oldResultsPathArgument); + var newResultsPathArgument = new Argument("newReportPath") + { + DefaultValueFactory = (_) => ExistingReportPath, + Description = "The path to the new benchmark report.", + }; + compareCommand.Arguments.Add(newResultsPathArgument); + var logLevelOption = new Option("--log-level", "-l") + { + DefaultValueFactory = (_) => LogLevel.Warning, + Description = "The log level to use.", + }; + compareCommand.Options.Add(logLevelOption); var allPolicyNames = IBenchmarkComparisonPolicy.GetAllPolicies().Select(static p => p.Name).Order(StringComparer.OrdinalIgnoreCase).ToArray(); - var policiesOption = new Option(["--policies", "-p"], () => ["all"], $"The policies to use for comparison: {string.Join(',', allPolicyNames)}.") + var policiesOption = new Option("--policies", "-p") { - Arity = ArgumentArity.ZeroOrMore + Arity = ArgumentArity.ZeroOrMore, + DefaultValueFactory = (_) => ["all"], + Description = $"The policies to use for comparison: {string.Join(',', allPolicyNames)}.", }; - compareCommand.AddOption(policiesOption); - compareCommand.Handler = new CompareCommandHandler + compareCommand.Options.Add(policiesOption); + var compareCommandHandler = new CompareCommandHandler { OldResultsPath = oldResultsPathArgument, NewResultsPath = newResultsPathArgument, LogLevel = logLevelOption, Policies = policiesOption, }; + compareCommand.SetAction(compareCommandHandler.InvokeAsync); rootCommand.Add(compareCommand); return rootCommand; } diff --git a/performance/resultsComparer/handlers/AsyncCommandHandler.cs b/performance/resultsComparer/handlers/AsyncCommandHandler.cs deleted file mode 100644 index f4c65b566..000000000 --- a/performance/resultsComparer/handlers/AsyncCommandHandler.cs +++ /dev/null @@ -1,14 +0,0 @@ -using System; -using System.CommandLine.Invocation; -using System.Threading.Tasks; - -namespace resultsComparer.Handlers; - -internal abstract class AsyncCommandHandler : ICommandHandler -{ - public int Invoke(InvocationContext context) - { - throw new InvalidOperationException("This method should not be called"); - } - public abstract Task InvokeAsync(InvocationContext context); -} diff --git a/performance/resultsComparer/handlers/CompareCommandHandler.cs b/performance/resultsComparer/handlers/CompareCommandHandler.cs index ed079953e..1565fdf77 100644 --- a/performance/resultsComparer/handlers/CompareCommandHandler.cs +++ b/performance/resultsComparer/handlers/CompareCommandHandler.cs @@ -3,30 +3,38 @@ using System.CommandLine.Invocation; using System.Text.Json; using System.Text.Json.Serialization; -using Microsoft.Extensions.DependencyInjection; using Microsoft.Extensions.Logging; using resultsComparer.Models; using resultsComparer.Policies; namespace resultsComparer.Handlers; -internal class CompareCommandHandler : AsyncCommandHandler +internal class CompareCommandHandler : AsynchronousCommandLineAction { public required Argument OldResultsPath { get; set; } public required Argument NewResultsPath { get; set; } public required Option LogLevel { get; set; } public required Option Policies { get; set; } - public override Task InvokeAsync(InvocationContext context) + public override Task InvokeAsync(ParseResult parseResult, CancellationToken cancellationToken = default) { - var cancellationToken = context.BindingContext.GetRequiredService(); - var oldResultsPath = context.ParseResult.GetValueForArgument(OldResultsPath); - var newResultsPath = context.ParseResult.GetValueForArgument(NewResultsPath); - var policyNames = context.ParseResult.GetValueForOption(Policies) ?? []; + var oldResultsPath = parseResult.GetValue(OldResultsPath); + var newResultsPath = parseResult.GetValue(NewResultsPath); + var policyNames = parseResult.GetValue(Policies) ?? []; var policies = IBenchmarkComparisonPolicy.GetSelectedPolicies(policyNames).ToArray(); - var logLevel = context.ParseResult.GetValueForOption(LogLevel); + var logLevel = parseResult.GetValue(LogLevel); using var loggerFactory = Logger.ConfigureLogger(logLevel); var logger = loggerFactory.CreateLogger(); + if (string.IsNullOrWhiteSpace(oldResultsPath)) + { + logger.LogError("Old results path is required."); + return Task.FromResult(1); + } + if (string.IsNullOrWhiteSpace(newResultsPath)) + { + logger.LogError("New results path is required."); + return Task.FromResult(1); + } return CompareResultsAsync(oldResultsPath, newResultsPath, logger, policies, cancellationToken); } private static async Task CompareResultsAsync(string existingReportPath, string newReportPath, ILogger logger, IBenchmarkComparisonPolicy[] comparisonPolicies, CancellationToken cancellationToken = default) diff --git a/src/Microsoft.OpenApi.Hidi/Extensions/CommandExtensions.cs b/src/Microsoft.OpenApi.Hidi/Extensions/CommandExtensions.cs index 5b83212d5..1a2dc477d 100644 --- a/src/Microsoft.OpenApi.Hidi/Extensions/CommandExtensions.cs +++ b/src/Microsoft.OpenApi.Hidi/Extensions/CommandExtensions.cs @@ -12,7 +12,7 @@ public static void AddOptions(this Command command, IReadOnlyList