本文整理汇总了C#中SemanticVersion类的典型用法代码示例。如果您正苦于以下问题:C# SemanticVersion类的具体用法?C# SemanticVersion怎么用?C# SemanticVersion使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
SemanticVersion类属于命名空间,在下文中一共展示了SemanticVersion类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C#代码示例。
示例1: PutAsync
public async Task<Hash> PutAsync(long id, SemanticVersion version, IPackage package)
{
#region Preconditions
if (package == null) throw new ArgumentNullException(nameof(package));
#endregion
var key = id.ToString() + "/" + version.ToString();
using (var ms = new MemoryStream())
{
await package.ZipToStreamAsync(ms).ConfigureAwait(false);
var hash = Hash.ComputeSHA256(ms, leaveOpen: true);
var blob = new Blob(ms) {
ContentType = "application/zip"
};
await bucket.PutAsync(key, blob).ConfigureAwait(false);
return hash;
}
}
开发者ID:carbon,项目名称:Platform,代码行数:25,代码来源:PackageStore.cs
示例2: VersionString_carried_through_even_if_invalid
public void VersionString_carried_through_even_if_invalid()
{
// Ensure the version string is available, even if the value is not a valid SemVer
SemanticVersion semVer = new SemanticVersion("1.2.3*3.2213312-invalid");
Assert.Equal("1.2.3*3.2213312-invalid", semVer.VersionString);
Assert.False(semVer.IsValid);
}
开发者ID:NetChris,项目名称:NetChris.SemVer,代码行数:7,代码来源:SemanticVersionValidationTests.cs
示例3: Matches
public static bool Matches(IVersionSpec versionSpec, SemanticVersion version)
{
if (versionSpec == null)
return true; // I CAN'T DEAL WITH THIS
bool minVersion;
if (versionSpec.MinVersion == null) {
minVersion = true; // no preconditon? LET'S DO IT
} else if (versionSpec.IsMinInclusive) {
minVersion = version >= versionSpec.MinVersion;
} else {
minVersion = version > versionSpec.MinVersion;
}
bool maxVersion;
if (versionSpec.MaxVersion == null) {
maxVersion = true; // no preconditon? LET'S DO IT
} else if (versionSpec.IsMaxInclusive) {
maxVersion = version <= versionSpec.MaxVersion;
} else {
maxVersion = version < versionSpec.MaxVersion;
}
return maxVersion && minVersion;
}
开发者ID:christianrondeau,项目名称:Squirrel.Windows.Next,代码行数:25,代码来源:ReleasePackage.cs
示例4: GetHashCode
public int GetHashCode(SemanticVersion obj)
{
var version = obj as NuGetVersion;
return String.Format(CultureInfo.InvariantCulture, "{0}.{1}.{2}-{3}GIT{4}",
version.Major, version.Minor, version.Patch, version.Release, GetCommitFromMetadata(version.Metadata)).GetHashCode();
}
开发者ID:eerhardt,项目名称:NuGet3,代码行数:7,代码来源:ExampleComparers.cs
示例5: CreatePackageReference
void CreatePackageReference (
string packageId = "Id",
bool requireReinstallation = false)
{
var version = new SemanticVersion ("1.2.3");
packageReference = new PackageReference (packageId, version, null, null, false, requireReinstallation);
}
开发者ID:powerumc,项目名称:monodevelop_korean,代码行数:7,代码来源:PackageReferenceNodeTests.cs
示例6: BumpPatchVersion
public void BumpPatchVersion()
{
var semver = new SemanticVersion(Version);
var newVer = new SemanticVersion(semver.Major, semver.Minor, semver.Patch+1,build:null, preRelease: null);
Version = FileVersion = newVer.ToString();
}
开发者ID:RejectKid,项目名称:MakeSharp,代码行数:7,代码来源:AssemblyInfo.cs
示例7: AssertVariablesAreWrittenToFile
static void AssertVariablesAreWrittenToFile(string f)
{
var writes = new List<string>();
var semanticVersion = new SemanticVersion
{
Major = 1,
Minor = 2,
Patch = 3,
PreReleaseTag = "beta1",
BuildMetaData = "5"
};
semanticVersion.BuildMetaData.CommitDate = DateTimeOffset.Parse("2014-03-06 23:59:59Z");
semanticVersion.BuildMetaData.Sha = "commitSha";
var config = new TestEffectiveConfiguration();
var variables = VariableProvider.GetVariablesFor(semanticVersion, config, false);
var j = new Jenkins(f);
j.WriteIntegration(writes.Add, variables);
writes[1].ShouldBe("1.2.3-beta.1+5");
File.Exists(f).ShouldBe(true);
var props = File.ReadAllText(f);
props.ShouldContain("GitVersion_Major=1");
props.ShouldContain("GitVersion_Minor=2");
}
开发者ID:qetza,项目名称:GitVersion,代码行数:32,代码来源:JenkinsMessageGenerationTests.cs
示例8: VerifyCreatedCode
public void VerifyCreatedCode()
{
var semanticVersion = new SemanticVersion
{
Major = 1,
Minor = 2,
Patch = 3,
PreReleaseTag = "unstable4",
BuildMetaData = new SemanticVersionBuildMetaData(5,
"feature1",
new ReleaseDate
{
OriginalCommitSha = "originalCommitSha",
OriginalDate = DateTimeOffset.Parse("2014-03-01 00:00:01Z"),
CommitSha = "commitSha",
Date = DateTimeOffset.Parse("2014-03-06 23:59:59Z")
})
};
var assemblyInfoBuilder = new AssemblyInfoBuilder
{
SemanticVersion = semanticVersion
};
var assemblyInfoText = assemblyInfoBuilder.GetAssemblyInfoText();
Approvals.Verify(assemblyInfoText);
var syntaxTree = SyntaxTree.ParseText(assemblyInfoText);
var references = new[] {new MetadataFileReference(typeof(object).Assembly.Location), };
var compilation = Compilation.Create("Greeter.dll", new CompilationOptions(OutputKind.NetModule), new[] { syntaxTree }, references);
var emitResult = compilation.Emit(new MemoryStream());
Assert.IsTrue(emitResult.Success, string.Join(Environment.NewLine, emitResult.Diagnostics.Select(x => x.Info)));
}
开发者ID:robdmoore,项目名称:GitVersion,代码行数:30,代码来源:AssemblyInfoBuilderTests.cs
示例9: remove_hook_should_be_called
protected void remove_hook_should_be_called(string expectedRepository, string expectedName, string expectedScope, SemanticVersion expectedVersion)
{
RemoveCalls.FirstOrDefault(x => x.Repository == expectedRepository &&
x.Name == expectedName &&
x.Scope == expectedScope &&
x.Version == expectedVersion).ShouldNotBeNull();
}
开发者ID:simonlaroche,项目名称:openwrap,代码行数:7,代码来源:add_wrap_with_hooks.cs
示例10: GetHashCodeNotEqualNoBuildNoPrerelease
public void GetHashCodeNotEqualNoBuildNoPrerelease()
{
SemanticVersion left = new SemanticVersion(1, 0, 0);
SemanticVersion right = new SemanticVersion(2, 0, 0);
Assert.NotEqual(left.GetHashCode(), right.GetHashCode());
}
开发者ID:Ruhrpottpatriot,项目名称:SemanticVersion,代码行数:7,代码来源:GetHashCodeTest.cs
示例11: GetHashCodeNotEqual
public void GetHashCodeNotEqual()
{
SemanticVersion left = new SemanticVersion(1, 0, 0, "foo", "bar");
SemanticVersion right = new SemanticVersion(2, 0, 0, "foo", "bar");
Assert.NotEqual(left.GetHashCode(), right.GetHashCode());
}
开发者ID:Ruhrpottpatriot,项目名称:SemanticVersion,代码行数:7,代码来源:GetHashCodeTest.cs
示例12: TryGetVersion
public static bool TryGetVersion(string directory, out SemanticVersion versionAndBranch)
{
var gitDirectory = GitDirFinder.TreeWalkForGitDir(directory);
if (string.IsNullOrEmpty(gitDirectory))
{
var message =
"No .git directory found in provided solution path. This means the assembly may not be versioned correctly. " +
"To fix this warning either clone the repository using git or remove the `GitVersionTask` nuget package. " +
"To temporarily work around this issue add a AssemblyInfo.cs with an appropriate `AssemblyVersionAttribute`. " +
"If it is detected that this build is occurring on a CI server an error may be thrown.";
Logger.WriteWarning(message);
versionAndBranch = null;
return false;
}
if (!processedDirectories.Contains(directory))
{
processedDirectories.Add(directory);
var authentication = new Authentication();
foreach (var buildServer in BuildServerList.GetApplicableBuildServers(authentication))
{
Logger.WriteInfo(string.Format("Executing PerformPreProcessingSteps for '{0}'.", buildServer.GetType().Name));
buildServer.PerformPreProcessingSteps(gitDirectory);
}
}
versionAndBranch = VersionCache.GetVersion(gitDirectory);
return true;
}
开发者ID:hbre,项目名称:GitVersion,代码行数:29,代码来源:VersionAndBranchFinder.cs
示例13: semantic_from_version
public void semantic_from_version()
{
var version = new Version("1.0.0.23");
var sem = new SemanticVersion(version);
var sem2 = new SemanticVersion("1.0.0");
Assert.Equal(sem2,sem);
}
开发者ID:geffzhang,项目名称:cavemantools,代码行数:7,代码来源:SemVersionTests.cs
示例14: TryResolvePartialName
private bool TryResolvePartialName(string name, SemanticVersion version, FrameworkName targetFramework, out string assemblyLocation)
{
foreach (var gacPath in GetGacSearchPaths(targetFramework))
{
var di = new DirectoryInfo(Path.Combine(gacPath, name));
if (!di.Exists)
{
continue;
}
foreach (var assemblyFile in di.EnumerateFiles("*.dll", SearchOption.AllDirectories))
{
if (!Path.GetFileNameWithoutExtension(assemblyFile.Name).Equals(name, StringComparison.OrdinalIgnoreCase))
{
continue;
}
SemanticVersion assemblyVersion = VersionUtility.GetAssemblyVersion(assemblyFile.FullName);
if (version == null || assemblyVersion == version)
{
assemblyLocation = assemblyFile.FullName;
return true;
}
}
}
assemblyLocation = null;
return false;
}
开发者ID:leloulight,项目名称:dnx,代码行数:30,代码来源:GacDependencyResolver.cs
示例15: WillReturnConflictIfAPackageWithTheIdAndSemanticVersionAlreadyExists
public void WillReturnConflictIfAPackageWithTheIdAndSemanticVersionAlreadyExists()
{
var version = new SemanticVersion("1.0.42");
var nuGetPackage = new Mock<IPackage>();
nuGetPackage.Setup(x => x.Id).Returns("theId");
nuGetPackage.Setup(x => x.Version).Returns(version);
var user = new User();
var packageRegistration = new PackageRegistration
{
Packages = new List<Package> { new Package { Version = version.ToString() } },
Owners = new List<User> { user }
};
var packageSvc = new Mock<IPackageService>();
packageSvc.Setup(x => x.FindPackageRegistrationById(It.IsAny<string>())).Returns(packageRegistration);
var userSvc = new Mock<IUserService>();
userSvc.Setup(x => x.FindByApiKey(It.IsAny<Guid>())).Returns(user);
var controller = CreateController(userSvc: userSvc, packageSvc: packageSvc, packageFromInputStream: nuGetPackage.Object);
// Act
var result = controller.CreatePackagePut(Guid.NewGuid().ToString());
// Assert
Assert.IsType<HttpStatusCodeWithBodyResult>(result);
var statusCodeResult = (HttpStatusCodeWithBodyResult)result;
Assert.Equal(409, statusCodeResult.StatusCode);
Assert.Equal(String.Format(Strings.PackageExistsAndCannotBeModified, "theId", "1.0.42"), statusCodeResult.StatusDescription);
}
开发者ID:Redsandro,项目名称:chocolatey.org,代码行数:30,代码来源:ApiControllerFacts.cs
示例16: NextVersion
public SemanticVersion NextVersion()
{
var versionZero = new SemanticVersion();
var lastRelease = lastTaggedReleaseFinder.GetVersion().SemVer;
var fileVersion = nextVersionTxtFileFinder.GetNextVersion();
var mergedBranchVersion = mergedBranchesWithVersionFinder.GetVersion();
var otherBranchVersion = unknownBranchFinder.FindVersion(context);
if (otherBranchVersion != null && otherBranchVersion.PreReleaseTag != null && otherBranchVersion.PreReleaseTag.Name == "release")
otherBranchVersion.PreReleaseTag.Name = "beta";
var maxCalculated = new[]{ fileVersion, otherBranchVersion, mergedBranchVersion }.Max();
if (lastRelease == versionZero && maxCalculated == versionZero)
{
return new SemanticVersion
{
Minor = 1
};
}
if (maxCalculated <= lastRelease)
{
return new SemanticVersion
{
Major = lastRelease.Major,
Minor = lastRelease.Minor,
Patch = lastRelease.Patch + 1
};
}
return maxCalculated;
}
开发者ID:potherca-contrib,项目名称:GitVersion,代码行数:32,代码来源:NextSemverCalculator.cs
示例17: ResolvePackage
private IEnumerable<ITaskItem> ResolvePackage(ITaskItem package)
{
string id = package.ItemSpec;
string version = package.GetMetadata("Version");
Log.LogMessage(MessageImportance.Normal, "Resolving Package Reference {0} {1}...", id, version);
// Initial version just searches a machine-level repository
var localFs = new PhysicalFileSystem(Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.LocalApplicationData), "NuGet", "Lib"));
var defaultResolver = new DefaultPackagePathResolver(localFs);
var machineRepo = new LocalPackageRepository(defaultResolver, localFs);
var buildRepo = new BuildPackageRepository();
var remoteRepo = new DataServicePackageRepository(new Uri("https://nuget.org/api/v2"));
var project = new BuildProjectSystem(ProjectDirectory, new FrameworkName(TargetFramework), CurrentReferences);
var manager = new PackageManager(remoteRepo, defaultResolver, localFs, machineRepo);
var projectManager = new ProjectManager(remoteRepo, defaultResolver, project, buildRepo);
// Install the package
var ver = new SemanticVersion(version);
manager.PackageInstalling += manager_PackageInstalling;
manager.InstallPackage(id, ver);
projectManager.AddPackageReference(id, ver);
return project.OutputReferences.Select(item =>
{
var name = AssemblyName.GetAssemblyName(item);
return new TaskItem(name.FullName, new Dictionary<string, string>() {
{"HintPath", item },
{"Private", "true"}
});
});
}
开发者ID:anurse,项目名称:NuGetBuild,代码行数:33,代码来源:ResolvePackageReference.cs
示例18: FindVersion
public SemanticVersion FindVersion(IRepository repository, Commit tip)
{
int major;
int minor;
int patch;
foreach (var tag in repository.TagsByDate(tip))
{
if (ShortVersionParser.TryParse(tag.Name, out major, out minor, out patch))
{
return BuildVersion(repository, tip, major, minor, patch);
}
}
var semanticVersion = new SemanticVersion();
string versionString;
if (MergeMessageParser.TryParse(tip, out versionString))
{
if (ShortVersionParser.TryParse(versionString, out major, out minor, out patch))
{
semanticVersion = BuildVersion(repository, tip, major, minor, patch);
}
}
semanticVersion.OverrideVersionManuallyIfNeeded(repository);
if (semanticVersion == null || semanticVersion.IsEmpty())
{
throw new WarningException("The head of a support branch should always be a merge commit if you follow gitflow. Please create one or work around this by tagging the commit with SemVer compatible Id.");
}
return semanticVersion;
}
开发者ID:hbre,项目名称:GitVersion,代码行数:33,代码来源:SupportVersionFinder.cs
示例19: InstallPackage
public async Task InstallPackage(string id, SemanticVersion version = null, Uri source = null, bool force = false)
{
this.StartProgressDialog("Installing", "Building chocolatey command...", id);
var arguments = new StringBuilder();
arguments.AppendFormat("install {0} -y", id);
if (version != null)
{
arguments.AppendFormat(" --version {0}", version);
}
if (source != null)
{
arguments.AppendFormat(" --source {0}", source);
}
if (force)
{
arguments.Append(" --force");
}
await ProcessEx.RunAsync(this.chocoExePath, arguments.ToString());
var newPackage =
(await this.GetInstalledPackages(true)).OrderByDescending(p => p.Version)
.FirstOrDefault(
p =>
string.Compare(p.Id, id, StringComparison.OrdinalIgnoreCase) == 0
&& (version == null || version == p.Version));
this.UpdatePackageLists(id, source, newPackage, version);
}
开发者ID:mikecole,项目名称:ChocolateyGUI,代码行数:33,代码来源:CSharpChocolateyPackageService.cs
示例20: FindVersion
public SemanticVersion FindVersion(GitVersionContext context)
{
// If current commit is tagged, don't do anything except add build metadata
if (context.IsCurrentCommitTagged)
{
// Will always be 0, don't bother with the +0 on tags
var semanticVersionBuildMetaData = metaDataCalculator.Create(context.CurrentCommit, context);
semanticVersionBuildMetaData.CommitsSinceTag = null;
var semanticVersion = new SemanticVersion(context.CurrentCommitTaggedVersion)
{
BuildMetaData = semanticVersionBuildMetaData
};
return semanticVersion;
}
var baseVersion = baseVersionFinder.GetBaseVersion(context);
var semver = baseVersion.SemanticVersion;
var increment = IncrementStrategyFinder.DetermineIncrementedField(context, baseVersion);
if (increment != null)
{
semver = semver.IncrementVersion(increment.Value);
}
else Logger.WriteInfo("Skipping version increment");
if (!semver.PreReleaseTag.HasTag() && !string.IsNullOrEmpty(context.Configuration.Tag))
{
UpdatePreReleaseTag(context, semver, baseVersion.BranchNameOverride);
}
semver.BuildMetaData = metaDataCalculator.Create(baseVersion.BaseVersionSource, context);
return semver;
}
开发者ID:nphmuller,项目名称:GitVersion,代码行数:33,代码来源:NextVersionCalculator.cs
注:本文中的SemanticVersion类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论