Skip to content

Commit a195aaa

Browse files
committed
Fix usings.
1 parent ace6b4a commit a195aaa

1 file changed

Lines changed: 26 additions & 28 deletions

File tree

src/BenchmarkDotNet/Toolchains/DotNetCli/DotNetCliCommandExecutor.cs

Lines changed: 26 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -27,8 +27,8 @@ public static class DotNetCliCommandExecutor
2727
[PublicAPI]
2828
public static async Task<DotNetCliCommandResult> ExecuteAsync(DotNetCliCommand parameters, CancellationToken cancellationToken)
2929
{
30-
var process = new Process { StartInfo = BuildStartInfo(parameters.CliPath, parameters.GenerateResult.ArtifactsPaths.BuildArtifactsDirectoryPath, parameters.Arguments, parameters.EnvironmentVariables) };
31-
var outputReader = new AsyncProcessOutputReader(process, parameters.LogOutput, parameters.Logger);
30+
using var process = new Process { StartInfo = BuildStartInfo(parameters.CliPath, parameters.GenerateResult.ArtifactsPaths.BuildArtifactsDirectoryPath, parameters.Arguments, parameters.EnvironmentVariables) };
31+
using var outputReader = new AsyncProcessOutputReader(process, parameters.LogOutput, parameters.Logger);
3232
using var _ = new ProcessCleanupHelper(process, parameters.Logger);
3333

3434
parameters.Logger.WriteLineInfo($"// start {process.StartInfo.FileName} {process.StartInfo.Arguments} in {process.StartInfo.WorkingDirectory}");
@@ -73,26 +73,25 @@ public static async Task<DotNetCliCommandResult> ExecuteAsync(DotNetCliCommand p
7373

7474
internal static string GetDotNetSdkVersion()
7575
{
76-
using (var process = new Process { StartInfo = BuildStartInfo(customDotNetCliPath: null, workingDirectory: string.Empty, arguments: "--version", redirectStandardError: false) })
77-
using (new ProcessCleanupHelper(process, NullLogger.Instance))
76+
using var process = new Process { StartInfo = BuildStartInfo(customDotNetCliPath: null, workingDirectory: string.Empty, arguments: "--version", redirectStandardError: false) };
77+
using var _ = new ProcessCleanupHelper(process, NullLogger.Instance);
78+
79+
try
7880
{
79-
try
80-
{
81-
process.Start();
82-
}
83-
catch (Win32Exception) // dotnet cli is not installed
84-
{
85-
return "";
86-
}
81+
process.Start();
82+
}
83+
catch (Win32Exception) // dotnet cli is not installed
84+
{
85+
return "";
86+
}
8787

88-
string output = process.StandardOutput.ReadToEnd();
88+
string output = process.StandardOutput.ReadToEnd();
8989

90-
process.WaitForExit();
90+
process.WaitForExit();
9191

92-
// first line contains something like ".NET Command Line Tools (1.0.0-beta-001603)"
93-
return Regex.Split(output, Environment.NewLine, RegexOptions.Compiled)
94-
.FirstOrDefault(line => line.IsNotBlank()) ?? "";
95-
}
92+
// first line contains something like ".NET Command Line Tools (1.0.0-beta-001603)"
93+
return Regex.Split(output, Environment.NewLine, RegexOptions.Compiled)
94+
.FirstOrDefault(line => line.IsNotBlank()) ?? "";
9695
}
9796

9897
internal static void LogEnvVars(DotNetCliCommand command)
@@ -157,18 +156,17 @@ private static string GetDefaultDotNetCliPath()
157156
if (!OsDetector.IsLinux())
158157
return "dotnet";
159158

160-
using (var parentProcess = Process.GetProcessById(libc.getppid()))
161-
{
162-
string parentPath = parentProcess.MainModule?.FileName ?? string.Empty;
163-
// sth like /snap/dotnet-sdk/112/dotnet and we should use the exact path instead of just "dotnet"
164-
if (parentPath.StartsWith("/snap/", StringComparison.Ordinal) &&
165-
parentPath.EndsWith("/dotnet", StringComparison.Ordinal))
166-
{
167-
return parentPath;
168-
}
159+
using var parentProcess = Process.GetProcessById(libc.getppid());
169160

170-
return "dotnet";
161+
string parentPath = parentProcess.MainModule?.FileName ?? string.Empty;
162+
// sth like /snap/dotnet-sdk/112/dotnet and we should use the exact path instead of just "dotnet"
163+
if (parentPath.StartsWith("/snap/", StringComparison.Ordinal) &&
164+
parentPath.EndsWith("/dotnet", StringComparison.Ordinal))
165+
{
166+
return parentPath;
171167
}
168+
169+
return "dotnet";
172170
}
173171

174172
internal static async Task<string> GetSdkPathAsync(string cliPath, CancellationToken cancellationToken)

0 commit comments

Comments
 (0)