Skip to content

Commit 9ddc1f3

Browse files
committed
Removing Contract.Assume
1 parent b3276e6 commit 9ddc1f3

File tree

4 files changed

+3
-14
lines changed

4 files changed

+3
-14
lines changed

src/GitVersion.Core/Git/ReferenceName.cs

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
using System.Diagnostics.CodeAnalysis;
2-
using System.Diagnostics.Contracts;
32
using System.Text.RegularExpressions;
43
using GitVersion.Extensions;
54
using GitVersion.Helpers;
@@ -85,8 +84,6 @@ public bool TryGetSemanticVersion([NotNullWhen(true)] out (SemanticVersion Value
8584
{
8685
result = default;
8786

88-
Contract.Assume(versionPatternRegex.ToString().StartsWith('^'));
89-
9087
int length = 0;
9188
foreach (var branchPart in WithoutOrigin.Split(GetBranchSeparator()))
9289
{

src/GitVersion.Core/VersionCalculation/VersionCalculators/ContinuousDeliveryVersionCalculator.cs

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
using System.Diagnostics.Contracts;
21
using GitVersion.Common;
32
using GitVersion.Logging;
43

@@ -23,20 +22,17 @@ public SemanticVersion Calculate(SemanticVersion semanticVersion, ICommit? baseV
2322

2423
private SemanticVersion CalculateInternal(SemanticVersion semanticVersion, ICommit? baseVersionSource)
2524
{
26-
Contract.Assume(semanticVersion.PreReleaseTag.Number.HasValue);
27-
2825
var buildMetaData = CreateVersionBuildMetaData(baseVersionSource);
29-
Contract.Assume(buildMetaData.CommitsSinceTag.HasValue);
3026

3127
return new SemanticVersion(semanticVersion)
3228
{
3329
PreReleaseTag = new SemanticVersionPreReleaseTag(semanticVersion.PreReleaseTag)
3430
{
35-
Number = semanticVersion.PreReleaseTag.Number.Value + buildMetaData.CommitsSinceTag - 1
31+
Number = semanticVersion.PreReleaseTag.Number!.Value + buildMetaData.CommitsSinceTag - 1
3632
},
3733
BuildMetaData = new SemanticVersionBuildMetaData(buildMetaData)
3834
{
39-
CommitsSinceVersionSource = buildMetaData.CommitsSinceTag.Value,
35+
CommitsSinceVersionSource = buildMetaData.CommitsSinceTag!.Value,
4036
CommitsSinceTag = null
4137
}
4238
};

src/GitVersion.Core/VersionCalculation/VersionCalculators/ContinuousDeploymentVersionCalculator.cs

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
using System.Diagnostics.Contracts;
21
using GitVersion.Common;
32
using GitVersion.Logging;
43

@@ -18,14 +17,13 @@ public SemanticVersion Calculate(SemanticVersion semanticVersion, ICommit? baseV
1817
private SemanticVersion CalculateInternal(SemanticVersion semanticVersion, ICommit? baseVersionSource)
1918
{
2019
var buildMetaData = CreateVersionBuildMetaData(baseVersionSource);
21-
Contract.Assume(buildMetaData.CommitsSinceTag.HasValue);
2220

2321
return new SemanticVersion(semanticVersion)
2422
{
2523
PreReleaseTag = SemanticVersionPreReleaseTag.Empty,
2624
BuildMetaData = new SemanticVersionBuildMetaData(buildMetaData)
2725
{
28-
CommitsSinceVersionSource = buildMetaData.CommitsSinceTag.Value,
26+
CommitsSinceVersionSource = buildMetaData.CommitsSinceTag!.Value,
2927
CommitsSinceTag = null
3028
}
3129
};

src/GitVersion.Core/VersionCalculation/VersionCalculators/ManualDeploymentVersionCalculator.cs

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
using System.Diagnostics.Contracts;
21
using GitVersion.Common;
32
using GitVersion.Logging;
43

@@ -18,7 +17,6 @@ public SemanticVersion Calculate(SemanticVersion semanticVersion, ICommit? baseV
1817
private SemanticVersion CalculateInternal(SemanticVersion semanticVersion, ICommit? baseVersionSource)
1918
{
2019
var buildMetaData = CreateVersionBuildMetaData(baseVersionSource);
21-
Contract.Assume(buildMetaData.CommitsSinceTag.HasValue);
2220

2321
return new SemanticVersion(semanticVersion)
2422
{

0 commit comments

Comments
 (0)