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

Revert "System.CommandLine update" #77078

Merged
merged 1 commit into from
Feb 6, 2025
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
8 changes: 4 additions & 4 deletions eng/Version.Details.xml
Original file line number Diff line number Diff line change
Expand Up @@ -13,14 +13,14 @@
<Sha>3f926184cacc477e3ddccd1eb4f3ebcb9a2b81a5</Sha>
<SourceBuild RepoName="source-build-reference-packages" ManagedOnly="true" />
</Dependency>
<Dependency Name="System.CommandLine" Version="2.0.0-beta4.25072.1">
<Dependency Name="System.CommandLine" Version="2.0.0-beta4.24528.1">
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What's the reason for the revert?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@adamsitnik you might want to mention the reason for the revert in an issue somewhere (maybe in command-line-api) and then link to that in all the revert PRs.

Copy link
Member Author

@adamsitnik adamsitnik Feb 6, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Short answer: chicken-and-egg problem with the update in SDK and NuGet.Client repos.

Long answer: The breaking change introduced in System.CommandLine requires an update to SDK, which uses both System.CommandLine and NuGet.CommandLine.XPlat (a NuGet package from NuGet.Client repo that also relies on System.CommandLine). NuGet.Client repo uses a hardcoded version of SDK (9.0.2) to run their integration tests, which is using an older version of System.CommandLine and fails at runtime (because the types have been renamed). The NuGet.Client repo release schedule is not tied to .NET, but to VS, so their dev branch updates flow to both SDK/main and SDK/release/9.0.x. Unblocking the flow would require them to create dedicated branches (and cause a lot of work to sync all the changes), or use a workaround with multi-targeting (NuGet/NuGet.Client#6252). It was decided that the simplest solution will be to just wait until NuGet.Client creates a new branch for next VS release in April.

<Uri>https://github.com/dotnet/command-line-api</Uri>
<Sha>060374e56c1b2e741b6525ca8417006efb54fbd7</Sha>
<Sha>feb61c7f328a2401d74f4317b39d02126cfdfe24</Sha>
</Dependency>
<!-- Intermediate is necessary for source build. -->
<Dependency Name="Microsoft.SourceBuild.Intermediate.command-line-api" Version="0.1.607201">
<Dependency Name="Microsoft.SourceBuild.Intermediate.command-line-api" Version="0.1.552801">
<Uri>https://github.com/dotnet/command-line-api</Uri>
<Sha>060374e56c1b2e741b6525ca8417006efb54fbd7</Sha>
<Sha>feb61c7f328a2401d74f4317b39d02126cfdfe24</Sha>
<SourceBuild RepoName="command-line-api" ManagedOnly="true" />
</Dependency>
<!-- Necessary for source-build. This allows the live version of the package to be used by source-build. -->
Expand Down
2 changes: 1 addition & 1 deletion eng/Versions.props
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@
Versions managed by Arcade (see Versions.Details.xml)
-->
<PropertyGroup>
<SystemCommandLineVersion>2.0.0-beta4.25072.1</SystemCommandLineVersion>
<SystemCommandLineVersion>2.0.0-beta4.24528.1</SystemCommandLineVersion>
<SystemCompositionVersion>8.0.0</SystemCompositionVersion>
<SystemConfigurationConfigurationManagerVersion>8.0.0</SystemConfigurationConfigurationManagerVersion>
<SystemDiagnosticsEventLogVersion>8.0.0</SystemDiagnosticsEventLogVersion>
Expand Down
16 changes: 8 additions & 8 deletions src/Features/Lsif/Generator/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -26,17 +26,17 @@ internal static class Program
{
public static Task Main(string[] args)
{
var solution = new Option<FileInfo>("--solution") { Description = "input solution file" }.AcceptExistingOnly();
var project = new Option<FileInfo>("--project") { Description = "input project file" }.AcceptExistingOnly();
var compilerInvocation = new Option<FileInfo>("--compiler-invocation") { Description = "path to a .json file that contains the information for a csc/vbc invocation" }.AcceptExistingOnly();
var binLog = new Option<FileInfo>("--binlog") { Description = "path to a MSBuild binlog that csc/vbc invocations will be extracted from" }.AcceptExistingOnly();
var output = new Option<string?>("--output") { Description = "file to write the LSIF output to, instead of the console", DefaultValueFactory = _ => null };
var solution = new CliOption<FileInfo>("--solution") { Description = "input solution file" }.AcceptExistingOnly();
var project = new CliOption<FileInfo>("--project") { Description = "input project file" }.AcceptExistingOnly();
var compilerInvocation = new CliOption<FileInfo>("--compiler-invocation") { Description = "path to a .json file that contains the information for a csc/vbc invocation" }.AcceptExistingOnly();
var binLog = new CliOption<FileInfo>("--binlog") { Description = "path to a MSBuild binlog that csc/vbc invocations will be extracted from" }.AcceptExistingOnly();
var output = new CliOption<string?>("--output") { Description = "file to write the LSIF output to, instead of the console", DefaultValueFactory = _ => null };
output.AcceptLegalFilePathsOnly();
var outputFormat = new Option<LsifFormat>("--output-format") { Description = "format of LSIF output", DefaultValueFactory = _ => LsifFormat.Line };
var log = new Option<string?>("--log") { Description = "file to write a log to", DefaultValueFactory = _ => null };
var outputFormat = new CliOption<LsifFormat>("--output-format") { Description = "format of LSIF output", DefaultValueFactory = _ => LsifFormat.Line };
var log = new CliOption<string?>("--log") { Description = "file to write a log to", DefaultValueFactory = _ => null };
log.AcceptLegalFilePathsOnly();

var generateCommand = new RootCommand("generates an LSIF file")
var generateCommand = new CliRootCommand("generates an LSIF file")
{
solution,
project,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
using Microsoft.CodeAnalysis.LanguageServer.Logging;
using Microsoft.CodeAnalysis.LanguageServer.Services;
using Microsoft.CodeAnalysis.LanguageServer.StarredSuggestions;
using Microsoft.CodeAnalysis.Options;
using Microsoft.Extensions.Logging;
using Microsoft.Extensions.Logging.Console;
using Roslyn.Utilities;
Expand Down Expand Up @@ -102,7 +103,7 @@ static async Task RunAsync(ServerConfiguration serverConfiguration, Cancellation

// LSP server doesn't have the pieces yet to support 'balanced' mode for source-generators. Hardcode us to
// 'automatic' for now.
var globalOptionService = exportProvider.GetExportedValue<Microsoft.CodeAnalysis.Options.IGlobalOptionService>();
var globalOptionService = exportProvider.GetExportedValue<IGlobalOptionService>();
globalOptionService.SetGlobalOption(WorkspaceConfigurationOptionsStorage.SourceGeneratorExecution, SourceGeneratorExecutionPreference.Automatic);

// The log file directory passed to us by VSCode might not exist yet, though its parent directory is guaranteed to exist.
Expand Down Expand Up @@ -180,87 +181,87 @@ static async Task RunAsync(ServerConfiguration serverConfiguration, Cancellation
}
}

static RootCommand CreateCommandLineParser()
static CliRootCommand CreateCommandLineParser()
{
var debugOption = new Option<bool>("--debug")
var debugOption = new CliOption<bool>("--debug")
{
Description = "Flag indicating if the debugger should be launched on startup.",
Required = false,
DefaultValueFactory = _ => false,
};
var brokeredServicePipeNameOption = new Option<string?>("--brokeredServicePipeName")
var brokeredServicePipeNameOption = new CliOption<string?>("--brokeredServicePipeName")
{
Description = "The name of the pipe used to connect to a remote process (if one exists).",
Required = false,
};

var logLevelOption = new Option<LogLevel>("--logLevel")
var logLevelOption = new CliOption<LogLevel>("--logLevel")
{
Description = "The minimum log verbosity.",
Required = true,
};
var starredCompletionsPathOption = new Option<string?>("--starredCompletionComponentPath")
var starredCompletionsPathOption = new CliOption<string?>("--starredCompletionComponentPath")
{
Description = "The location of the starred completion component (if one exists).",
Required = false,
};

var telemetryLevelOption = new Option<string?>("--telemetryLevel")
var telemetryLevelOption = new CliOption<string?>("--telemetryLevel")
{
Description = "Telemetry level, Defaults to 'off'. Example values: 'all', 'crash', 'error', or 'off'.",
Required = false,
};
var extensionLogDirectoryOption = new Option<string>("--extensionLogDirectory")
var extensionLogDirectoryOption = new CliOption<string>("--extensionLogDirectory")
{
Description = "The directory where we should write log files to",
Required = true,
};

var sessionIdOption = new Option<string?>("--sessionId")
var sessionIdOption = new CliOption<string?>("--sessionId")
{
Description = "Session Id to use for telemetry",
Required = false
};

var extensionAssemblyPathsOption = new Option<string[]?>("--extension")
var extensionAssemblyPathsOption = new CliOption<string[]?>("--extension")
{
Description = "Full paths of extension assemblies to load (optional).",
Required = false
};

var devKitDependencyPathOption = new Option<string?>("--devKitDependencyPath")
var devKitDependencyPathOption = new CliOption<string?>("--devKitDependencyPath")
{
Description = "Full path to the Roslyn dependency used with DevKit (optional).",
Required = false
};

var razorSourceGeneratorOption = new Option<string?>("--razorSourceGenerator")
var razorSourceGeneratorOption = new CliOption<string?>("--razorSourceGenerator")
{
Description = "Full path to the Razor source generator (optional).",
Required = false
};

var razorDesignTimePathOption = new Option<string?>("--razorDesignTimePath")
var razorDesignTimePathOption = new CliOption<string?>("--razorDesignTimePath")
{
Description = "Full path to the Razor design time target path (optional).",
Required = false
};

var serverPipeNameOption = new Option<string?>("--pipe")
var serverPipeNameOption = new CliOption<string?>("--pipe")
{
Description = "The name of the pipe the server will connect to.",
Required = false
};

var useStdIoOption = new Option<bool>("--stdio")
var useStdIoOption = new CliOption<bool>("--stdio")
{
Description = "Use stdio for communication with the client.",
Required = false,
DefaultValueFactory = _ => false,

};

var rootCommand = new RootCommand()
var rootCommand = new CliRootCommand()
{
debugOption,
brokeredServicePipeNameOption,
Expand Down
18 changes: 9 additions & 9 deletions src/Tools/BuildValidator/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -31,45 +31,45 @@ static int Main(string[] args)
{
System.Diagnostics.Trace.Listeners.Clear();

var assembliesPath = new Option<string[]>("--assembliesPath")
var assembliesPath = new CliOption<string[]>("--assembliesPath")
{
Description = BuildValidatorResources.Path_to_assemblies_to_rebuild_can_be_specified_one_or_more_times,
Required = true,
Arity = ArgumentArity.OneOrMore,
};
var exclude = new Option<string[]>("--exclude")
var exclude = new CliOption<string[]>("--exclude")
{
Description = BuildValidatorResources.Assemblies_to_be_excluded_substring_match,
Arity = ArgumentArity.ZeroOrMore,
};
var source = new Option<string>("--sourcePath")
var source = new CliOption<string>("--sourcePath")
{
Description = BuildValidatorResources.Path_to_sources_to_use_in_rebuild,
Required = true,
};
var referencesPath = new Option<string[]>("--referencesPath")
var referencesPath = new CliOption<string[]>("--referencesPath")
{
Description = BuildValidatorResources.Path_to_referenced_assemblies_can_be_specified_zero_or_more_times,
Arity = ArgumentArity.ZeroOrMore,
};
var verbose = new Option<bool>("--verbose")
var verbose = new CliOption<bool>("--verbose")
{
Description = BuildValidatorResources.Output_verbose_log_information
};
var quiet = new Option<bool>("--quiet")
var quiet = new CliOption<bool>("--quiet")
{
Description = BuildValidatorResources.Do_not_output_log_information_to_console
};
var debug = new Option<bool>("--debug")
var debug = new CliOption<bool>("--debug")
{
Description = BuildValidatorResources.Output_debug_info_when_rebuild_is_not_equal_to_the_original
};
var debugPath = new Option<string?>("--debugPath")
var debugPath = new CliOption<string?>("--debugPath")
{
Description = BuildValidatorResources.Path_to_output_debug_info
};

var rootCommand = new RootCommand
var rootCommand = new CliRootCommand
{
assembliesPath,
exclude,
Expand Down
10 changes: 5 additions & 5 deletions src/Workspaces/MSBuild/BuildHost/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -16,11 +16,11 @@ internal static class Program
{
internal static async Task Main(string[] args)
{
var pipeOption = new Option<string>("--pipe") { Required = true };
var propertyOption = new Option<string[]>("--property") { Arity = ArgumentArity.ZeroOrMore };
var binaryLogOption = new Option<string?>("--binlog") { Required = false };
var localeOption = new Option<string>("--locale") { Required = true };
var command = new RootCommand { pipeOption, binaryLogOption, propertyOption, localeOption };
var pipeOption = new CliOption<string>("--pipe") { Required = true };
var propertyOption = new CliOption<string[]>("--property") { Arity = ArgumentArity.ZeroOrMore };
var binaryLogOption = new CliOption<string?>("--binlog") { Required = false };
var localeOption = new CliOption<string>("--locale") { Required = true };
var command = new CliRootCommand { pipeOption, binaryLogOption, propertyOption, localeOption };
var parsedArguments = command.Parse(args);
var pipeName = parsedArguments.GetValue(pipeOption)!;
var properties = parsedArguments.GetValue(propertyOption)!;
Expand Down