Skip to content
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

[BLOCKED] System.CommandLine update #111864

Draft
wants to merge 7 commits into
base: main
Choose a base branch
from
Draft
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
8 changes: 4 additions & 4 deletions eng/Version.Details.xml
Original file line number Diff line number Diff line change
Expand Up @@ -40,14 +40,14 @@
<Uri>https://github.com/dotnet/llvm-project</Uri>
<Sha>317598aea216019b6164f599859c738f69595c60</Sha>
</Dependency>
<Dependency Name="System.CommandLine" Version="2.0.0-beta4.24528.1">
<Dependency Name="System.CommandLine" Version="2.0.0-beta4.25072.1">
<Uri>https://github.com/dotnet/command-line-api</Uri>
<Sha>feb61c7f328a2401d74f4317b39d02126cfdfe24</Sha>
<Sha>060374e56c1b2e741b6525ca8417006efb54fbd7</Sha>
</Dependency>
<!-- Intermediate is necessary for source build. -->
<Dependency Name="Microsoft.SourceBuild.Intermediate.command-line-api" Version="0.1.552801">
<Dependency Name="Microsoft.SourceBuild.Intermediate.command-line-api" Version="0.1.607201">
<Uri>https://github.com/dotnet/command-line-api</Uri>
<Sha>feb61c7f328a2401d74f4317b39d02126cfdfe24</Sha>
<Sha>060374e56c1b2e741b6525ca8417006efb54fbd7</Sha>
<SourceBuild RepoName="command-line-api" ManagedOnly="true" />
</Dependency>
<Dependency Name="Microsoft.DotNet.Cecil" Version="0.11.5-alpha.25069.2">
Expand Down
2 changes: 1 addition & 1 deletion eng/Versions.props
Original file line number Diff line number Diff line change
Expand Up @@ -173,7 +173,7 @@
<!-- Not auto-updated. -->
<MicrosoftDiaSymReaderVersion>2.0.0</MicrosoftDiaSymReaderVersion>
<MicrosoftDiaSymReaderNativeVersion>17.10.0-beta1.24272.1</MicrosoftDiaSymReaderNativeVersion>
<SystemCommandLineVersion>2.0.0-beta4.24528.1</SystemCommandLineVersion>
<SystemCommandLineVersion>2.0.0-beta4.25072.1</SystemCommandLineVersion>
<TraceEventVersion>3.1.16</TraceEventVersion>
<NETStandardLibraryRefVersion>2.1.0</NETStandardLibraryRefVersion>
<NetStandardLibraryVersion>2.0.3</NetStandardLibraryVersion>
Expand Down
18 changes: 9 additions & 9 deletions src/coreclr/tools/Common/CommandLineHelpers.cs
Original file line number Diff line number Diff line change
Expand Up @@ -24,23 +24,23 @@ internal static partial class Helpers
{
public const string DefaultSystemModule = "System.Private.CoreLib";

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

foreach (CliToken token in tokens)
foreach (Token token in tokens)
{
AppendExpandedPaths(dictionary, token.Value, strict);
}

return dictionary;
}

public static List<string> BuildPathList(IReadOnlyList<CliToken> tokens)
public static List<string> BuildPathList(IReadOnlyList<Token> tokens)
{
List<string> paths = new();
Dictionary<string, string> dictionary = new(StringComparer.OrdinalIgnoreCase);
foreach (CliToken token in tokens)
foreach (Token token in tokens)
{
AppendExpandedPaths(dictionary, token.Value, false);
foreach (string file in dictionary.Values)
Expand Down Expand Up @@ -115,7 +115,7 @@ public static TargetArchitecture GetTargetArchitecture(string token)
}
}

public static CliRootCommand UseVersion(this CliRootCommand command)
public static RootCommand UseVersion(this RootCommand command)
{
for (int i = 0; i < command.Options.Count; i++)
{
Expand All @@ -129,9 +129,9 @@ public static CliRootCommand UseVersion(this CliRootCommand command)
return command;
}

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

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

foreach (CliArgument argument in res.CommandResult.Command.Arguments)
foreach (Argument argument in res.CommandResult.Command.Arguments)
{
ArgumentResult argumentResult = res.GetResult(argument);
if (argumentResult is null)
Expand Down
34 changes: 17 additions & 17 deletions src/coreclr/tools/ILVerify/ILVerifyRootCommand.cs
Original file line number Diff line number Diff line change
Expand Up @@ -8,33 +8,33 @@

namespace ILVerify
{
internal sealed class ILVerifyRootCommand : CliRootCommand
internal sealed class ILVerifyRootCommand : RootCommand
{
public CliArgument<Dictionary<string, string>> InputFilePath { get; } =
public Argument<Dictionary<string, string>> InputFilePath { get; } =
new("input-file-path") { CustomParser = result => Helpers.BuildPathDictionary(result.Tokens, true), Description = "Input file(s)", Arity = ArgumentArity.OneOrMore };
public CliOption<Dictionary<string, string>> Reference { get; } =
public Option<Dictionary<string, string>> Reference { get; } =
new("--reference", "-r") { CustomParser = result => Helpers.BuildPathDictionary(result.Tokens, false), DefaultValueFactory = result => Helpers.BuildPathDictionary(result.Tokens, false), Description = "Reference metadata from the specified assembly" };
public CliOption<string> SystemModule { get; } =
public Option<string> SystemModule { get; } =
new("--system-module", "-s") { Description = "System module name (default: mscorlib)" };
public CliOption<bool> SanityChecks { get; } =
public Option<bool> SanityChecks { get; } =
new("--sanity-checks", "-c") { Description = "Check for valid constructs that are likely mistakes" };
public CliOption<string[]> Include { get; } =
public Option<string[]> Include { get; } =
new("--include", "-i") { Description = "Use only methods/types/namespaces, which match the given regular expression(s)" };
public CliOption<FileInfo> IncludeFile { get; } =
new CliOption<FileInfo>("--include-file") { Description = "Same as --include, but the regular expression(s) are declared line by line in the specified file." }.AcceptExistingOnly();
public CliOption<string[]> Exclude { get; } =
public Option<FileInfo> IncludeFile { get; } =
new Option<FileInfo>("--include-file") { Description = "Same as --include, but the regular expression(s) are declared line by line in the specified file." }.AcceptExistingOnly();
public Option<string[]> Exclude { get; } =
new("--exclude", "-e") { Description = "Skip methods/types/namespaces, which match the given regular expression(s)" };
public CliOption<FileInfo> ExcludeFile { get; } =
new CliOption<FileInfo>("--exclude-file") { Description = "Same as --exclude, but the regular expression(s) are declared line by line in the specified file." }.AcceptExistingOnly();
public CliOption<string[]> IgnoreError { get; } =
public Option<FileInfo> ExcludeFile { get; } =
new Option<FileInfo>("--exclude-file") { Description = "Same as --exclude, but the regular expression(s) are declared line by line in the specified file." }.AcceptExistingOnly();
public Option<string[]> IgnoreError { get; } =
new("--ignore-error", "-g") { Description = "Ignore errors, which match the given regular expression(s)" };
public CliOption<FileInfo> IgnoreErrorFile { get; } =
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();
public CliOption<bool> Statistics { get; } =
public Option<FileInfo> IgnoreErrorFile { get; } =
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();
public Option<bool> Statistics { get; } =
new("--statistics") { Description = "Print verification statistics" };
public CliOption<bool> Verbose { get; } =
public Option<bool> Verbose { get; } =
new("--verbose") { Description = "Verbose output" };
public CliOption<bool> Tokens { get; } =
public Option<bool> Tokens { get; } =
new("--tokens", "-t") { Description = "Include metadata tokens in error messages" };

public ParseResult Result;
Expand Down
6 changes: 3 additions & 3 deletions src/coreclr/tools/ILVerify/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -475,11 +475,11 @@ public PEReader Resolve(string simpleName)
return null;
}

private T Get<T>(CliOption<T> option) => _command.Result.GetValue(option);
private T Get<T>(CliArgument<T> argument) => _command.Result.GetValue(argument);
private T Get<T>(Option<T> option) => _command.Result.GetValue(option);
private T Get<T>(Argument<T> argument) => _command.Result.GetValue(argument);

private static int Main(string[] args) =>
new CliConfiguration(new ILVerifyRootCommand().UseVersion())
new CommandLineConfiguration(new ILVerifyRootCommand().UseVersion())
{
ResponseFileTokenReplacer = Helpers.TryReadResponseFile,
EnableDefaultExceptionHandler = false,
Expand Down
Loading
Loading