Skip to content

Commit 2e96d29

Browse files
Don't show AssemblyInformationalVersion metadata in BDN BrandVersion
1 parent c27152b commit 2e96d29

File tree

2 files changed

+26
-1
lines changed

2 files changed

+26
-1
lines changed

src/BenchmarkDotNet/Properties/BenchmarkDotNetInfo.cs

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ public class BenchmarkDotNetInfo
1111
var assembly = typeof(BenchmarkDotNetInfo).GetTypeInfo().Assembly;
1212
var assemblyVersion = assembly.GetName().Version;
1313
string informationVersion = assembly.GetCustomAttribute<AssemblyInformationalVersionAttribute>().InformationalVersion ?? "";
14-
return new BenchmarkDotNetInfo(assemblyVersion, informationVersion);
14+
return new BenchmarkDotNetInfo(assemblyVersion, RemoveVersionMetadata(informationVersion));
1515
});
1616

1717
public static BenchmarkDotNetInfo Instance { get; } = LazyInstance.Value;
@@ -49,6 +49,12 @@ public BenchmarkDotNetInfo(Version assemblyVersion, string fullVersion)
4949
BrandTitle = "BenchmarkDotNet v" + BrandVersion;
5050
}
5151

52+
internal static string RemoveVersionMetadata(string version)
53+
{
54+
int index = version.IndexOf('+');
55+
return index >= 0 ? version.Substring(0, index) : version;
56+
}
57+
5258
internal const string PublicKey =
5359
"00240000048000009400000006020000002400005253413100040000010001002970bbdfca4d12" +
5460
"9fc74b4845b239973f1b183684f0d7db5e1de7e085917e3656cf94884803cb800d85d5aae5838f" +
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
using BenchmarkDotNet.Properties;
2+
using Xunit;
3+
4+
namespace BenchmarkDotNet.Tests.Properties;
5+
6+
public class BenchmarkDotNetInfoTests
7+
{
8+
[Theory]
9+
[InlineData("", "")]
10+
[InlineData("1.2.3.4", "1.2.3.4")]
11+
[InlineData("1729-foo", "1729-foo")]
12+
[InlineData("0.13.9+228a464e8be6c580ad9408e98f18813f6407fb5a", "0.13.9")]
13+
[InlineData("1-2+3", "1-2")]
14+
public void RemoveVersionMetadata(string input, string expectedOutput)
15+
{
16+
string? actualOutput = BenchmarkDotNetInfo.RemoveVersionMetadata(input);
17+
Assert.Equal(expectedOutput, actualOutput);
18+
}
19+
}

0 commit comments

Comments
 (0)