Skip to content

Commit a58e923

Browse files
authored
System.CommandLine update (#111864)
* Update dependencies from https://github.com/dotnet/command-line-api build 20250122.1 Microsoft.SourceBuild.Intermediate.command-line-api , System.CommandLine From Version 0.1.552801 -> To Version 0.1.607201 * adopt to breaking changes in System.CommandLine * stop using System.CommandLine.Experimental * fix the build by keeping the versions hardcoded, as stress test projects do not import the repo infrastructure intentionally
1 parent b044b20 commit a58e923

File tree

22 files changed

+462
-446
lines changed

22 files changed

+462
-446
lines changed

eng/Version.Details.xml

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -40,14 +40,14 @@
4040
<Uri>https://github.com/dotnet/llvm-project</Uri>
4141
<Sha>da5dd054a531e6fea65643b7e754285b73eab433</Sha>
4242
</Dependency>
43-
<Dependency Name="System.CommandLine" Version="2.0.0-beta4.24528.1">
43+
<Dependency Name="System.CommandLine" Version="2.0.0-beta5.25208.1">
4444
<Uri>https://github.com/dotnet/command-line-api</Uri>
45-
<Sha>feb61c7f328a2401d74f4317b39d02126cfdfe24</Sha>
45+
<Sha>48bd86bdcd926a194e1581a60d820d12a64ef3c6</Sha>
4646
</Dependency>
4747
<!-- Intermediate is necessary for source build. -->
48-
<Dependency Name="Microsoft.SourceBuild.Intermediate.command-line-api" Version="0.1.552801">
48+
<Dependency Name="Microsoft.SourceBuild.Intermediate.command-line-api" Version="0.1.620801">
4949
<Uri>https://github.com/dotnet/command-line-api</Uri>
50-
<Sha>feb61c7f328a2401d74f4317b39d02126cfdfe24</Sha>
50+
<Sha>48bd86bdcd926a194e1581a60d820d12a64ef3c6</Sha>
5151
<SourceBuild RepoName="command-line-api" ManagedOnly="true" />
5252
</Dependency>
5353
<Dependency Name="Microsoft.DotNet.Cecil" Version="0.11.5-alpha.25125.1">

eng/Versions.props

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -179,7 +179,7 @@
179179
<!-- Not auto-updated. -->
180180
<MicrosoftDiaSymReaderVersion>2.0.0</MicrosoftDiaSymReaderVersion>
181181
<MicrosoftDiaSymReaderNativeVersion>17.10.0-beta1.24272.1</MicrosoftDiaSymReaderNativeVersion>
182-
<SystemCommandLineVersion>2.0.0-beta4.24528.1</SystemCommandLineVersion>
182+
<SystemCommandLineVersion>2.0.0-beta5.25208.1</SystemCommandLineVersion>
183183
<TraceEventVersion>3.1.16</TraceEventVersion>
184184
<NETStandardLibraryRefVersion>2.1.0</NETStandardLibraryRefVersion>
185185
<NetStandardLibraryVersion>2.0.3</NetStandardLibraryVersion>

src/coreclr/tools/Common/CommandLineHelpers.cs

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -24,23 +24,23 @@ internal static partial class Helpers
2424
{
2525
public const string DefaultSystemModule = "System.Private.CoreLib";
2626

27-
public static Dictionary<string, string> BuildPathDictionary(IReadOnlyList<CliToken> tokens, bool strict)
27+
public static Dictionary<string, string> BuildPathDictionary(IReadOnlyList<Token> tokens, bool strict)
2828
{
2929
Dictionary<string, string> dictionary = new(StringComparer.OrdinalIgnoreCase);
3030

31-
foreach (CliToken token in tokens)
31+
foreach (Token token in tokens)
3232
{
3333
AppendExpandedPaths(dictionary, token.Value, strict);
3434
}
3535

3636
return dictionary;
3737
}
3838

39-
public static List<string> BuildPathList(IReadOnlyList<CliToken> tokens)
39+
public static List<string> BuildPathList(IReadOnlyList<Token> tokens)
4040
{
4141
List<string> paths = new();
4242
Dictionary<string, string> dictionary = new(StringComparer.OrdinalIgnoreCase);
43-
foreach (CliToken token in tokens)
43+
foreach (Token token in tokens)
4444
{
4545
AppendExpandedPaths(dictionary, token.Value, false);
4646
foreach (string file in dictionary.Values)
@@ -115,7 +115,7 @@ public static TargetArchitecture GetTargetArchitecture(string token)
115115
}
116116
}
117117

118-
public static CliRootCommand UseVersion(this CliRootCommand command)
118+
public static RootCommand UseVersion(this RootCommand command)
119119
{
120120
for (int i = 0; i < command.Options.Count; i++)
121121
{
@@ -129,9 +129,9 @@ public static CliRootCommand UseVersion(this CliRootCommand command)
129129
return command;
130130
}
131131

132-
public static CliRootCommand UseExtendedHelp(this CliRootCommand command, Func<HelpContext, IEnumerable<Func<HelpContext, bool>>> customizer)
132+
public static RootCommand UseExtendedHelp(this RootCommand command, Func<HelpContext, IEnumerable<Func<HelpContext, bool>>> customizer)
133133
{
134-
foreach (CliOption option in command.Options)
134+
foreach (Option option in command.Options)
135135
{
136136
if (option is HelpOption helpOption)
137137
{
@@ -209,7 +209,7 @@ public static void MakeReproPackage(string makeReproPath, string outputFilePath,
209209
Dictionary<string, string> outputToReproPackageFileName = new();
210210

211211
List<string> rspFile = new List<string>();
212-
foreach (CliOption option in res.CommandResult.Command.Options)
212+
foreach (Option option in res.CommandResult.Command.Options)
213213
{
214214
OptionResult optionResult = res.GetResult(option);
215215
if (optionResult is null || option.Name == "--make-repro-path")
@@ -266,7 +266,7 @@ public static void MakeReproPackage(string makeReproPath, string outputFilePath,
266266
}
267267
}
268268

269-
foreach (CliArgument argument in res.CommandResult.Command.Arguments)
269+
foreach (Argument argument in res.CommandResult.Command.Arguments)
270270
{
271271
ArgumentResult argumentResult = res.GetResult(argument);
272272
if (argumentResult is null)

src/coreclr/tools/ILVerify/ILVerifyRootCommand.cs

Lines changed: 17 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -8,33 +8,33 @@
88

99
namespace ILVerify
1010
{
11-
internal sealed class ILVerifyRootCommand : CliRootCommand
11+
internal sealed class ILVerifyRootCommand : RootCommand
1212
{
13-
public CliArgument<Dictionary<string, string>> InputFilePath { get; } =
13+
public Argument<Dictionary<string, string>> InputFilePath { get; } =
1414
new("input-file-path") { CustomParser = result => Helpers.BuildPathDictionary(result.Tokens, true), Description = "Input file(s)", Arity = ArgumentArity.OneOrMore };
15-
public CliOption<Dictionary<string, string>> Reference { get; } =
15+
public Option<Dictionary<string, string>> Reference { get; } =
1616
new("--reference", "-r") { CustomParser = result => Helpers.BuildPathDictionary(result.Tokens, false), DefaultValueFactory = result => Helpers.BuildPathDictionary(result.Tokens, false), Description = "Reference metadata from the specified assembly" };
17-
public CliOption<string> SystemModule { get; } =
17+
public Option<string> SystemModule { get; } =
1818
new("--system-module", "-s") { Description = "System module name (default: mscorlib)" };
19-
public CliOption<bool> SanityChecks { get; } =
19+
public Option<bool> SanityChecks { get; } =
2020
new("--sanity-checks", "-c") { Description = "Check for valid constructs that are likely mistakes" };
21-
public CliOption<string[]> Include { get; } =
21+
public Option<string[]> Include { get; } =
2222
new("--include", "-i") { Description = "Use only methods/types/namespaces, which match the given regular expression(s)" };
23-
public CliOption<FileInfo> IncludeFile { get; } =
24-
new CliOption<FileInfo>("--include-file") { Description = "Same as --include, but the regular expression(s) are declared line by line in the specified file." }.AcceptExistingOnly();
25-
public CliOption<string[]> Exclude { get; } =
23+
public Option<FileInfo> IncludeFile { get; } =
24+
new Option<FileInfo>("--include-file") { Description = "Same as --include, but the regular expression(s) are declared line by line in the specified file." }.AcceptExistingOnly();
25+
public Option<string[]> Exclude { get; } =
2626
new("--exclude", "-e") { Description = "Skip methods/types/namespaces, which match the given regular expression(s)" };
27-
public CliOption<FileInfo> ExcludeFile { get; } =
28-
new CliOption<FileInfo>("--exclude-file") { Description = "Same as --exclude, but the regular expression(s) are declared line by line in the specified file." }.AcceptExistingOnly();
29-
public CliOption<string[]> IgnoreError { get; } =
27+
public Option<FileInfo> ExcludeFile { get; } =
28+
new Option<FileInfo>("--exclude-file") { Description = "Same as --exclude, but the regular expression(s) are declared line by line in the specified file." }.AcceptExistingOnly();
29+
public Option<string[]> IgnoreError { get; } =
3030
new("--ignore-error", "-g") { Description = "Ignore errors, which match the given regular expression(s)" };
31-
public CliOption<FileInfo> IgnoreErrorFile { get; } =
32-
new CliOption<FileInfo>("--ignore-error-file") { Description = "Same as --ignore-error, but the regular expression(s) are declared line by line in the specified file." }.AcceptExistingOnly();
33-
public CliOption<bool> Statistics { get; } =
31+
public Option<FileInfo> IgnoreErrorFile { get; } =
32+
new Option<FileInfo>("--ignore-error-file") { Description = "Same as --ignore-error, but the regular expression(s) are declared line by line in the specified file." }.AcceptExistingOnly();
33+
public Option<bool> Statistics { get; } =
3434
new("--statistics") { Description = "Print verification statistics" };
35-
public CliOption<bool> Verbose { get; } =
35+
public Option<bool> Verbose { get; } =
3636
new("--verbose") { Description = "Verbose output" };
37-
public CliOption<bool> Tokens { get; } =
37+
public Option<bool> Tokens { get; } =
3838
new("--tokens", "-t") { Description = "Include metadata tokens in error messages" };
3939

4040
public ParseResult Result;

src/coreclr/tools/ILVerify/Program.cs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -475,11 +475,11 @@ public PEReader Resolve(string simpleName)
475475
return null;
476476
}
477477

478-
private T Get<T>(CliOption<T> option) => _command.Result.GetValue(option);
479-
private T Get<T>(CliArgument<T> argument) => _command.Result.GetValue(argument);
478+
private T Get<T>(Option<T> option) => _command.Result.GetValue(option);
479+
private T Get<T>(Argument<T> argument) => _command.Result.GetValue(argument);
480480

481481
private static int Main(string[] args) =>
482-
new CliConfiguration(new ILVerifyRootCommand().UseVersion())
482+
new CommandLineConfiguration(new ILVerifyRootCommand().UseVersion())
483483
{
484484
ResponseFileTokenReplacer = Helpers.TryReadResponseFile,
485485
EnableDefaultExceptionHandler = false,

0 commit comments

Comments
 (0)