1
- using System . ComponentModel ;
1
+ #nullable enable
2
2
using System . Diagnostics . CodeAnalysis ;
3
3
using System . Globalization ;
4
4
@@ -70,7 +70,6 @@ namespace Terminal.Gui;
70
70
/// </list>
71
71
/// </para>
72
72
/// </remarks>
73
- [ DefaultValue ( KeyCode . Null ) ]
74
73
public class Key : EventArgs , IEquatable < Key >
75
74
{
76
75
/// <summary>Constructs a new <see cref="Key"/></summary>
@@ -213,7 +212,7 @@ public KeyCode KeyCode
213
212
#if DEBUG
214
213
if ( GetIsKeyCodeAtoZ ( value ) && ( value & KeyCode . Space ) != 0 )
215
214
{
216
- throw new ArgumentException ( $ "Invalid KeyCode: { value } is invalid.", nameof ( value ) ) ;
215
+ throw new ArgumentException ( @ $ "Invalid KeyCode: { value } is invalid.", nameof ( value ) ) ;
217
216
}
218
217
219
218
#endif
@@ -395,7 +394,7 @@ public static Rune ToRune (KeyCode key)
395
394
public static implicit operator string ( Key key ) { return key . ToString ( ) ; }
396
395
397
396
/// <inheritdoc/>
398
- public override bool Equals ( object obj )
397
+ public override bool Equals ( object ? obj )
399
398
{
400
399
if ( obj is Key other )
401
400
{
@@ -404,7 +403,7 @@ public override bool Equals (object obj)
404
403
return false ;
405
404
}
406
405
407
- bool IEquatable < Key > . Equals ( Key other ) { return Equals ( other ) ; }
406
+ bool IEquatable < Key > . Equals ( Key ? other ) { return Equals ( other ) ; }
408
407
409
408
/// <inheritdoc/>
410
409
public override int GetHashCode ( ) { return _keyCode . GetHashCode ( ) ; }
@@ -473,7 +472,7 @@ private static string GetKeyString (KeyCode key)
473
472
return ( ( Rune ) ( uint ) key ) . ToString ( ) ;
474
473
}
475
474
476
- string keyName = Enum . GetName ( typeof ( KeyCode ) , key ) ;
475
+ string ? keyName = Enum . GetName ( typeof ( KeyCode ) , key ) ;
477
476
478
477
return ! string . IsNullOrEmpty ( keyName ) ? keyName : ( ( Rune ) ( uint ) key ) . ToString ( ) ;
479
478
}
@@ -576,7 +575,7 @@ private static string TrimEndSeparator (string input, Rune separator)
576
575
/// <param name="key">The parsed value.</param>
577
576
/// <returns>A boolean value indicating whether parsing was successful.</returns>
578
577
/// <remarks></remarks>
579
- public static bool TryParse ( string text , [ NotNullWhen ( true ) ] out Key key )
578
+ public static bool TryParse ( string text , out Key key )
580
579
{
581
580
if ( string . IsNullOrEmpty ( text ) )
582
581
{
@@ -601,7 +600,7 @@ public static bool TryParse (string text, [NotNullWhen (true)] out Key key)
601
600
return true ;
602
601
}
603
602
604
- key = null ;
603
+ key = null ! ;
605
604
606
605
Rune separator = Separator ;
607
606
0 commit comments