Skip to content

Commit 8cb701c

Browse files
Update OsBrandStringHelper
1 parent 4bd433d commit 8cb701c

File tree

2 files changed

+10
-4
lines changed

2 files changed

+10
-4
lines changed

src/BenchmarkDotNet/Environments/OsBrandStringHelper.cs

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -98,7 +98,8 @@ public class OsBrandStringHelper
9898
{ "10.0.18363", "10 19H2 [1909, November 2019 Update]" },
9999
{ "10.0.19041", "10 20H1 [2004, May 2020 Update]" },
100100
{ "10.0.19042", "10 20H2 [20H2, October 2020 Update]" },
101-
{ "10.0.19043", "10 21H1 [21H1, May 2021 Update]" }
101+
{ "10.0.19043", "10 21H1 [21H1, May 2021 Update]" },
102+
{ "10.0.19044", "10 21H2 [21H2]" }
102103
};
103104

104105
private class Windows10Version
@@ -122,13 +123,15 @@ private Windows10Version(string version, [NotNull] string codeName, [NotNull] st
122123
private string ToFullVersion([CanBeNull] int? ubr = null)
123124
=> ubr == null ? $"10.0.{BuildNumber}" : $"10.0.{BuildNumber}.{ubr}";
124125

126+
private static string Collapse(params string[] values) => string.Join("/", values.Where(v => !string.IsNullOrEmpty(v)));
127+
125128
// The line with OsBrandString is one of the longest lines in the summary.
126129
// When people past in on GitHub, it can be a reason of an ugly horizontal scrollbar.
127130
// To avoid this, we are trying to minimize this line and use the minimum possible number of characters.
128131
public string ToPrettifiedString([CanBeNull] int? ubr)
129132
=> Version == ShortifiedCodeName
130-
? $"{ToFullVersion(ubr)} ({Version}/{ShortifiedMarketingName})"
131-
: $"{ToFullVersion(ubr)} ({Version}/{ShortifiedMarketingName}/{ShortifiedCodeName})";
133+
? $"{ToFullVersion(ubr)} ({Collapse(Version, ShortifiedMarketingName)})"
134+
: $"{ToFullVersion(ubr)} ({Collapse(Version, ShortifiedMarketingName, ShortifiedCodeName)})";
132135

133136
// See https://en.wikipedia.org/wiki/Windows_10_version_history
134137
private static readonly List<Windows10Version> WellKnownVersions = new List<Windows10Version>
@@ -145,6 +148,7 @@ public string ToPrettifiedString([CanBeNull] int? ubr)
145148
new Windows10Version("2004", "20H1", "May 2020 Update", 19041),
146149
new Windows10Version("20H2", "20H2", "October 2020 Update", 19042),
147150
new Windows10Version("21H1", "21H1", "May 2021 Update", 19043),
151+
new Windows10Version("21H2", "21H2", "", 19044), // The markingName is not announced yet
148152
};
149153

150154
[CanBeNull]
@@ -209,7 +213,8 @@ private MacOSXVersion(int darwinVersion, [NotNull] string codeName)
209213
new MacOSXVersion(17, "High Sierra"),
210214
new MacOSXVersion(18, "Mojave"),
211215
new MacOSXVersion(19, "Catalina"),
212-
new MacOSXVersion(20, "Big Sur")
216+
new MacOSXVersion(20, "Big Sur"),
217+
new MacOSXVersion(21, "Monterey")
213218
};
214219

215220
[CanBeNull]

tests/BenchmarkDotNet.Tests/Environments/OsBrandStringTests.cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,7 @@ public void WindowsIsPrettified(string originalVersion, string prettifiedName)
4444
[InlineData("10.0.19041", 1, "Windows 10.0.19041.1 (2004/May2020Update/20H1)")]
4545
[InlineData("10.0.19042", 746, "Windows 10.0.19042.746 (20H2/October2020Update)")]
4646
[InlineData("10.0.19043", 964, "Windows 10.0.19043.964 (21H1/May2021Update)")]
47+
[InlineData("10.0.19044", 1147, "Windows 10.0.19044.1147 (21H2)")]
4748
public void WindowsWithUbrIsPrettified(string originalVersion, int ubr, string prettifiedName)
4849
=> Check(OsBrandStringHelper.Prettify("Windows", originalVersion, ubr), prettifiedName);
4950

0 commit comments

Comments
 (0)