Skip to content

Commit eaf1224

Browse files
committed
replace Parse with TryParse
1 parent 69e2000 commit eaf1224

File tree

1 file changed

+2
-1
lines changed

1 file changed

+2
-1
lines changed

src/GitVersion.Core/VersionCalculation/SemanticVersioning/SemanticVersionPreReleaseTag.cs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -103,7 +103,8 @@ public static SemanticVersionPreReleaseTag TryParse(string preReleaseTag)
103103
}
104104

105105
var value = match.Groups["name"].Value;
106-
var number = match.Groups["number"].Success ? int.Parse(match.Groups["number"].Value) : (int?)null;
106+
var number = (match.Groups["number"].Success && int.TryParse(match.Groups["number"].Value, out int parsedNumber)) ? (int?)parsedNumber : null;
107+
107108
if (value.EndsWith("-"))
108109
return new SemanticVersionPreReleaseTag(preReleaseTag, null);
109110

0 commit comments

Comments
 (0)