Skip to content

Commit f278faf

Browse files
authored
Merge pull request #2410 from microsoft/dependabot/nuget/performance/resultsComparer/multi-51f7fe1af4
Bump Microsoft.OpenApi.OData and 3 others
2 parents 09f661f + a5f8721 commit f278faf

File tree

15 files changed

+185
-156
lines changed

15 files changed

+185
-156
lines changed

performance/resultsComparer/Program.cs

Lines changed: 27 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,8 @@ public class Program
1111
public static async Task<int> Main(string[] args)
1212
{
1313
var rootCommand = CreateRootCommand();
14-
return await rootCommand.InvokeAsync(args);
14+
var parseResult = rootCommand.Parse(args);
15+
return await parseResult.InvokeAsync();
1516
}
1617
internal static RootCommand CreateRootCommand()
1718
{
@@ -21,25 +22,40 @@ internal static RootCommand CreateRootCommand()
2122
{
2223
Description = "Compare the benchmark results."
2324
};
24-
var oldResultsPathArgument = new Argument<string>("existingReportPath", () => ExistingReportPath, "The path to the existing benchmark report.");
25-
compareCommand.AddArgument(oldResultsPathArgument);
26-
var newResultsPathArgument = new Argument<string>("newReportPath", () => ExistingReportPath, "The path to the new benchmark report.");
27-
compareCommand.AddArgument(newResultsPathArgument);
28-
var logLevelOption = new Option<LogLevel>(["--log-level", "-l"], () => LogLevel.Warning, "The log level to use.");
29-
compareCommand.AddOption(logLevelOption);
25+
var oldResultsPathArgument = new Argument<string>("existingReportPath")
26+
{
27+
DefaultValueFactory = (_) => ExistingReportPath,
28+
Description = "The path to the existing benchmark report.",
29+
};
30+
compareCommand.Arguments.Add(oldResultsPathArgument);
31+
var newResultsPathArgument = new Argument<string>("newReportPath")
32+
{
33+
DefaultValueFactory = (_) => ExistingReportPath,
34+
Description = "The path to the new benchmark report.",
35+
};
36+
compareCommand.Arguments.Add(newResultsPathArgument);
37+
var logLevelOption = new Option<LogLevel>("--log-level", "-l")
38+
{
39+
DefaultValueFactory = (_) => LogLevel.Warning,
40+
Description = "The log level to use.",
41+
};
42+
compareCommand.Options.Add(logLevelOption);
3043
var allPolicyNames = IBenchmarkComparisonPolicy.GetAllPolicies().Select(static p => p.Name).Order(StringComparer.OrdinalIgnoreCase).ToArray();
31-
var policiesOption = new Option<string[]>(["--policies", "-p"], () => ["all"], $"The policies to use for comparison: {string.Join(',', allPolicyNames)}.")
44+
var policiesOption = new Option<string[]>("--policies", "-p")
3245
{
33-
Arity = ArgumentArity.ZeroOrMore
46+
Arity = ArgumentArity.ZeroOrMore,
47+
DefaultValueFactory = (_) => ["all"],
48+
Description = $"The policies to use for comparison: {string.Join(',', allPolicyNames)}.",
3449
};
35-
compareCommand.AddOption(policiesOption);
36-
compareCommand.Handler = new CompareCommandHandler
50+
compareCommand.Options.Add(policiesOption);
51+
var compareCommandHandler = new CompareCommandHandler
3752
{
3853
OldResultsPath = oldResultsPathArgument,
3954
NewResultsPath = newResultsPathArgument,
4055
LogLevel = logLevelOption,
4156
Policies = policiesOption,
4257
};
58+
compareCommand.SetAction(compareCommandHandler.InvokeAsync);
4359
rootCommand.Add(compareCommand);
4460
return rootCommand;
4561
}

performance/resultsComparer/handlers/AsyncCommandHandler.cs

Lines changed: 0 additions & 14 deletions
This file was deleted.

performance/resultsComparer/handlers/CompareCommandHandler.cs

Lines changed: 16 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -3,30 +3,38 @@
33
using System.CommandLine.Invocation;
44
using System.Text.Json;
55
using System.Text.Json.Serialization;
6-
using Microsoft.Extensions.DependencyInjection;
76
using Microsoft.Extensions.Logging;
87
using resultsComparer.Models;
98
using resultsComparer.Policies;
109

1110
namespace resultsComparer.Handlers;
1211

13-
internal class CompareCommandHandler : AsyncCommandHandler
12+
internal class CompareCommandHandler : AsynchronousCommandLineAction
1413
{
1514
public required Argument<string> OldResultsPath { get; set; }
1615
public required Argument<string> NewResultsPath { get; set; }
1716
public required Option<LogLevel> LogLevel { get; set; }
1817
public required Option<string[]> Policies { get; set; }
1918

20-
public override Task<int> InvokeAsync(InvocationContext context)
19+
public override Task<int> InvokeAsync(ParseResult parseResult, CancellationToken cancellationToken = default)
2120
{
22-
var cancellationToken = context.BindingContext.GetRequiredService<CancellationToken>();
23-
var oldResultsPath = context.ParseResult.GetValueForArgument(OldResultsPath);
24-
var newResultsPath = context.ParseResult.GetValueForArgument(NewResultsPath);
25-
var policyNames = context.ParseResult.GetValueForOption(Policies) ?? [];
21+
var oldResultsPath = parseResult.GetValue(OldResultsPath);
22+
var newResultsPath = parseResult.GetValue(NewResultsPath);
23+
var policyNames = parseResult.GetValue(Policies) ?? [];
2624
var policies = IBenchmarkComparisonPolicy.GetSelectedPolicies(policyNames).ToArray();
27-
var logLevel = context.ParseResult.GetValueForOption(LogLevel);
25+
var logLevel = parseResult.GetValue(LogLevel);
2826
using var loggerFactory = Logger.ConfigureLogger(logLevel);
2927
var logger = loggerFactory.CreateLogger<CompareCommandHandler>();
28+
if (string.IsNullOrWhiteSpace(oldResultsPath))
29+
{
30+
logger.LogError("Old results path is required.");
31+
return Task.FromResult(1);
32+
}
33+
if (string.IsNullOrWhiteSpace(newResultsPath))
34+
{
35+
logger.LogError("New results path is required.");
36+
return Task.FromResult(1);
37+
}
3038
return CompareResultsAsync(oldResultsPath, newResultsPath, logger, policies, cancellationToken);
3139
}
3240
private static async Task<int> CompareResultsAsync(string existingReportPath, string newReportPath, ILogger logger, IBenchmarkComparisonPolicy[] comparisonPolicies, CancellationToken cancellationToken = default)

performance/resultsComparer/resultsComparer.csproj

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
<PackageReference Include="Microsoft.Extensions.Logging" Version="9.0.6" />
1313
<PackageReference Include="Microsoft.Extensions.Logging.Console" Version="9.0.6" />
1414
<PackageReference Include="Microsoft.Extensions.Logging.Debug" Version="9.0.6" />
15-
<PackageReference Include="System.CommandLine" Version="2.0.0-beta4.22272.1" />
15+
<PackageReference Include="System.CommandLine" Version="2.0.0-beta5.25306.1" />
1616
<PackageReference Include="system.text.json" Version="9.0.6" />
1717
</ItemGroup>
1818

src/Microsoft.OpenApi.Hidi/Extensions/CommandExtensions.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ public static void AddOptions(this Command command, IReadOnlyList<Option> option
1212
{
1313
foreach (var option in options)
1414
{
15-
command.AddOption(option);
15+
command.Options.Add(option);
1616
}
1717
}
1818
}

src/Microsoft.OpenApi.Hidi/Handlers/AsyncCommandHandler.cs

Lines changed: 0 additions & 14 deletions
This file was deleted.

src/Microsoft.OpenApi.Hidi/Handlers/PluginCommandHandler.cs

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2,26 +2,25 @@
22
// Licensed under the MIT license.
33

44
using System;
5+
using System.CommandLine;
56
using System.CommandLine.Invocation;
67
using System.Threading;
78
using System.Threading.Tasks;
8-
using Microsoft.Extensions.DependencyInjection;
99
using Microsoft.Extensions.Logging;
1010
using Microsoft.OpenApi.Hidi.Options;
1111

1212
namespace Microsoft.OpenApi.Hidi.Handlers
1313
{
14-
internal class PluginCommandHandler : AsyncCommandHandler
14+
internal class PluginCommandHandler : AsynchronousCommandLineAction
1515
{
1616
public CommandOptions CommandOptions { get; }
1717
public PluginCommandHandler(CommandOptions commandOptions)
1818
{
1919
CommandOptions = commandOptions;
2020
}
21-
public override async Task<int> InvokeAsync(InvocationContext context)
21+
public override async Task<int> InvokeAsync(ParseResult parseResult, CancellationToken cancellationToken = default)
2222
{
23-
var hidiOptions = new HidiOptions(context.ParseResult, CommandOptions);
24-
var cancellationToken = (CancellationToken)context.BindingContext.GetRequiredService(typeof(CancellationToken));
23+
var hidiOptions = new HidiOptions(parseResult, CommandOptions);
2524

2625
using var loggerFactory = Logger.ConfigureLogger(hidiOptions.LogLevel);
2726
var logger = loggerFactory.CreateLogger<PluginCommandHandler>();

src/Microsoft.OpenApi.Hidi/Handlers/ShowCommandHandler.cs

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2,26 +2,25 @@
22
// Licensed under the MIT license.
33

44
using System;
5+
using System.CommandLine;
56
using System.CommandLine.Invocation;
67
using System.Threading;
78
using System.Threading.Tasks;
8-
using Microsoft.Extensions.DependencyInjection;
99
using Microsoft.Extensions.Logging;
1010
using Microsoft.OpenApi.Hidi.Options;
1111

1212
namespace Microsoft.OpenApi.Hidi.Handlers
1313
{
14-
internal class ShowCommandHandler : AsyncCommandHandler
14+
internal class ShowCommandHandler : AsynchronousCommandLineAction
1515
{
1616
public CommandOptions CommandOptions { get; set; }
1717
public ShowCommandHandler(CommandOptions commandOptions)
1818
{
1919
CommandOptions = commandOptions;
2020
}
21-
public override async Task<int> InvokeAsync(InvocationContext context)
21+
public override async Task<int> InvokeAsync(ParseResult parseResult, CancellationToken cancellationToken = default)
2222
{
23-
var hidiOptions = new HidiOptions(context.ParseResult, CommandOptions);
24-
var cancellationToken = (CancellationToken)context.BindingContext.GetRequiredService(typeof(CancellationToken));
23+
var hidiOptions = new HidiOptions(parseResult, CommandOptions);
2524

2625
using var loggerFactory = Logger.ConfigureLogger(hidiOptions.LogLevel);
2726
var logger = loggerFactory.CreateLogger<ShowCommandHandler>();

src/Microsoft.OpenApi.Hidi/Handlers/TransformCommandHandler.cs

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2,26 +2,25 @@
22
// Licensed under the MIT license.
33

44
using System;
5+
using System.CommandLine;
56
using System.CommandLine.Invocation;
67
using System.Threading;
78
using System.Threading.Tasks;
8-
using Microsoft.Extensions.DependencyInjection;
99
using Microsoft.Extensions.Logging;
1010
using Microsoft.OpenApi.Hidi.Options;
1111

1212
namespace Microsoft.OpenApi.Hidi.Handlers
1313
{
14-
internal class TransformCommandHandler : AsyncCommandHandler
14+
internal class TransformCommandHandler : AsynchronousCommandLineAction
1515
{
1616
public CommandOptions CommandOptions { get; }
1717
public TransformCommandHandler(CommandOptions commandOptions)
1818
{
1919
CommandOptions = commandOptions;
2020
}
21-
public override async Task<int> InvokeAsync(InvocationContext context)
21+
public override async Task<int> InvokeAsync(ParseResult parseResult, CancellationToken cancellationToken = default)
2222
{
23-
var hidiOptions = new HidiOptions(context.ParseResult, CommandOptions);
24-
var cancellationToken = (CancellationToken)context.BindingContext.GetRequiredService(typeof(CancellationToken));
23+
var hidiOptions = new HidiOptions(parseResult, CommandOptions);
2524

2625
using var loggerFactory = Logger.ConfigureLogger(hidiOptions.LogLevel);
2726
var logger = loggerFactory.CreateLogger<TransformCommandHandler>();

src/Microsoft.OpenApi.Hidi/Handlers/ValidateCommandHandler.cs

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2,27 +2,26 @@
22
// Licensed under the MIT license.
33

44
using System;
5+
using System.CommandLine;
56
using System.CommandLine.Invocation;
67
using System.Threading;
78
using System.Threading.Tasks;
8-
using Microsoft.Extensions.DependencyInjection;
99
using Microsoft.Extensions.Logging;
1010
using Microsoft.OpenApi.Hidi.Options;
1111

1212
namespace Microsoft.OpenApi.Hidi.Handlers
1313
{
14-
internal class ValidateCommandHandler : AsyncCommandHandler
14+
internal class ValidateCommandHandler : AsynchronousCommandLineAction
1515
{
1616
public CommandOptions CommandOptions { get; }
1717

1818
public ValidateCommandHandler(CommandOptions commandOptions)
1919
{
2020
CommandOptions = commandOptions;
2121
}
22-
public override async Task<int> InvokeAsync(InvocationContext context)
22+
public override async Task<int> InvokeAsync(ParseResult parseResult, CancellationToken cancellationToken = default)
2323
{
24-
var hidiOptions = new HidiOptions(context.ParseResult, CommandOptions);
25-
var cancellationToken = (CancellationToken)context.BindingContext.GetRequiredService(typeof(CancellationToken));
24+
var hidiOptions = new HidiOptions(parseResult, CommandOptions);
2625
using var loggerFactory = Logger.ConfigureLogger(hidiOptions.LogLevel);
2726
var logger = loggerFactory.CreateLogger<ValidateCommandHandler>();
2827
try

src/Microsoft.OpenApi.Hidi/Microsoft.OpenApi.Hidi.csproj

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -36,11 +36,11 @@
3636
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
3737
<PrivateAssets>all</PrivateAssets>
3838
</PackageReference>
39-
<PackageReference Include="System.CommandLine" Version="2.0.0-beta4.22272.1" />
39+
<PackageReference Include="System.CommandLine" Version="2.0.0-beta5.25306.1" />
4040
<PackageReference Include="Microsoft.OData.Edm" Version="8.2.3" />
4141
<PackageReference Include="Microsoft.OpenApi.OData" Version="2.0.0-preview.15" />
4242
<PackageReference Include="Microsoft.OpenApi.ApiManifest" Version="2.0.0-preview5" />
43-
<PackageReference Include="System.CommandLine.Hosting" Version="0.4.0-alpha.22272.1" />
43+
<PackageReference Include="System.CommandLine.Hosting" Version="0.4.0-alpha.25306.1" />
4444
</ItemGroup>
4545

4646
<ItemGroup>

0 commit comments

Comments
 (0)