-
Notifications
You must be signed in to change notification settings - Fork 468
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
5 changed files
with
178 additions
and
30 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
// Copyright (c) Microsoft. All Rights Reserved. Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. | ||
|
||
using System; | ||
|
||
namespace Analyzer.Utilities.Extensions | ||
{ | ||
internal static class VersionExtension | ||
{ | ||
public static bool IsGreaterThanOrEqualTo(this Version? current, Version? compare) | ||
{ | ||
if (current == null) | ||
{ | ||
return compare == null; | ||
} | ||
|
||
if (compare == null) | ||
{ | ||
return true; | ||
} | ||
|
||
if (current.Major != compare.Major) | ||
{ | ||
return current.Major > compare.Major; | ||
} | ||
|
||
if (current.Minor != compare.Minor) | ||
{ | ||
return current.Minor > compare.Minor; | ||
} | ||
|
||
// For build or revision value of 0 equals to -1 | ||
if (current.Build != compare.Build && (current.Build > 0 || compare.Build > 0)) | ||
{ | ||
return current.Build > compare.Build; | ||
} | ||
|
||
if (current.Revision != compare.Revision && (current.Revision > 0 || compare.Revision > 0)) | ||
{ | ||
return current.Revision > compare.Revision; | ||
} | ||
|
||
return true; | ||
} | ||
} | ||
} |