示例#1
0
 /*********
 ** Private methods
 *********/
 /// <summary>Assert that the version matches the expected parts.</summary>
 /// <param name="version">The version number.</param>
 /// <param name="major">The major number.</param>
 /// <param name="minor">The minor number.</param>
 /// <param name="patch">The patch number.</param>
 /// <param name="prerelease">The prerelease tag.</param>
 /// <param name="build">The build metadata.</param>
 /// <param name="nonStandard">Whether the version should be marked as non-standard.</param>
 private void AssertParts(ISemanticVersion version, int major, int minor, int patch, string prerelease, string build, bool nonStandard)
 {
     Assert.AreEqual(major, version.MajorVersion, "The major version doesn't match.");
     Assert.AreEqual(minor, version.MinorVersion, "The minor version doesn't match.");
     Assert.AreEqual(patch, version.PatchVersion, "The patch version doesn't match.");
     Assert.AreEqual(string.IsNullOrWhiteSpace(prerelease) ? null : prerelease.Trim(), version.PrereleaseTag, "The prerelease tag doesn't match.");
     Assert.AreEqual(string.IsNullOrWhiteSpace(build) ? null : build.Trim(), version.BuildMetadata, "The build metadata doesn't match.");
     Assert.AreEqual(nonStandard, version.IsNonStandard(), $"The version is incorrectly marked {(nonStandard ? "standard" : "non-standard")}.");
 }
示例#2
0
 /// <summary>Parse a version string without throwing an exception if it fails.</summary>
 /// <param name="version">The version string.</param>
 /// <param name="parsed">The parsed representation.</param>
 /// <returns>Returns whether parsing the version succeeded.</returns>
 public static bool TryParse(string version, out ISemanticVersion parsed)
 {
     return(SemanticVersion.TryParseNonStandard(version, out parsed) && !parsed.IsNonStandard());
 }