Skip to content

Commit 9563ec9

Browse files
committed
Key -> nullable enable
1 parent 1180b2f commit 9563ec9

File tree

1 file changed

+7
-8
lines changed
  • Terminal.Gui/Input/Keyboard

1 file changed

+7
-8
lines changed

Terminal.Gui/Input/Keyboard/Key.cs

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
using System.ComponentModel;
1+
#nullable enable
22
using System.Diagnostics.CodeAnalysis;
33
using System.Globalization;
44

@@ -70,7 +70,6 @@ namespace Terminal.Gui;
7070
/// </list>
7171
/// </para>
7272
/// </remarks>
73-
[DefaultValue(KeyCode.Null)]
7473
public class Key : EventArgs, IEquatable<Key>
7574
{
7675
/// <summary>Constructs a new <see cref="Key"/></summary>
@@ -213,7 +212,7 @@ public KeyCode KeyCode
213212
#if DEBUG
214213
if (GetIsKeyCodeAtoZ (value) && (value & KeyCode.Space) != 0)
215214
{
216-
throw new ArgumentException ($"Invalid KeyCode: {value} is invalid.", nameof (value));
215+
throw new ArgumentException (@$"Invalid KeyCode: {value} is invalid.", nameof (value));
217216
}
218217

219218
#endif
@@ -395,7 +394,7 @@ public static Rune ToRune (KeyCode key)
395394
public static implicit operator string (Key key) { return key.ToString (); }
396395

397396
/// <inheritdoc/>
398-
public override bool Equals (object obj)
397+
public override bool Equals (object? obj)
399398
{
400399
if (obj is Key other)
401400
{
@@ -404,7 +403,7 @@ public override bool Equals (object obj)
404403
return false;
405404
}
406405

407-
bool IEquatable<Key>.Equals (Key other) { return Equals (other); }
406+
bool IEquatable<Key>.Equals (Key? other) { return Equals (other); }
408407

409408
/// <inheritdoc/>
410409
public override int GetHashCode () { return _keyCode.GetHashCode (); }
@@ -473,7 +472,7 @@ private static string GetKeyString (KeyCode key)
473472
return ((Rune)(uint)key).ToString ();
474473
}
475474

476-
string keyName = Enum.GetName (typeof (KeyCode), key);
475+
string? keyName = Enum.GetName (typeof (KeyCode), key);
477476

478477
return !string.IsNullOrEmpty (keyName) ? keyName : ((Rune)(uint)key).ToString ();
479478
}
@@ -576,7 +575,7 @@ private static string TrimEndSeparator (string input, Rune separator)
576575
/// <param name="key">The parsed value.</param>
577576
/// <returns>A boolean value indicating whether parsing was successful.</returns>
578577
/// <remarks></remarks>
579-
public static bool TryParse (string text, [NotNullWhen (true)] out Key key)
578+
public static bool TryParse (string text, out Key key)
580579
{
581580
if (string.IsNullOrEmpty (text))
582581
{
@@ -601,7 +600,7 @@ public static bool TryParse (string text, [NotNullWhen (true)] out Key key)
601600
return true;
602601
}
603602

604-
key = null;
603+
key = null!;
605604

606605
Rune separator = Separator;
607606

0 commit comments

Comments
 (0)