@@ -354,7 +354,7 @@ public override bool Equals(object? obj)
354354 /// <returns><c>True</c> if the current object is equal to the other parameter; otherwise, <c>false</c>.</returns>
355355 public bool Equals ( Key ? other )
356356 {
357- if ( other == null )
357+ if ( other is null )
358358 {
359359 return false ;
360360 }
@@ -431,10 +431,9 @@ public Key WithCommandKey(bool value)
431431 /// </summary>
432432 /// <param name="key">The other key to combine with.</param>
433433 /// <returns>A new key with combination of Control, Shift, Alt, and Command keys.</returns>
434- [ return : NotNullIfNotNull ( "key" ) ]
435434 public Key Combine ( Key ? key )
436435 {
437- if ( key == null )
436+ if ( key is null )
438437 {
439438 return this ;
440439 }
@@ -473,7 +472,7 @@ static bool IsSuitableForCombination(Key key)
473472 return true ;
474473 }
475474
476- return x != null && x . Equals ( y ) ;
475+ return ! ( x is null ) && x . Equals ( y ) ;
477476 }
478477
479478 /// <summary>
@@ -494,19 +493,22 @@ static bool IsSuitableForCombination(Key key)
494493 [ return : NotNullIfNotNull ( "x" ) ]
495494 [ return : NotNullIfNotNull ( "y" ) ]
496495 [ SuppressMessage ( "Usage" , "CA2225:Operator overloads have named alternates" , Justification = "Alternative method is named Combine" ) ]
497- public static Key ? operator + ( Key ? x , Key ? y )
496+ public static Key operator + ( Key x , Key ? y )
498497 {
499- if ( x != null )
498+ if ( ! ( x is null ) )
500499 {
501500 return x . Combine ( y ) ;
502501 }
503- else if ( y != null )
502+ else if ( ! ( y is null ) )
504503 {
505504 return y . Combine ( x ) ;
506505 }
507506 else
508507 {
509- return null ;
508+ // In future 'x' should be supported as nullable.
509+ // However, NotNullIfNotNull does not work correctly with operators.
510+ // Therfore workaround is to make 'x' non-nullable.
511+ return null ! ;
510512 }
511513 }
512514
@@ -526,7 +528,7 @@ static bool IsSuitableForCombination(Key key)
526528 [ SuppressMessage ( "Usage" , "CA2225:Operator overloads have named alternates" , Justification = "Key should have minimal relation to KeyboardEventArgs type" ) ]
527529 public static implicit operator KeyboardEventArgs ? ( Key ? key )
528530 {
529- if ( key == null )
531+ if ( key is null )
530532 {
531533 return null ;
532534 }
0 commit comments