From 70426dd1e40c2a7dd2496b1552bd9a6c13ea5938 Mon Sep 17 00:00:00 2001
From: Adeel <3840695+am11@users.noreply.github.com>
Date: Fri, 9 Jun 2023 19:35:47 +0300
Subject: [PATCH 1/4] Update System.CommandLine version
---
eng/Version.Details.xml | 4 +-
eng/Versions.props | 2 +-
.../tools/Common/CommandLineHelpers.cs | 49 +-
.../tools/ILVerify/ILVerifyRootCommand.cs | 90 ++--
src/coreclr/tools/ILVerify/Program.cs | 16 +-
src/coreclr/tools/InjectResource/Program.cs | 36 +-
.../aot/ILCompiler/ILCompilerRootCommand.cs | 466 +++++++++--------
src/coreclr/tools/aot/ILCompiler/Program.cs | 16 +-
.../aot/crossgen2/Crossgen2RootCommand.cs | 494 +++++++++---------
src/coreclr/tools/aot/crossgen2/Program.cs | 16 +-
.../tools/dotnet-pgo/PgoRootCommand.cs | 200 +++----
src/coreclr/tools/dotnet-pgo/Program.cs | 20 +-
src/coreclr/tools/r2rdump/Program.cs | 14 +-
.../tools/r2rdump/R2RDumpRootCommand.cs | 222 ++++----
.../tools/r2rtest/CommandLineOptions.cs | 195 ++++---
src/coreclr/tools/r2rtest/R2RTest.csproj | 23 +-
16 files changed, 943 insertions(+), 920 deletions(-)
diff --git a/eng/Version.Details.xml b/eng/Version.Details.xml
index ac2e8e2650dae8..3e55787d76b831 100644
--- a/eng/Version.Details.xml
+++ b/eng/Version.Details.xml
@@ -76,9 +76,9 @@
https://github.com/dotnet/llvm-project
76f334f354eb653a7b409a5319b591ea09df5a43
-
+
https://github.com/dotnet/command-line-api
- 8374d5fca634a93458c84414b1604c12f765d1ab
+ 02fe27cd6a9b001c8feb7938e6ef4b3799745759
https://github.com/dotnet/command-line-api
diff --git a/eng/Versions.props b/eng/Versions.props
index 1131b7c5e1a902..6119727b701fbd 100644
--- a/eng/Versions.props
+++ b/eng/Versions.props
@@ -162,7 +162,7 @@
1.0.0-prerelease.23303.6
16.11.23-beta1.23063.1
- 2.0.0-beta4.22564.1
+ 2.0.0-beta4.23307.1
3.0.3
2.1.0
2.0.3
diff --git a/src/coreclr/tools/Common/CommandLineHelpers.cs b/src/coreclr/tools/Common/CommandLineHelpers.cs
index 2475d2a64213d8..02653dc214b3e3 100644
--- a/src/coreclr/tools/Common/CommandLineHelpers.cs
+++ b/src/coreclr/tools/Common/CommandLineHelpers.cs
@@ -1,8 +1,8 @@
// Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT license.
+using System.CommandLine.Help;
using System.Collections.Generic;
-using System.CommandLine.Binding;
using System.CommandLine.Parsing;
using System.IO;
using System.IO.Compression;
@@ -24,11 +24,11 @@ internal static partial class Helpers
{
public const string DefaultSystemModule = "System.Private.CoreLib";
- public static Dictionary BuildPathDictionary(IReadOnlyList tokens, bool strict)
+ public static Dictionary BuildPathDictionary(IReadOnlyList tokens, bool strict)
{
Dictionary dictionary = new(StringComparer.OrdinalIgnoreCase);
- foreach (Token token in tokens)
+ foreach (CliToken token in tokens)
{
AppendExpandedPaths(dictionary, token.Value, strict);
}
@@ -36,11 +36,11 @@ public static Dictionary BuildPathDictionary(IReadOnlyList BuildPathList(IReadOnlyList tokens)
+ public static List BuildPathList(IReadOnlyList tokens)
{
List paths = new();
Dictionary dictionary = new(StringComparer.OrdinalIgnoreCase);
- foreach (Token token in tokens)
+ foreach (CliToken token in tokens)
{
AppendExpandedPaths(dictionary, token.Value, false);
foreach (string file in dictionary.Values)
@@ -113,6 +113,36 @@ public static TargetArchitecture GetTargetArchitecture(string token)
}
}
+ public static CliRootCommand UseVersion(this CliRootCommand command)
+ {
+ for (int i = 0; i < command.Options.Count; i++)
+ {
+ if (command.Options[i] is VersionOption)
+ {
+ command.Options[i] = new VersionOption("--version", "-v");
+ break;
+ }
+ }
+
+ return command;
+ }
+
+ public static CliRootCommand UseExtendedHelp(this CliRootCommand command, Func>> customizer)
+ {
+ foreach (CliOption option in command.Options)
+ {
+ if (option is HelpOption helpOption)
+ {
+ HelpBuilder builder = new();
+ builder.CustomizeLayout(customizer);
+ helpOption.Action = new HelpAction { Builder = builder };
+ break;
+ }
+ }
+
+ return command;
+ }
+
public static void MakeReproPackage(string makeReproPath, string outputFilePath, string[] args, ParseResult res, IEnumerable inputOptions, IEnumerable outputOptions = null)
{
Directory.CreateDirectory(makeReproPath);
@@ -177,16 +207,15 @@ public static void MakeReproPackage(string makeReproPath, string outputFilePath,
Dictionary outputToReproPackageFileName = new();
List rspFile = new List();
- foreach (var option in res.CommandResult.Command.Options)
+ foreach (CliOption