Skip to content

Commit b9caf48

Browse files
committed
Add Keys nullability
1 parent 1d4a57b commit b9caf48

File tree

1 file changed

+6
-3
lines changed

1 file changed

+6
-3
lines changed

dotnet/src/webdriver/Keys.cs

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,8 @@
2121
using System.Collections.Generic;
2222
using System.Globalization;
2323

24+
#nullable enable
25+
2426
namespace OpenQA.Selenium
2527
{
2628
/// <summary>
@@ -352,13 +354,14 @@ public static class Keys
352354
/// </summary>
353355
public static readonly string ZenkakuHankaku = Convert.ToString(Convert.ToChar(0xE040, CultureInfo.InvariantCulture), CultureInfo.InvariantCulture);
354356

355-
private static Dictionary<string, string> descriptions;
357+
private static Dictionary<string, string>? descriptions;
356358

357359
/// <summary>
358360
/// Gets the description of a specific key.
359361
/// </summary>
360362
/// <param name="value">The key value for which to get the description.</param>
361363
/// <returns>The description of the key.</returns>
364+
/// <exception cref="ArgumentNullException">If <paramref name="value"/> is <see langword="null"/>.</exception>
362365
internal static object GetDescription(string value)
363366
{
364367
if (descriptions == null)
@@ -423,9 +426,9 @@ internal static object GetDescription(string value)
423426
descriptions.Add(ZenkakuHankaku, "Zenkaku Hankaku");
424427
}
425428

426-
if (descriptions.ContainsKey(value))
429+
if (descriptions.TryGetValue(value, out string? description))
427430
{
428-
return descriptions[value];
431+
return description;
429432
}
430433

431434
return value;

0 commit comments

Comments
 (0)