From 5d420c416ea52d7e3fcc15f167b04480b367391a Mon Sep 17 00:00:00 2001 From: Stephen Toub Date: Thu, 11 Apr 2019 22:22:30 -0400 Subject: [PATCH] Update Version annotations to match changes in master (#23917) --- .../shared/System/Version.cs | 26 ++++++++++++---------- 1 file changed, 14 insertions(+), 12 deletions(-) diff --git a/src/System.Private.CoreLib/shared/System/Version.cs b/src/System.Private.CoreLib/shared/System/Version.cs index c6399ba..67ddf85 100644 --- a/src/System.Private.CoreLib/shared/System/Version.cs +++ b/src/System.Private.CoreLib/shared/System/Version.cs @@ -427,32 +427,34 @@ namespace System return !(v1 == v2); } - public static bool operator <(Version v1, Version? v2) + public static bool operator <(Version? v1, Version? v2) { if (v1 is null) - throw new ArgumentNullException(nameof(v1)); + { + return !(v2 is null); + } + return (v1.CompareTo(v2) < 0); } - public static bool operator <=(Version v1, Version? v2) + public static bool operator <=(Version? v1, Version? v2) { if (v1 is null) - throw new ArgumentNullException(nameof(v1)); + { + return true; + } + return (v1.CompareTo(v2) <= 0); } - public static bool operator >(Version v1, Version? v2) + public static bool operator >(Version? v1, Version? v2) { - if (v1 is null) - throw new ArgumentNullException(nameof(v1)); - return (v1.CompareTo(v2) > 0); + return (v2 < v1); } - public static bool operator >=(Version v1, Version? v2) + public static bool operator >=(Version? v1, Version? v2) { - if (v1 is null) - throw new ArgumentNullException(nameof(v1)); - return (v1.CompareTo(v2) >= 0); + return (v2 <= v1); } } } -- 2.7.4