Skip to content

Commit 17b8bd3

Browse files
authored
Merge branch 'trunk' into setup
2 parents 477d4ce + 4f07e4a commit 17b8bd3

29 files changed

+344
-308
lines changed

dotnet/src/webdriver/Chromium/ChromiumDriverService.cs

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -208,7 +208,7 @@ protected static string ChromiumDriverServiceFileName(string fileName = DefaultC
208208
// straightforward as you might hope.
209209
// See: http://mono.wikia.com/wiki/Detecting_the_execution_platform
210210
// and https://msdn.microsoft.com/en-us/library/3a8hyw88(v=vs.110).aspx
211-
const int PlatformMonoUnixValue = 128;
211+
const PlatformID PlatformIDMonoUnix = (PlatformID)128;
212212

213213
switch (Environment.OSVersion.Platform)
214214
{
@@ -221,17 +221,14 @@ protected static string ChromiumDriverServiceFileName(string fileName = DefaultC
221221

222222
case PlatformID.MacOSX:
223223
case PlatformID.Unix:
224+
case PlatformIDMonoUnix:
224225
break;
225226

226227
// Don't handle the Xbox case. Let default handle it.
227228
// case PlatformID.Xbox:
228229
// break;
229-
default:
230-
if ((int)Environment.OSVersion.Platform == PlatformMonoUnixValue)
231-
{
232-
break;
233-
}
234230

231+
default:
235232
throw new WebDriverException("Unsupported platform: " + Environment.OSVersion.Platform);
236233
}
237234

dotnet/src/webdriver/Firefox/FirefoxDriverService.cs

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -263,7 +263,7 @@ private static string FirefoxDriverServiceFileName()
263263
// straightforward as you might hope.
264264
// See: http://mono.wikia.com/wiki/Detecting_the_execution_platform
265265
// and https://msdn.microsoft.com/en-us/library/3a8hyw88(v=vs.110).aspx
266-
const int PlatformMonoUnixValue = 128;
266+
const PlatformID PlatformIDMonoUnix = (PlatformID)128;
267267

268268
switch (Environment.OSVersion.Platform)
269269
{
@@ -276,17 +276,13 @@ private static string FirefoxDriverServiceFileName()
276276

277277
case PlatformID.MacOSX:
278278
case PlatformID.Unix:
279+
case PlatformIDMonoUnix:
279280
break;
280281

281282
// Don't handle the Xbox case. Let default handle it.
282283
// case PlatformID.Xbox:
283284
// break;
284285
default:
285-
if ((int)Environment.OSVersion.Platform == PlatformMonoUnixValue)
286-
{
287-
break;
288-
}
289-
290286
throw new WebDriverException("Unsupported platform: " + Environment.OSVersion.Platform);
291287
}
292288

dotnet/src/webdriver/ICapabilities.cs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,8 @@
1919

2020
using System;
2121

22+
#nullable enable
23+
2224
namespace OpenQA.Selenium
2325
{
2426
/// <summary>
@@ -49,6 +51,6 @@ public interface ICapabilities
4951
/// <param name="capability">The capability to get.</param>
5052
/// <returns>An object associated with the capability, or <see langword="null"/>
5153
/// if the capability is not set on the browser.</returns>
52-
object GetCapability(string capability);
54+
object? GetCapability(string capability);
5355
}
5456
}

dotnet/src/webdriver/Internal/AndroidOptions.cs

Lines changed: 7 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -19,55 +19,43 @@
1919

2020
using System;
2121

22+
#nullable enable
23+
2224
namespace OpenQA.Selenium.Internal
2325
{
2426
/// <summary>
2527
/// Provides a base class for options for browsers to be automated on Android.
2628
/// </summary>
2729
public class AndroidOptions
2830
{
29-
private string androidPackage;
30-
private string androidDeviceSerial;
31-
private string androidActivity;
32-
3331
/// <summary>
3432
/// Initializes a new instance of the <see cref="AndroidOptions"/> class.
3533
/// </summary>
3634
/// <param name="androidPackage"></param>
35+
/// <exception cref="ArgumentException">If <paramref name="androidPackage"/> is <see langword="null"/> or <see cref="string.Empty"/>.</exception>
3736
protected AndroidOptions(string androidPackage)
3837
{
3938
if (string.IsNullOrEmpty(androidPackage))
4039
{
4140
throw new ArgumentException("The Android package cannot be null or the empty string", nameof(androidPackage));
4241
}
4342

44-
this.androidPackage = androidPackage;
43+
this.AndroidPackage = androidPackage;
4544
}
4645

4746
/// <summary>
4847
/// The package name of the application to automate.
4948
/// </summary>
50-
public string AndroidPackage
51-
{
52-
get { return this.androidPackage; }
53-
}
49+
public string AndroidPackage { get; }
5450

5551
/// <summary>
5652
/// The serial number of the device on which to launch the application.
5753
/// </summary>
58-
public string AndroidDeviceSerial
59-
{
60-
get { return this.androidDeviceSerial; }
61-
set { this.androidDeviceSerial = value; }
62-
}
54+
public string? AndroidDeviceSerial { get; set; }
6355

6456
/// <summary>
6557
/// Gets or sets the name of the Activity hosting the app.
6658
/// </summary>
67-
public string AndroidActivity
68-
{
69-
get { return this.androidActivity; }
70-
set { this.androidActivity = value; }
71-
}
59+
public string? AndroidActivity { get; set; }
7260
}
7361
}

dotnet/src/webdriver/Internal/FileUtilities.cs

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,8 @@
2323
using System.IO;
2424
using System.Reflection;
2525

26+
#nullable enable
27+
2628
namespace OpenQA.Selenium.Internal
2729
{
2830
/// <summary>
@@ -40,7 +42,7 @@ internal static class FileUtilities
4042
/// <returns><see langword="true"/> if the copy is completed; otherwise <see langword="false"/>.</returns>
4143
public static bool CopyDirectory(string sourceDirectory, string destinationDirectory)
4244
{
43-
bool copyComplete = false;
45+
bool copyComplete;
4446
DirectoryInfo sourceDirectoryInfo = new DirectoryInfo(sourceDirectory);
4547
DirectoryInfo destinationDirectoryInfo = new DirectoryInfo(destinationDirectory);
4648

@@ -132,7 +134,7 @@ public static string FindFile(string fileName)
132134

133135
// If it's not in the same directory as the executing assembly,
134136
// try looking in the system path.
135-
string systemPath = Environment.GetEnvironmentVariable("PATH");
137+
string? systemPath = Environment.GetEnvironmentVariable("PATH");
136138
if (!string.IsNullOrEmpty(systemPath))
137139
{
138140
string expandedPath = Environment.ExpandEnvironmentVariables(systemPath);
@@ -165,7 +167,7 @@ public static string FindFile(string fileName)
165167
public static string GetCurrentDirectory()
166168
{
167169
Assembly executingAssembly = typeof(FileUtilities).Assembly;
168-
string location = null;
170+
string? location = null;
169171

170172
// Make sure not to call Path.GetDirectoryName if assembly location is null or empty
171173
if (!string.IsNullOrEmpty(executingAssembly.Location))
@@ -184,13 +186,13 @@ public static string GetCurrentDirectory()
184186
location = Directory.GetCurrentDirectory();
185187
}
186188

187-
string currentDirectory = location;
189+
string currentDirectory = location!;
188190

189191
// If we're shadow copying, get the directory from the codebase instead
190192
if (AppDomain.CurrentDomain.ShadowCopyFiles)
191193
{
192194
Uri uri = new Uri(executingAssembly.CodeBase);
193-
currentDirectory = Path.GetDirectoryName(uri.LocalPath);
195+
currentDirectory = Path.GetDirectoryName(uri.LocalPath)!;
194196
}
195197

196198
return currentDirectory;

dotnet/src/webdriver/Internal/IFindsElement.cs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,8 @@
1919

2020
using System.Collections.ObjectModel;
2121

22+
#nullable enable
23+
2224
namespace OpenQA.Selenium.Internal
2325
{
2426
/// <summary>

dotnet/src/webdriver/Internal/IHasCapabilitiesDictionary.cs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,8 @@
1919

2020
using System.Collections.Generic;
2121

22+
#nullable enable
23+
2224
namespace OpenQA.Selenium.Internal
2325
{
2426
/// <summary>

dotnet/src/webdriver/Internal/Logging/ConsoleLogHandler.cs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,8 @@
1919

2020
using System;
2121

22+
#nullable enable
23+
2224
namespace OpenQA.Selenium.Internal.Logging
2325
{
2426
/// <summary>

dotnet/src/webdriver/Internal/Logging/FileLogHandler.cs

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,8 @@
2020
using System;
2121
using System.IO;
2222

23+
#nullable enable
24+
2325
namespace OpenQA.Selenium.Internal.Logging
2426
{
2527
/// <summary>
@@ -40,6 +42,7 @@ public class FileLogHandler : ILogHandler, IDisposable
4042
/// Initializes a new instance of the <see cref="FileLogHandler"/> class with the specified file path.
4143
/// </summary>
4244
/// <param name="filePath">The path of the log file.</param>
45+
/// <exception cref="ArgumentException">If <paramref name="filePath"/> is <see langword="null"/> or <see cref="string.Empty"/>.</exception>
4346
public FileLogHandler(string filePath)
4447
: this(filePath, overwrite: true)
4548
{
@@ -51,6 +54,7 @@ public FileLogHandler(string filePath)
5154
/// </summary>
5255
/// <param name="filePath">The path of the log file.</param>
5356
/// <param name="overwrite">Specifies whether the file should be overwritten if it exists on the disk.</param>
57+
/// <exception cref="ArgumentException">If <paramref name="filePath"/> is <see langword="null"/> or <see cref="string.Empty"/>.</exception>
5458
public FileLogHandler(string filePath, bool overwrite)
5559
{
5660
if (string.IsNullOrEmpty(filePath)) throw new ArgumentException("File log path cannot be null or empty.", nameof(filePath));
@@ -112,9 +116,9 @@ protected virtual void Dispose(bool disposing)
112116
if (disposing)
113117
{
114118
_streamWriter?.Dispose();
115-
_streamWriter = null;
119+
_streamWriter = null!;
116120
_fileStream?.Dispose();
117-
_fileStream = null;
121+
_fileStream = null!;
118122
}
119123

120124
_isDisposed = true;

dotnet/src/webdriver/Internal/Logging/ILogContext.cs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,8 @@
1919

2020
using System;
2121

22+
#nullable enable
23+
2224
namespace OpenQA.Selenium.Internal.Logging
2325
{
2426
/// <summary>

0 commit comments

Comments
 (0)