Skip to content

Commit

Permalink
Change from "sln" to "solution" as primary, and add "sln" as alias (d…
Browse files Browse the repository at this point in the history
  • Loading branch information
nagilson authored Oct 18, 2024
2 parents cf30ac2 + 528ec3d commit 41c6d4b
Show file tree
Hide file tree
Showing 15 changed files with 544 additions and 360 deletions.
6 changes: 3 additions & 3 deletions src/BuiltInTools/dotnet-watch/CommandLineOptions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ internal sealed class CommandLineOptions
"restore",
"run",
"sdk",
"sln",
"solution",
"store",
"test",
"tool",
Expand Down Expand Up @@ -179,7 +179,7 @@ internal sealed class CommandLineOptions
BuildProperties = ParseBuildProperties(parseResult.GetValue(propertyOption) ?? []).ToArray(),
};

// Parses name=value pairs passed to --property. Skips invalid input.
// Parses name=value pairs passed to --property. Skips invalid input.
// We don't report error here as it will be reported by dotnet run.
static IEnumerable<(string key, string value)> ParseBuildProperties(string[] properties)
=> from property in properties
Expand Down Expand Up @@ -240,7 +240,7 @@ private static IReadOnlyList<string> GetCommandArguments(
{
explicitCommand = token;
}
else
else
{
if (!dashDashInserted && i >= unmatchedTokensBeforeDashDash)
{
Expand Down
2 changes: 1 addition & 1 deletion src/Cli/dotnet-new3/Dotnet.cs
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ internal static Dotnet AddProjectsToSolution(string solutionFile, IReadOnlyList<
{
List<string> allArgs = new()
{
"sln",
"solution",
solutionFile,
"add"
};
Expand Down
10 changes: 5 additions & 5 deletions src/Cli/dotnet/ReleasePropertyProjectLocator.cs
Original file line number Diff line number Diff line change
Expand Up @@ -138,7 +138,7 @@ public IEnumerable<string> GetCustomDefaultConfigurationValueIfSpecified()
}
}
}
return null; // If nothing can be found: that's caught by MSBuild XMake::ProcessProjectSwitch -- don't change the behavior by failing here.
return null; // If nothing can be found: that's caught by MSBuild XMake::ProcessProjectSwitch -- don't change the behavior by failing here.
}

/// <returns>An arbitrary existant project in a solution file. Returns null if no projects exist.
Expand Down Expand Up @@ -205,7 +205,7 @@ public IEnumerable<string> GetCustomDefaultConfigurationValueIfSpecified()
/// <summary>
/// Returns an arbitrary project for the solution. Relies on the .NET SDK PrepareForPublish or _VerifyPackReleaseConfigurations MSBuild targets to catch conflicting values of a given property, like PublishRelease or PackRelease.
/// </summary>
/// <param name="sln">The solution to get an arbitrary project from.</param>
/// <param name="solution">The solution to get an arbitrary project from.</param>
/// <param name="globalProps">The global properties to load into the project.</param>
/// <returns>null if no project exists in the solution that can be evaluated properly. Else, the first project in the solution that can be.</returns>
private ProjectInstance? GetSingleProjectFromSolution(SlnFile sln, Dictionary<string, string> globalProps)
Expand Down Expand Up @@ -253,13 +253,13 @@ private bool IsUnanalyzableProjectInSolution(SlnProject project, string projectF
return null;
}

/// <returns>Returns true if the path exists and is a project file type.</returns>
/// <returns>Returns true if the path exists and is a project file type.</returns>
private bool IsValidProjectFilePath(string path)
{
return File.Exists(path) && Path.GetExtension(path).EndsWith("proj");
}

/// <returns>Returns true if the path exists and is a sln file type.</returns>
/// <returns>Returns true if the path exists and is a sln file type.</returns>
private bool IsValidSlnFilePath(string path)
{
return File.Exists(path) && Path.GetExtension(path).EndsWith("sln");
Expand All @@ -271,7 +271,7 @@ private Dictionary<string, string> GetUserSpecifiedExplicitMSBuildProperties()
Dictionary<string, string> globalProperties = new(StringComparer.OrdinalIgnoreCase);

string[]? globalPropEnumerable = _parseResult.GetValue(CommonOptions.PropertiesOption);

if ( globalPropEnumerable != null )
{
foreach (var keyEqValString in globalPropEnumerable)
Expand Down
2 changes: 1 addition & 1 deletion src/Cli/dotnet/Telemetry/TelemetryFilter.cs
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ public IEnumerable<ApplicationInsightsEntryFormat> Filter(object objectToFilter)
private static List<IParseResultLogRule> ParseResultLogRules => new()
{
new AllowListToSendFirstArgument(new HashSet<string> {"new", "help"}),
new AllowListToSendFirstAppliedOptions(new HashSet<string> {"add", "remove", "list", "sln", "nuget"}),
new AllowListToSendFirstAppliedOptions(new HashSet<string> {"add", "remove", "list", "solution", "nuget"}),
new TopLevelCommandNameAndOptionToLog
(
topLevelCommandName: new HashSet<string> {"build", "publish"},
Expand Down
2 changes: 1 addition & 1 deletion src/Cli/dotnet/commands/dotnet-help/HelpUsageText.cs
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ internal static class HelpUsageText
restore {LocalizableStrings.RestoreDefinition}
run {LocalizableStrings.RunDefinition}
sdk {LocalizableStrings.SdkDefinition}
sln {LocalizableStrings.SlnDefinition}
solution {LocalizableStrings.SlnDefinition}
store {LocalizableStrings.StoreDefinition}
test {LocalizableStrings.TestDefinition}
tool {LocalizableStrings.ToolDefinition}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ internal static bool AddProjectsToSolution(string solutionPath, IReadOnlyList<st
{
PathUtility.EnsureAllPathsExist(new[] { solutionPath }, CommonLocalizableStrings.FileNotFound, allowDirectories: false);
PathUtility.EnsureAllPathsExist(projectsToAdd, CommonLocalizableStrings.FileNotFound, allowDirectories: false);
IEnumerable<string> commandArgs = new[] { "sln", solutionPath, "add" }.Concat(projectsToAdd);
IEnumerable<string> commandArgs = new[] { "solution", solutionPath, "add" }.Concat(projectsToAdd);
if (!string.IsNullOrWhiteSpace(solutionFolder))
{
commandArgs = commandArgs.Append(SlnAddParser.SolutionFolderOption.Name).Append(solutionFolder);
Expand Down
2 changes: 1 addition & 1 deletion src/Cli/dotnet/commands/dotnet-sln/SlnArgumentValidator.cs
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ public static void ParseAndValidateArguments(string _fileOrDirectory, IReadOnlyC
{
string.Format(CommonLocalizableStrings.SolutionArgumentMisplaced, slnFile),
CommonLocalizableStrings.DidYouMean,
$" dotnet sln {slnFile} {command} {args}{projectArgs}"
$" dotnet solution {slnFile} {command} {args}{projectArgs}"
});
}
}
Expand Down
7 changes: 6 additions & 1 deletion src/Cli/dotnet/commands/dotnet-sln/SlnCommandParser.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
// The .NET Foundation licenses this file to you under the MIT license.

using System.CommandLine;
using NuGet.Packaging;
using LocalizableStrings = Microsoft.DotNet.Tools.Sln.LocalizableStrings;

namespace Microsoft.DotNet.Cli
Expand All @@ -10,6 +11,8 @@ internal static class SlnCommandParser
{
public static readonly string DocsLink = "https://aka.ms/dotnet-sln";

public static readonly string CommandName = "solution";
public static readonly string CommandAlias = "sln";
public static readonly CliArgument<string> SlnArgument = new CliArgument<string>(LocalizableStrings.SolutionArgumentName)
{
HelpName = LocalizableStrings.SolutionArgumentName,
Expand All @@ -26,7 +29,9 @@ public static CliCommand GetCommand()

private static CliCommand ConstructCommand()
{
DocumentedCommand command = new("sln", DocsLink, LocalizableStrings.AppFullName);
DocumentedCommand command = new(CommandName, DocsLink, LocalizableStrings.AppFullName);

command.Aliases.Add(CommandAlias);

command.Arguments.Add(SlnArgument);
command.Subcommands.Add(SlnAddParser.GetCommand());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ remove Remove a package or reference from a .NET project.
restore Restore dependencies specified in a .NET project.
run Build and run a .NET project output.
sdk Manage .NET SDK installation.
sln Modify Visual Studio solution files.
solution Modify Visual Studio solution files.
store Store the specified assemblies in the runtime package store.
test Run unit tests using the test runner specified in a .NET project.
tool Install or manage tools that extend the .NET experience.
Expand Down
Loading

0 comments on commit 41c6d4b

Please sign in to comment.