Skip to content

Bump Microsoft.OpenApi.OData and 3 others #2410

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
38 changes: 27 additions & 11 deletions performance/resultsComparer/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,13 @@

namespace resultsComparer;

public class Program

Check warning on line 9 in performance/resultsComparer/Program.cs

View workflow job for this annotation

GitHub Actions / Build

Add a 'protected' constructor or the 'static' keyword to the class declaration. (https://rules.sonarsource.com/csharp/RSPEC-1118)

Check warning on line 9 in performance/resultsComparer/Program.cs

View workflow job for this annotation

GitHub Actions / Build

Add a 'protected' constructor or the 'static' keyword to the class declaration. (https://rules.sonarsource.com/csharp/RSPEC-1118)
{
public static async Task<int> Main(string[] args)
{
var rootCommand = CreateRootCommand();
return await rootCommand.InvokeAsync(args);
var parseResult = rootCommand.Parse(args);
return await parseResult.InvokeAsync();
}
internal static RootCommand CreateRootCommand()
{
Expand All @@ -21,25 +22,40 @@
{
Description = "Compare the benchmark results."
};
var oldResultsPathArgument = new Argument<string>("existingReportPath", () => ExistingReportPath, "The path to the existing benchmark report.");
compareCommand.AddArgument(oldResultsPathArgument);
var newResultsPathArgument = new Argument<string>("newReportPath", () => ExistingReportPath, "The path to the new benchmark report.");
compareCommand.AddArgument(newResultsPathArgument);
var logLevelOption = new Option<LogLevel>(["--log-level", "-l"], () => LogLevel.Warning, "The log level to use.");
compareCommand.AddOption(logLevelOption);
var oldResultsPathArgument = new Argument<string>("existingReportPath")
{
DefaultValueFactory = (_) => ExistingReportPath,
Description = "The path to the existing benchmark report.",
};
compareCommand.Arguments.Add(oldResultsPathArgument);
var newResultsPathArgument = new Argument<string>("newReportPath")
{
DefaultValueFactory = (_) => ExistingReportPath,
Description = "The path to the new benchmark report.",
};
compareCommand.Arguments.Add(newResultsPathArgument);
var logLevelOption = new Option<LogLevel>("--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<string[]>(["--policies", "-p"], () => ["all"], $"The policies to use for comparison: {string.Join(',', allPolicyNames)}.")
var policiesOption = new Option<string[]>("--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;
}
Expand Down
14 changes: 0 additions & 14 deletions performance/resultsComparer/handlers/AsyncCommandHandler.cs

This file was deleted.

24 changes: 16 additions & 8 deletions performance/resultsComparer/handlers/CompareCommandHandler.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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<string> OldResultsPath { get; set; }
public required Argument<string> NewResultsPath { get; set; }
public required Option<LogLevel> LogLevel { get; set; }
public required Option<string[]> Policies { get; set; }

public override Task<int> InvokeAsync(InvocationContext context)
public override Task<int> InvokeAsync(ParseResult parseResult, CancellationToken cancellationToken = default)
{
var cancellationToken = context.BindingContext.GetRequiredService<CancellationToken>();
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<CompareCommandHandler>();
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<int> CompareResultsAsync(string existingReportPath, string newReportPath, ILogger logger, IBenchmarkComparisonPolicy[] comparisonPolicies, CancellationToken cancellationToken = default)
Expand All @@ -52,7 +60,7 @@
logger.LogError("No new benchmark result found for {ExistingBenchmarkResultKey}.", existingBenchmarkResult.Key);
hasErrors = true;
}
foreach (var comparisonPolicy in comparisonPolicies)

Check warning on line 63 in performance/resultsComparer/handlers/CompareCommandHandler.cs

View workflow job for this annotation

GitHub Actions / Build

Loops should be simplified using the "Where" LINQ method (https://rules.sonarsource.com/csharp/RSPEC-3267)

Check warning on line 63 in performance/resultsComparer/handlers/CompareCommandHandler.cs

View workflow job for this annotation

GitHub Actions / Build

Loops should be simplified using the "Where" LINQ method (https://rules.sonarsource.com/csharp/RSPEC-3267)
{
if (!comparisonPolicy.Equals(existingBenchmarkResult.Value, newBenchmarkResult))
{
Expand Down
2 changes: 1 addition & 1 deletion performance/resultsComparer/resultsComparer.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
<PackageReference Include="Microsoft.Extensions.Logging" Version="9.0.6" />
<PackageReference Include="Microsoft.Extensions.Logging.Console" Version="9.0.6" />
<PackageReference Include="Microsoft.Extensions.Logging.Debug" Version="9.0.6" />
<PackageReference Include="System.CommandLine" Version="2.0.0-beta4.22272.1" />
<PackageReference Include="System.CommandLine" Version="2.0.0-beta5.25306.1" />
<PackageReference Include="system.text.json" Version="9.0.6" />
</ItemGroup>

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ public static void AddOptions(this Command command, IReadOnlyList<Option> option
{
foreach (var option in options)
{
command.AddOption(option);
command.Options.Add(option);
}
}
}
Expand Down
14 changes: 0 additions & 14 deletions src/Microsoft.OpenApi.Hidi/Handlers/AsyncCommandHandler.cs

This file was deleted.

9 changes: 4 additions & 5 deletions src/Microsoft.OpenApi.Hidi/Handlers/PluginCommandHandler.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,26 +2,25 @@
// Licensed under the MIT license.

using System;
using System.CommandLine;
using System.CommandLine.Invocation;
using System.Threading;
using System.Threading.Tasks;
using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.Logging;
using Microsoft.OpenApi.Hidi.Options;

namespace Microsoft.OpenApi.Hidi.Handlers
{
internal class PluginCommandHandler : AsyncCommandHandler
internal class PluginCommandHandler : AsynchronousCommandLineAction
{
public CommandOptions CommandOptions { get; }
public PluginCommandHandler(CommandOptions commandOptions)
{
CommandOptions = commandOptions;
}
public override async Task<int> InvokeAsync(InvocationContext context)
public override async Task<int> InvokeAsync(ParseResult parseResult, CancellationToken cancellationToken = default)
{
var hidiOptions = new HidiOptions(context.ParseResult, CommandOptions);
var cancellationToken = (CancellationToken)context.BindingContext.GetRequiredService(typeof(CancellationToken));
var hidiOptions = new HidiOptions(parseResult, CommandOptions);

using var loggerFactory = Logger.ConfigureLogger(hidiOptions.LogLevel);
var logger = loggerFactory.CreateLogger<PluginCommandHandler>();
Expand All @@ -34,7 +33,7 @@
#if RELEASE
#pragma warning disable CA1031 // Do not catch general exception types
#endif
catch (Exception ex)

Check warning on line 36 in src/Microsoft.OpenApi.Hidi/Handlers/PluginCommandHandler.cs

View workflow job for this annotation

GitHub Actions / Build

Either log this exception and handle it, or rethrow it with some contextual information. (https://rules.sonarsource.com/csharp/RSPEC-2139)
{
#if DEBUG
logger.LogCritical(ex, "Command failed");
Expand Down
9 changes: 4 additions & 5 deletions src/Microsoft.OpenApi.Hidi/Handlers/ShowCommandHandler.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,26 +2,25 @@
// Licensed under the MIT license.

using System;
using System.CommandLine;
using System.CommandLine.Invocation;
using System.Threading;
using System.Threading.Tasks;
using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.Logging;
using Microsoft.OpenApi.Hidi.Options;

namespace Microsoft.OpenApi.Hidi.Handlers
{
internal class ShowCommandHandler : AsyncCommandHandler
internal class ShowCommandHandler : AsynchronousCommandLineAction
{
public CommandOptions CommandOptions { get; set; }
public ShowCommandHandler(CommandOptions commandOptions)
{
CommandOptions = commandOptions;
}
public override async Task<int> InvokeAsync(InvocationContext context)
public override async Task<int> InvokeAsync(ParseResult parseResult, CancellationToken cancellationToken = default)
{
var hidiOptions = new HidiOptions(context.ParseResult, CommandOptions);
var cancellationToken = (CancellationToken)context.BindingContext.GetRequiredService(typeof(CancellationToken));
var hidiOptions = new HidiOptions(parseResult, CommandOptions);

using var loggerFactory = Logger.ConfigureLogger(hidiOptions.LogLevel);
var logger = loggerFactory.CreateLogger<ShowCommandHandler>();
Expand All @@ -34,7 +33,7 @@
#if RELEASE
#pragma warning disable CA1031 // Do not catch general exception types
#endif
catch (Exception ex)

Check warning on line 36 in src/Microsoft.OpenApi.Hidi/Handlers/ShowCommandHandler.cs

View workflow job for this annotation

GitHub Actions / Build

Either log this exception and handle it, or rethrow it with some contextual information. (https://rules.sonarsource.com/csharp/RSPEC-2139)
{
#if DEBUG
logger.LogCritical(ex, "Command failed");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,26 +2,25 @@
// Licensed under the MIT license.

using System;
using System.CommandLine;
using System.CommandLine.Invocation;
using System.Threading;
using System.Threading.Tasks;
using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.Logging;
using Microsoft.OpenApi.Hidi.Options;

namespace Microsoft.OpenApi.Hidi.Handlers
{
internal class TransformCommandHandler : AsyncCommandHandler
internal class TransformCommandHandler : AsynchronousCommandLineAction
{
public CommandOptions CommandOptions { get; }
public TransformCommandHandler(CommandOptions commandOptions)
{
CommandOptions = commandOptions;
}
public override async Task<int> InvokeAsync(InvocationContext context)
public override async Task<int> InvokeAsync(ParseResult parseResult, CancellationToken cancellationToken = default)
{
var hidiOptions = new HidiOptions(context.ParseResult, CommandOptions);
var cancellationToken = (CancellationToken)context.BindingContext.GetRequiredService(typeof(CancellationToken));
var hidiOptions = new HidiOptions(parseResult, CommandOptions);

using var loggerFactory = Logger.ConfigureLogger(hidiOptions.LogLevel);
var logger = loggerFactory.CreateLogger<TransformCommandHandler>();
Expand All @@ -34,7 +33,7 @@
#if RELEASE
#pragma warning disable CA1031 // Do not catch general exception types
#endif
catch (Exception ex)

Check warning on line 36 in src/Microsoft.OpenApi.Hidi/Handlers/TransformCommandHandler.cs

View workflow job for this annotation

GitHub Actions / Build

Either log this exception and handle it, or rethrow it with some contextual information. (https://rules.sonarsource.com/csharp/RSPEC-2139)
{
#if DEBUG
logger.LogCritical(ex, "Command failed");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,27 +2,26 @@
// Licensed under the MIT license.

using System;
using System.CommandLine;
using System.CommandLine.Invocation;
using System.Threading;
using System.Threading.Tasks;
using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.Logging;
using Microsoft.OpenApi.Hidi.Options;

namespace Microsoft.OpenApi.Hidi.Handlers
{
internal class ValidateCommandHandler : AsyncCommandHandler
internal class ValidateCommandHandler : AsynchronousCommandLineAction
{
public CommandOptions CommandOptions { get; }

public ValidateCommandHandler(CommandOptions commandOptions)
{
CommandOptions = commandOptions;
}
public override async Task<int> InvokeAsync(InvocationContext context)
public override async Task<int> InvokeAsync(ParseResult parseResult, CancellationToken cancellationToken = default)
{
var hidiOptions = new HidiOptions(context.ParseResult, CommandOptions);
var cancellationToken = (CancellationToken)context.BindingContext.GetRequiredService(typeof(CancellationToken));
var hidiOptions = new HidiOptions(parseResult, CommandOptions);
using var loggerFactory = Logger.ConfigureLogger(hidiOptions.LogLevel);
var logger = loggerFactory.CreateLogger<ValidateCommandHandler>();
try
Expand All @@ -34,7 +33,7 @@
#if RELEASE
#pragma warning disable CA1031 // Do not catch general exception types
#endif
catch (Exception ex)

Check warning on line 36 in src/Microsoft.OpenApi.Hidi/Handlers/ValidateCommandHandler.cs

View workflow job for this annotation

GitHub Actions / Build

Either log this exception and handle it, or rethrow it with some contextual information. (https://rules.sonarsource.com/csharp/RSPEC-2139)
{
#if DEBUG
logger.LogCritical(ex, "Command failed");
Expand Down
4 changes: 2 additions & 2 deletions src/Microsoft.OpenApi.Hidi/Microsoft.OpenApi.Hidi.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -36,11 +36,11 @@
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
<PrivateAssets>all</PrivateAssets>
</PackageReference>
<PackageReference Include="System.CommandLine" Version="2.0.0-beta4.22272.1" />
<PackageReference Include="System.CommandLine" Version="2.0.0-beta5.25306.1" />
<PackageReference Include="Microsoft.OData.Edm" Version="8.2.3" />
<PackageReference Include="Microsoft.OpenApi.OData" Version="2.0.0-preview.15" />
<PackageReference Include="Microsoft.OpenApi.ApiManifest" Version="2.0.0-preview5" />
<PackageReference Include="System.CommandLine.Hosting" Version="0.4.0-alpha.22272.1" />
<PackageReference Include="System.CommandLine.Hosting" Version="0.4.0-alpha.25306.1" />
</ItemGroup>

<ItemGroup>
Expand Down
Loading
Loading