Skip to content

Commit

Permalink
Merge branch 'release/9.0.2xx' into RestoreTestOutput
Browse files Browse the repository at this point in the history
  • Loading branch information
tmat authored Dec 11, 2024
2 parents b5212c7 + 449ccc0 commit 074c39b
Show file tree
Hide file tree
Showing 29 changed files with 197 additions and 121 deletions.
26 changes: 0 additions & 26 deletions src/BuiltInTools/dotnet-format/Commands/FormatCommandCommon.cs
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@ internal static class FormatCommandCommon
internal const int UnhandledExceptionExitCode = 1;
internal const int CheckFailedExitCode = 2;
internal const int UnableToLocateMSBuildExitCode = 3;
internal const int UnableToLocateDotNetCliExitCode = 4;

private static string[] VerbosityLevels => new[] { "q", "quiet", "m", "minimal", "n", "normal", "d", "detailed", "diag", "diagnostic" };
private static string[] SeverityLevels => new[] { "info", "warn", "error" };
Expand Down Expand Up @@ -102,14 +101,6 @@ internal static async Task<int> FormatAsync(FormatOptions formatOptions, ILogger
var runtimeVersion = GetRuntimeVersion();
logger.LogDebug(Resources.The_dotnet_runtime_version_is_0, runtimeVersion);

if (!TryGetDotNetCliVersion(out var dotnetVersion))
{
logger.LogError(Resources.Unable_to_locate_dotnet_CLI_Ensure_that_it_is_on_the_PATH);
return UnableToLocateDotNetCliExitCode;
}

logger.LogTrace(Resources.The_dotnet_CLI_version_is_0, dotnetVersion);

if (!TryLoadMSBuild(out var msBuildPath))
{
logger.LogError(Resources.Unable_to_locate_MSBuild_Ensure_the_NET_SDK_was_installed_with_the_official_installer);
Expand Down Expand Up @@ -354,23 +345,6 @@ private static string EnsureTrailingSlash(string path)
?.InformationalVersion;
}

internal static bool TryGetDotNetCliVersion([NotNullWhen(returnValue: true)] out string? dotnetVersion)
{
try
{
var processInfo = ProcessRunner.CreateProcess("dotnet", "--version", captureOutput: true, displayWindow: false);
var versionResult = processInfo.Result.GetAwaiter().GetResult();

dotnetVersion = versionResult.OutputLines[0].Trim();
return true;
}
catch
{
dotnetVersion = null;
return false;
}
}

internal static bool TryLoadMSBuild([NotNullWhen(returnValue: true)] out string? msBuildPath)
{
try
Expand Down
3 changes: 0 additions & 3 deletions src/BuiltInTools/dotnet-format/Resources.resx
Original file line number Diff line number Diff line change
Expand Up @@ -225,9 +225,6 @@
<data name="Standard_input_used_multiple_times" xml:space="preserve">
<value>Standard input markers ('/dev/stdin', '-') can only be used either with `--include` or `--exclude`, but not both.</value>
</data>
<data name="Unable_to_locate_dotnet_CLI_Ensure_that_it_is_on_the_PATH" xml:space="preserve">
<value>Unable to locate dotnet CLI. Ensure that it is on the PATH.</value>
</data>
<data name="The_dotnet_CLI_version_is_0" xml:space="preserve">
<value>The dotnet CLI version is '{0}'.</value>
</data>
Expand Down
5 changes: 0 additions & 5 deletions src/BuiltInTools/dotnet-format/xlf/Resources.cs.xlf

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

5 changes: 0 additions & 5 deletions src/BuiltInTools/dotnet-format/xlf/Resources.de.xlf

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

5 changes: 0 additions & 5 deletions src/BuiltInTools/dotnet-format/xlf/Resources.es.xlf

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

5 changes: 0 additions & 5 deletions src/BuiltInTools/dotnet-format/xlf/Resources.fr.xlf

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

5 changes: 0 additions & 5 deletions src/BuiltInTools/dotnet-format/xlf/Resources.it.xlf

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

5 changes: 0 additions & 5 deletions src/BuiltInTools/dotnet-format/xlf/Resources.ja.xlf

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

5 changes: 0 additions & 5 deletions src/BuiltInTools/dotnet-format/xlf/Resources.ko.xlf

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

5 changes: 0 additions & 5 deletions src/BuiltInTools/dotnet-format/xlf/Resources.pl.xlf

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

5 changes: 0 additions & 5 deletions src/BuiltInTools/dotnet-format/xlf/Resources.pt-BR.xlf

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

5 changes: 0 additions & 5 deletions src/BuiltInTools/dotnet-format/xlf/Resources.ru.xlf

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

5 changes: 0 additions & 5 deletions src/BuiltInTools/dotnet-format/xlf/Resources.tr.xlf

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

5 changes: 0 additions & 5 deletions src/BuiltInTools/dotnet-format/xlf/Resources.zh-Hans.xlf

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

5 changes: 0 additions & 5 deletions src/BuiltInTools/dotnet-format/xlf/Resources.zh-Hant.xlf

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
@@ -1,10 +1,13 @@
// Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT license.

using Microsoft.DotNet.Cli.Utils;

namespace Microsoft.DotNet.CommandFactory
{
public class CompositeCommandResolver : ICommandResolver
{
private const string CommandResolveEvent = "commandresolution/commandresolved";
private IList<ICommandResolver> _orderedCommandResolvers;

public IEnumerable<ICommandResolver> OrderedCommandResolvers
Expand Down Expand Up @@ -33,6 +36,12 @@ public CommandSpec Resolve(CommandResolverArguments commandResolverArguments)

if (commandSpec != null)
{
TelemetryEventEntry.TrackEvent(CommandResolveEvent, new Dictionary<string, string>()
{
{ "commandName", commandResolverArguments is null ? string.Empty : Sha256Hasher.HashWithNormalizedCasing(commandResolverArguments.CommandName) },
{ "commandResolver", commandResolver.GetType().ToString() }
});

return commandSpec;
}
}
Expand Down
37 changes: 37 additions & 0 deletions src/Cli/dotnet/commands/dotnet-workload/WorkloadUtilities.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
// Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT license.

using Microsoft.Deployment.DotNet.Releases;

namespace Microsoft.DotNet.Workloads.Workload
{
internal class WorkloadUtilities
{
internal static int VersionCompare(string first, string second)
{
if (first.Equals(second))
{
return 0;
}

var firstDash = first.IndexOf('-');
var secondDash = second.IndexOf('-');
firstDash = firstDash < 0 ? first.Length : firstDash;
secondDash = secondDash < 0 ? second.Length : secondDash;

var firstVersion = new Version(first.Substring(0, firstDash));
var secondVersion = new Version(second.Substring(0, secondDash));

var comparison = firstVersion.CompareTo(secondVersion);
if (comparison != 0)
{
return comparison;
}

var modifiedFirst = new ReleaseVersion(1, 1, 1, firstDash == first.Length ? null : first.Substring(firstDash));
var modifiedSecond = new ReleaseVersion(1, 1, 1, secondDash == second.Length ? null : second.Substring(secondDash));

return modifiedFirst.CompareTo(modifiedSecond);
}
}
}
Loading

0 comments on commit 074c39b

Please sign in to comment.