Skip to content

Commit bbf234d

Browse files
committed
Enable NRT for SeleniumManager
1 parent f056d15 commit bbf234d

File tree

1 file changed

+13
-11
lines changed

1 file changed

+13
-11
lines changed

dotnet/src/webdriver/SeleniumManager.cs

Lines changed: 13 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,8 @@
2626
using System.Text.Json;
2727
using System.Text.Json.Serialization;
2828

29+
#nullable enable
30+
2931
namespace OpenQA.Selenium
3032
{
3133
/// <summary>
@@ -77,7 +79,7 @@ public static class SeleniumManager
7779
/// <returns>
7880
/// An array with two entries, one for the driver path, and another one for the browser path.
7981
/// </returns>
80-
public static Dictionary<string, string> BinaryPaths(string arguments)
82+
public static Dictionary<string, string?> BinaryPaths(string arguments)
8183
{
8284
StringBuilder argsBuilder = new StringBuilder(arguments);
8385
argsBuilder.Append(" --language-binding csharp");
@@ -88,7 +90,7 @@ public static Dictionary<string, string> BinaryPaths(string arguments)
8890
}
8991

9092
var smCommandResult = RunCommand(_lazyBinaryFullPath.Value, argsBuilder.ToString());
91-
Dictionary<string, string> binaryPaths = new()
93+
Dictionary<string, string?> binaryPaths = new()
9294
{
9395
{ "browser_path", smCommandResult.BrowserPath },
9496
{ "driver_path", smCommandResult.DriverPath }
@@ -182,7 +184,8 @@ private static SeleniumManagerResponse.ResultResponse RunCommand(string fileName
182184

183185
try
184186
{
185-
jsonResponse = JsonSerializer.Deserialize<SeleniumManagerResponse>(output, _serializerOptions);
187+
jsonResponse = JsonSerializer.Deserialize<SeleniumManagerResponse>(output, _serializerOptions)
188+
?? throw new WebDriverException("SeleniumManagerResponse was null");
186189
}
187190
catch (Exception ex)
188191
{
@@ -217,36 +220,35 @@ private static SeleniumManagerResponse.ResultResponse RunCommand(string fileName
217220
}
218221
}
219222

220-
return jsonResponse.Result;
223+
return jsonResponse.Result ?? throw new WebDriverException("Selenium manager response's Result was null");
221224
}
222225
}
223226

224227
internal class SeleniumManagerResponse
225228
{
226-
public IReadOnlyList<LogEntryResponse> Logs { get; set; }
229+
public IReadOnlyList<LogEntryResponse>? Logs { get; set; }
227230

228-
public ResultResponse Result { get; set; }
231+
public ResultResponse? Result { get; set; }
229232

230233
public class LogEntryResponse
231234
{
232-
public string Level { get; set; }
235+
public string? Level { get; set; }
233236

234-
public string Message { get; set; }
237+
public string? Message { get; set; }
235238
}
236239

237240
public class ResultResponse
238241
{
239242
[JsonPropertyName("driver_path")]
240-
public string DriverPath { get; set; }
243+
public string? DriverPath { get; set; }
241244

242245
[JsonPropertyName("browser_path")]
243-
public string BrowserPath { get; set; }
246+
public string? BrowserPath { get; set; }
244247
}
245248
}
246249

247250
[JsonSerializable(typeof(SeleniumManagerResponse))]
248251
internal partial class SeleniumManagerSerializerContext : JsonSerializerContext
249252
{
250-
251253
}
252254
}

0 commit comments

Comments
 (0)