Skip to content

Commit 3eec09e

Browse files
authored
Revert "[main] Update dependencies from dotnet/command-line-api (#29131)" (#33146)
2 parents 593714c + 55a3ee0 commit 3eec09e

File tree

191 files changed

+3065
-3366
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

191 files changed

+3065
-3366
lines changed

eng/Version.Details.xml

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -321,13 +321,13 @@
321321
<Sha>2f0301ef59624a72fb00f7fd92caa50be03f277d</Sha>
322322
<SourceBuild RepoName="roslyn-analyzers" ManagedOnly="true" />
323323
</Dependency>
324-
<Dependency Name="System.CommandLine" Version="2.0.0-beta4.23307.1">
324+
<Dependency Name="System.CommandLine" Version="2.0.0-beta4.22564.1">
325325
<Uri>https://github.com/dotnet/command-line-api</Uri>
326-
<Sha>02fe27cd6a9b001c8feb7938e6ef4b3799745759</Sha>
326+
<Sha>8374d5fca634a93458c84414b1604c12f765d1ab</Sha>
327327
</Dependency>
328-
<Dependency Name="Microsoft.SourceBuild.Intermediate.command-line-api" Version="0.1.430701">
328+
<Dependency Name="Microsoft.SourceBuild.Intermediate.command-line-api" Version="0.1.356401">
329329
<Uri>https://github.com/dotnet/command-line-api</Uri>
330-
<Sha>02fe27cd6a9b001c8feb7938e6ef4b3799745759</Sha>
330+
<Sha>8374d5fca634a93458c84414b1604c12f765d1ab</Sha>
331331
<SourceBuild RepoName="command-line-api" ManagedOnly="true" />
332332
</Dependency>
333333
<Dependency Name="Microsoft.SourceBuild.Intermediate.source-build-externals" Version="8.0.0-alpha.1.23305.2">

eng/Versions.props

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@
3939
<SystemTextJsonVersion>7.0.2</SystemTextJsonVersion>
4040
<SystemReflectionMetadataLoadContextVersion>8.0.0-preview.6.23309.1</SystemReflectionMetadataLoadContextVersion>
4141
<SystemManagementPackageVersion>4.6.0</SystemManagementPackageVersion>
42-
<SystemCommandLineVersion>2.0.0-beta4.23307.1</SystemCommandLineVersion>
42+
<SystemCommandLineVersion>2.0.0-beta4.22564.1</SystemCommandLineVersion>
4343
<MicrosoftDeploymentDotNetReleasesVersion>1.0.0-preview.6.23206.1</MicrosoftDeploymentDotNetReleasesVersion>
4444
<MicrosoftVisualStudioSetupConfigurationInteropVersion>3.2.2146</MicrosoftVisualStudioSetupConfigurationInteropVersion>
4545
</PropertyGroup>

src/ApiCompat/Microsoft.DotNet.ApiCompat.Shared/ValidatePackage.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ public static void Run(Func<ISuppressionEngine, ISuppressableLog> logFactory,
2222
bool enableRuleAttributesMustMatch,
2323
string[]? excludeAttributesFiles,
2424
bool enableRuleCannotChangeParameterName,
25-
string? packagePath,
25+
string packagePath,
2626
bool runApiCompat,
2727
bool enableStrictModeForCompatibleTfms,
2828
bool enableStrictModeForCompatibleFrameworksInPackage,

src/ApiCompat/Microsoft.DotNet.ApiCompat.Tool/Program.cs

Lines changed: 159 additions & 196 deletions
Large diffs are not rendered by default.

src/BlazorWasmSdk/Tool/Program.cs

Lines changed: 20 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,8 @@
44
using System;
55
using System.Collections.Generic;
66
using System.CommandLine;
7+
using System.CommandLine.Invocation;
8+
using System.CommandLine.Parsing;
79
using System.IO;
810
using System.IO.Compression;
911
using System.Threading.Tasks;
@@ -14,22 +16,23 @@ internal static class Program
1416
{
1517
public static int Main(string[] args)
1618
{
17-
CliRootCommand rootCommand = new();
18-
CliCommand brotli = new("brotli");
19+
var rootCommand = new RootCommand();
20+
var brotli = new Command("brotli");
1921

20-
CliOption<CompressionLevel> compressionLevelOption = new("-c")
22+
var compressionLevelOption = new Option<CompressionLevel>(
23+
"-c",
24+
defaultValueFactory: () => CompressionLevel.SmallestSize,
25+
description: "System.IO.Compression.CompressionLevel for the Brotli compression algorithm.");
26+
var sourcesOption = new Option<List<string>>(
27+
"-s",
28+
description: "A list of files to compress.")
2129
{
22-
DefaultValueFactory = _ => CompressionLevel.SmallestSize,
23-
Description = "System.IO.Compression.CompressionLevel for the Brotli compression algorithm.",
24-
};
25-
CliOption<List<string>> sourcesOption = new("-s")
26-
{
27-
Description = "A list of files to compress.",
2830
AllowMultipleArgumentsPerToken = false
2931
};
30-
CliOption<List<string>> outputsOption = new("-o")
32+
var outputsOption = new Option<List<string>>(
33+
"-o",
34+
"The filenames to output the compressed file to.")
3135
{
32-
Description = "The filenames to output the compressed file to.",
3336
AllowMultipleArgumentsPerToken = false
3437
};
3538

@@ -39,11 +42,12 @@ public static int Main(string[] args)
3942

4043
rootCommand.Add(brotli);
4144

42-
brotli.SetAction((ParseResult parseResult) =>
45+
brotli.SetHandler((InvocationContext context) =>
4346
{
44-
var c = parseResult.GetValue(compressionLevelOption);
45-
var s = parseResult.GetValue(sourcesOption);
46-
var o = parseResult.GetValue(outputsOption);
47+
var parseResults = context.ParseResult;
48+
var c = parseResults.GetValue(compressionLevelOption);
49+
var s = parseResults.GetValue(sourcesOption);
50+
var o = parseResults.GetValue(outputsOption);
4751

4852
Parallel.For(0, s.Count, i =>
4953
{
@@ -65,7 +69,7 @@ public static int Main(string[] args)
6569
});
6670
});
6771

68-
return rootCommand.Parse(args).Invoke();
72+
return rootCommand.InvokeAsync(args).Result;
6973
}
7074
}
7175
}

src/BuiltInTools/dotnet-watch/CommandLineOptions.cs

Lines changed: 58 additions & 80 deletions
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,10 @@
66
using System;
77
using System.Collections.Generic;
88
using System.CommandLine;
9-
using System.IO;
9+
using System.CommandLine.Invocation;
1010
using System.Linq;
11+
12+
using Microsoft.AspNetCore.Authentication;
1113
using Microsoft.DotNet.Watcher.Tools;
1214
using Microsoft.Extensions.Tools.Internal;
1315

@@ -75,131 +77,112 @@ dotnet watch test
7577
public required IReadOnlyList<string> RemainingArguments { get; init; }
7678
public RunCommandLineOptions? RunOptions { get; init; }
7779

78-
public static CommandLineOptions? Parse(string[] args, IReporter reporter, out int errorCode, TextWriter? output = null, TextWriter? error = null)
80+
public static CommandLineOptions? Parse(string[] args, IReporter reporter, out int errorCode, System.CommandLine.IConsole? console = null)
7981
{
80-
var quietOption = new CliOption<bool>("--quiet", "-q")
81-
{
82-
Description = "Suppresses all output except warnings and errors"
83-
};
82+
var quietOption = new Option<bool>(new[] { "--quiet", "-q" }, "Suppresses all output except warnings and errors");
83+
var verboseOption = new Option<bool>(new[] { "--verbose", "-v" }, "Show verbose output");
8484

85-
var verboseOption = new CliOption<bool>("--verbose", "-v")
85+
verboseOption.AddValidator(v =>
8686
{
87-
Description = "Show verbose output"
88-
};
89-
90-
verboseOption.Validators.Add(v =>
91-
{
92-
if (v.GetResult(quietOption) is not null && v.GetResult(verboseOption) is not null)
87+
if (v.FindResultFor(quietOption) is not null && v.FindResultFor(verboseOption) is not null)
9388
{
94-
v.AddError(Resources.Error_QuietAndVerboseSpecified);
89+
v.ErrorMessage = Resources.Error_QuietAndVerboseSpecified;
9590
}
9691
});
9792

98-
var listOption = new CliOption<bool>("--list") { Description = "Lists all discovered files without starting the watcher." };
99-
var shortProjectOption = new CliOption<string>("-p") { Description = "The project to watch.", Hidden = true };
100-
var longProjectOption = new CliOption<string>("--project") { Description = "The project to watch" };
93+
var listOption = new Option<bool>("--list", "Lists all discovered files without starting the watcher.");
94+
var shortProjectOption = new Option<string>("-p", "The project to watch.") { IsHidden = true };
95+
var longProjectOption = new Option<string>("--project", "The project to watch");
10196

10297
// launch profile used by dotnet-watch
103-
var launchProfileWatchOption = new CliOption<string>(LaunchProfileOptionName, "-lp")
104-
{
105-
Description = "The launch profile to start the project with (case-sensitive)."
106-
};
107-
var noLaunchProfileWatchOption = new CliOption<bool>(NoLaunchProfileOptionName)
108-
{
109-
Description = "Do not attempt to use launchSettings.json to configure the application."
110-
};
98+
var launchProfileWatchOption = new Option<string>(new[] { "-lp", LaunchProfileOptionName }, "The launch profile to start the project with (case-sensitive).");
99+
var noLaunchProfileWatchOption = new Option<bool>(new[] { NoLaunchProfileOptionName }, "Do not attempt to use launchSettings.json to configure the application.");
111100

112101
// launch profile used by dotnet-run
113-
var launchProfileRunOption = new CliOption<string>(LaunchProfileOptionName, "-lp") { Hidden = true };
114-
var noLaunchProfileRunOption = new CliOption<bool>(NoLaunchProfileOptionName) { Hidden = true };
102+
var launchProfileRunOption = new Option<string>(new[] { "-lp", LaunchProfileOptionName }) { IsHidden = true };
103+
var noLaunchProfileRunOption = new Option<bool>(new[] { NoLaunchProfileOptionName }) { IsHidden = true };
115104

116-
var targetFrameworkOption = new CliOption<string>("--framework", "-f")
117-
{
118-
Description = "The target framework to run for. The target framework must also be specified in the project file."
119-
};
120-
var propertyOption = new CliOption<string[]>("--property")
121-
{
122-
Description = "Properties to be passed to MSBuild."
123-
};
105+
var targetFrameworkOption = new Option<string>(new[] { "-f", "--framework" }, "The target framework to run for. The target framework must also be specified in the project file.");
106+
var propertyOption = new Option<string[]>(new[] { "--property" }, "Properties to be passed to MSBuild.");
124107

125-
propertyOption.Validators.Add(v =>
108+
propertyOption.AddValidator(v =>
126109
{
127110
var invalidProperty = v.GetValue(propertyOption)?.FirstOrDefault(
128111
property => !(property.IndexOf('=') is > 0 and var index && index < property.Length - 1 && property[..index].Trim().Length > 0));
129112

130113
if (invalidProperty != null)
131114
{
132-
v.AddError($"Invalid property format: '{invalidProperty}'. Expected 'name=value'.");
115+
v.ErrorMessage = $"Invalid property format: '{invalidProperty}'. Expected 'name=value'.";
133116
}
134117
});
135118

136-
var noHotReloadOption = new CliOption<bool>("--no-hot-reload") { Description = "Suppress hot reload for supported apps." };
137-
var nonInteractiveOption = new CliOption<bool>("--non-interactive")
138-
{
139-
Description = "Runs dotnet-watch in non-interactive mode. This option is only supported when running with Hot Reload enabled. " +
140-
"Use this option to prevent console input from being captured."
141-
};
119+
var noHotReloadOption = new Option<bool>("--no-hot-reload", "Suppress hot reload for supported apps.");
120+
var nonInteractiveOption = new Option<bool>(
121+
"--non-interactive",
122+
"Runs dotnet-watch in non-interactive mode. This option is only supported when running with Hot Reload enabled. " +
123+
"Use this option to prevent console input from being captured.");
142124

143-
var remainingWatchArgs = new CliArgument<string[]>("forwardedArgs") { Description = "Arguments to pass to the child dotnet process." };
144-
var remainingRunArgs = new CliArgument<string[]>("remainingRunArgs");
125+
var remainingWatchArgs = new Argument<string[]>("forwardedArgs", "Arguments to pass to the child dotnet process.");
126+
var remainingRunArgs = new Argument<string[]>(name: null);
145127

146-
var runCommand = new CliCommand("run") { Hidden = true };
147-
var rootCommand = new CliRootCommand(Description);
148-
AddSymbols(runCommand);
149-
AddSymbols(rootCommand);
128+
var runCommand = new Command("run") { IsHidden = true };
129+
var rootCommand = new RootCommand(Description);
130+
addOptions(runCommand);
131+
addOptions(rootCommand);
150132

151-
void AddSymbols(CliCommand command)
133+
void addOptions(Command command)
152134
{
153-
command.Options.Add(quietOption);
154-
command.Options.Add(verboseOption);
155-
command.Options.Add(noHotReloadOption);
156-
command.Options.Add(nonInteractiveOption);
157-
command.Options.Add(longProjectOption);
158-
command.Options.Add(shortProjectOption);
135+
command.Add(quietOption);
136+
command.Add(verboseOption);
137+
command.Add(noHotReloadOption);
138+
command.Add(nonInteractiveOption);
139+
command.Add(longProjectOption);
140+
command.Add(shortProjectOption);
159141

160142
if (command == runCommand)
161143
{
162-
command.Options.Add(launchProfileRunOption);
163-
command.Options.Add(noLaunchProfileRunOption);
144+
command.Add(launchProfileRunOption);
145+
command.Add(noLaunchProfileRunOption);
164146
}
165147
else
166148
{
167-
command.Options.Add(launchProfileWatchOption);
168-
command.Options.Add(noLaunchProfileWatchOption);
149+
command.Add(launchProfileWatchOption);
150+
command.Add(noLaunchProfileWatchOption);
169151
}
170152

171-
command.Options.Add(targetFrameworkOption);
172-
command.Options.Add(propertyOption);
153+
command.Add(targetFrameworkOption);
154+
command.Add(propertyOption);
173155

174-
command.Options.Add(listOption);
156+
command.Add(listOption);
175157

176158
if (command == runCommand)
177159
{
178-
command.Arguments.Add(remainingRunArgs);
160+
command.Add(remainingRunArgs);
179161
}
180162
else
181163
{
182-
command.Subcommands.Add(runCommand);
183-
command.Arguments.Add(remainingWatchArgs);
164+
command.Add(runCommand);
165+
command.Add(remainingWatchArgs);
184166
}
185167
};
186168

187169
CommandLineOptions? options = null;
188170

189-
runCommand.SetAction(parseResult =>
171+
runCommand.SetHandler(context =>
190172
{
191-
RootHandler(parseResult, new()
173+
RootHandler(context, new()
192174
{
193-
LaunchProfileName = parseResult.GetValue(launchProfileRunOption),
194-
NoLaunchProfile = parseResult.GetValue(noLaunchProfileRunOption),
195-
RemainingArguments = parseResult.GetValue(remainingRunArgs) ?? Array.Empty<string>(),
175+
LaunchProfileName = context.ParseResult.GetValue(launchProfileRunOption),
176+
NoLaunchProfile = context.ParseResult.GetValue(noLaunchProfileRunOption),
177+
RemainingArguments = context.ParseResult.GetValue(remainingRunArgs),
196178
});
197179
});
198180

199-
rootCommand.SetAction(parseResult => RootHandler(parseResult, runOptions: null));
181+
rootCommand.SetHandler(context => RootHandler(context, runOptions: null));
200182

201-
void RootHandler(ParseResult parseResults, RunCommandLineOptions? runOptions)
183+
void RootHandler(InvocationContext context, RunCommandLineOptions? runOptions)
202184
{
185+
var parseResults = context.ParseResult;
203186
var projectValue = parseResults.GetValue(longProjectOption);
204187
if (string.IsNullOrEmpty(projectValue))
205188
{
@@ -224,17 +207,12 @@ void RootHandler(ParseResult parseResults, RunCommandLineOptions? runOptions)
224207
TargetFramework = parseResults.GetValue(targetFrameworkOption),
225208
BuildProperties = parseResults.GetValue(propertyOption)?
226209
.Select(p => (p[..p.IndexOf('=')].Trim(), p[(p.IndexOf('=') + 1)..])).ToArray(),
227-
RemainingArguments = parseResults.GetValue(remainingWatchArgs) ?? Array.Empty<string>(),
210+
RemainingArguments = parseResults.GetValue(remainingWatchArgs),
228211
RunOptions = runOptions,
229212
};
230213
}
231214

232-
errorCode = new CliConfiguration(rootCommand)
233-
{
234-
Output = output ?? Console.Out,
235-
Error = error ?? Console.Error
236-
}.Invoke(args);
237-
215+
errorCode = rootCommand.Invoke(args, console);
238216
return options;
239217
}
240218

src/Cli/Microsoft.DotNet.Cli.Utils/Extensions/StringExtensions.cs

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

0 commit comments

Comments
 (0)