Skip to content
Closed
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Next Next commit
Handle left Token being null in == and !=.
  • Loading branch information
andrewimcclement authored Jul 19, 2022
commit 5815738ef2156b64f1dfc8d2d0a2e76c3f3873e1
4 changes: 2 additions & 2 deletions src/System.CommandLine/Parsing/Token.cs
Original file line number Diff line number Diff line change
Expand Up @@ -66,14 +66,14 @@ internal Token(string? value, TokenType type, Symbol? symbol, int position)
/// <param name="left">The first <see cref="Token"/>.</param>
/// <param name="right">The second <see cref="Token"/>.</param>
/// <returns><see langword="true" /> if the objects are equal.</returns>
public static bool operator ==(Token left, Token right) => left.Equals(right);
public static bool operator ==(Token left, Token right) => left?.Equals(right) ?? right is null;

/// <summary>
/// Checks if two specified <see cref="Token"/> instances have different values.
/// </summary>
/// <param name="left">The first <see cref="Token"/>.</param>
/// <param name="right">The second <see cref="Token"/>.</param>
/// <returns><see langword="true" /> if the objects are not equal.</returns>
public static bool operator !=(Token left, Token right) => !left.Equals(right);
public static bool operator !=(Token left, Token right) => !(left == right);
}
}