Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion PowerKit.Tests/Extensions/VersionExtensionsTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ public class VersionExtensionsTests
[Fact]
public void ToSemanticString_Test()
{
new Version(1, 2).ToSemanticString().Should().Be("1.2");
new Version(1, 2).ToSemanticString().Should().Be("1.2.0");
new Version(1, 2, 3).ToSemanticString().Should().Be("1.2.3");
new Version(1, 2, 3, 4).ToSemanticString().Should().Be("1.2.3.4");
new Version(1, 2, 3, 0).ToSemanticString().Should().Be("1.2.3");
Expand Down
3 changes: 2 additions & 1 deletion PowerKit/Extensions/VersionExtensions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,10 @@ public static class VersionExtensions
{
/// <summary>
/// Formats the version as a semantic version string, omitting the revision component if it is not set or is zero.
/// Missing build or patch components are replaced with zero to ensure at least three components are present.
/// </summary>
Comment thread
Copilot marked this conversation as resolved.
public string ToSemanticString() =>
version.Build < 0 ? version.ToString(2)
version.Build < 0 ? version.ToString(2) + ".0"
: version.Revision <= 0 ? version.ToString(3)
: version.ToString();
}
Expand Down