Skip to content

Commit 71b0ab9

Browse files
committed
Further minimize diffs
1 parent 60b87b1 commit 71b0ab9

File tree

1 file changed

+35
-33
lines changed

1 file changed

+35
-33
lines changed

dotnet/src/webdriver/DriverService.cs

Lines changed: 35 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -237,52 +237,54 @@ public void Start()
237237
/// <returns>A task that represents the asynchronous start operation.</returns>
238238
public async Task StartAsync()
239239
{
240-
if (this.driverServiceProcess is null)
240+
if (this.driverServiceProcess != null)
241241
{
242-
var driverServiceProcess = new Process();
242+
return;
243+
}
243244

244-
try
245-
{
246-
if (this.DriverServicePath != null)
247-
{
248-
if (this.DriverServiceExecutableName is null)
249-
{
250-
throw new InvalidOperationException("If the driver service path is specified, the driver service executable name must be as well");
251-
}
245+
var driverServiceProcess = new Process();
252246

253-
driverServiceProcess.StartInfo.FileName = Path.Combine(this.DriverServicePath, this.DriverServiceExecutableName);
254-
}
255-
else
247+
try
248+
{
249+
if (this.DriverServicePath != null)
250+
{
251+
if (this.DriverServiceExecutableName is null)
256252
{
257-
driverServiceProcess.StartInfo.FileName = new DriverFinder(this.GetDefaultDriverOptions()).GetDriverPath();
253+
throw new InvalidOperationException("If the driver service path is specified, the driver service executable name must be as well");
258254
}
259255

260-
driverServiceProcess.StartInfo.Arguments = this.CommandLineArguments;
261-
driverServiceProcess.StartInfo.UseShellExecute = false;
262-
driverServiceProcess.StartInfo.CreateNoWindow = this.HideCommandPromptWindow;
256+
driverServiceProcess.StartInfo.FileName = Path.Combine(this.DriverServicePath, this.DriverServiceExecutableName);
257+
}
258+
else
259+
{
260+
driverServiceProcess.StartInfo.FileName = new DriverFinder(this.GetDefaultDriverOptions()).GetDriverPath();
261+
}
262+
263+
driverServiceProcess.StartInfo.Arguments = this.CommandLineArguments;
264+
driverServiceProcess.StartInfo.UseShellExecute = false;
265+
driverServiceProcess.StartInfo.CreateNoWindow = this.HideCommandPromptWindow;
263266

264-
DriverProcessStartingEventArgs eventArgs = new DriverProcessStartingEventArgs(driverServiceProcess.StartInfo);
265-
this.OnDriverProcessStarting(eventArgs);
267+
DriverProcessStartingEventArgs eventArgs = new DriverProcessStartingEventArgs(driverServiceProcess.StartInfo);
268+
this.OnDriverProcessStarting(eventArgs);
266269

267-
driverServiceProcess.Start();
268-
bool serviceAvailable = await this.WaitForServiceInitializationAsync().ConfigureAwait(false);
270+
driverServiceProcess.Start();
271+
bool serviceAvailable = await this.WaitForServiceInitializationAsync().ConfigureAwait(false);
269272

270-
DriverProcessStartedEventArgs processStartedEventArgs = new DriverProcessStartedEventArgs(driverServiceProcess);
271-
this.OnDriverProcessStarted(processStartedEventArgs);
273+
DriverProcessStartedEventArgs processStartedEventArgs = new DriverProcessStartedEventArgs(driverServiceProcess);
274+
this.OnDriverProcessStarted(processStartedEventArgs);
272275

273-
if (!serviceAvailable)
274-
{
275-
throw new WebDriverException($"Cannot start the driver service on {this.ServiceUrl}");
276-
}
277-
}
278-
catch
276+
if (!serviceAvailable)
279277
{
280-
driverServiceProcess.Dispose();
281-
throw;
278+
throw new WebDriverException($"Cannot start the driver service on {this.ServiceUrl}");
282279
}
283-
284-
this.driverServiceProcess = driverServiceProcess;
285280
}
281+
catch
282+
{
283+
driverServiceProcess.Dispose();
284+
throw;
285+
}
286+
287+
this.driverServiceProcess = driverServiceProcess;
286288
}
287289

288290
/// <summary>

0 commit comments

Comments
 (0)