diff --git a/CSharp.Nixill/src/Objects/SemVer.cs b/CSharp.Nixill/src/Objects/SemVer.cs index c196fd8..6447a1e 100644 --- a/CSharp.Nixill/src/Objects/SemVer.cs +++ b/CSharp.Nixill/src/Objects/SemVer.cs @@ -22,7 +22,7 @@ public class SemVer : IComparable private static readonly Regex PreReleaseRegex = new Regex("^(?:0|[1-9]\\d*|\\d*[a-zA-Z-][0-9a-zA-Z-]*)(?:\\.(?:0|[1-9]\\d*|\\d*[a-zA-Z-][0-9a-zA-Z-]*))*$"); private static readonly Regex BuildMetadataRegex = new Regex("^[0-9a-zA-Z-]+(?:\\.[0-9a-zA-Z-]+)*$"); - private static readonly Regex FullRegex = new Regex("^(?P0|[1-9]\\d*)\\.(?P0|[1-9]\\d*)\\.(?P0|[1-9]\\d*)(?:-(?P(?:0|[1-9]\\d*|\\d*[a-zA-Z-][0-9a-zA-Z-]*)(?:\\.(?:0|[1-9]\\d*|\\d*[a-zA-Z-][0-9a-zA-Z-]*))*))?(?:\\+(?P[0-9a-zA-Z-]+(?:\\.[0-9a-zA-Z-]+)*))?$"); + private static readonly Regex FullRegex = new Regex("^(?0|[1-9]\\d*)\\.(?0|[1-9]\\d*)\\.(?0|[1-9]\\d*)(?:-(?(?:0|[1-9]\\d*|\\d*[a-zA-Z-][0-9a-zA-Z-]*)(?:\\.(?:0|[1-9]\\d*|\\d*[a-zA-Z-][0-9a-zA-Z-]*))*))?(?:\\+(?[0-9a-zA-Z-]+(?:\\.[0-9a-zA-Z-]+)*))?$"); /// Constructs a SemVer consisting only of the main numbers. public SemVer(int major, int minor, int patch) : this(major, minor, patch, null, null) { } @@ -105,7 +105,7 @@ public int CompareTo(SemVer target) // separated identifier from left to right until a difference is // found as follows:" string[] leftPR = PreRelease.Split('.'); - string[] rightPR = PreRelease.Split('.'); + string[] rightPR = target.PreRelease.Split('.'); int length = Math.Min(leftPR.Length, rightPR.Length); for (int i = 0; i < length; i++) @@ -113,9 +113,8 @@ public int CompareTo(SemVer target) string leftPRE = leftPR[i]; string rightPRE = rightPR[i]; - int leftPRN, rightPRN; - bool leftIsNum = int.TryParse(leftPRE, out leftPRN); - bool rightIsNum = int.TryParse(rightPRE, out rightPRN); + bool leftIsNum = int.TryParse(leftPRE, out int leftPRN); + bool rightIsNum = int.TryParse(rightPRE, out int rightPRN); // "identifiers consisting of only digits are compared numerically" if (leftIsNum && rightIsNum) { @@ -149,11 +148,11 @@ public int CompareTo(SemVer target) /// This check follows rule 11. Notably, this means that build /// metadata is ignored for the purposes of the check. Use /// EqualsStrict to check with metadata. + /// /// /// /// If obj is not a SemVer. /// - /// public override bool Equals(object obj) { SemVer target = (SemVer)obj;