Skip to content

Commit 82de1df

Browse files
authored
Display net5.0 using ToString instead of custom logic (#8291)
Address #8235 Address #8268
1 parent a93c6ba commit 82de1df

2 files changed

Lines changed: 22 additions & 0 deletions

File tree

src/NuGetGallery/ExtensionMethods.cs

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -243,6 +243,15 @@ public static string ToFriendlyName(this NuGetFramework frameworkName, bool allo
243243
throw new ArgumentNullException(nameof(frameworkName));
244244
}
245245

246+
// Defer to the NuGet client logic for displaying .NET 5 frameworks. This aligns with Visual Studio package
247+
// management UI.
248+
var isNet5Era = frameworkName.Version.Major >= 5
249+
&& StringComparer.OrdinalIgnoreCase.Equals(FrameworkConstants.FrameworkIdentifiers.NetCoreApp, frameworkName.Framework);
250+
if (isNet5Era)
251+
{
252+
return frameworkName.ToString();
253+
}
254+
246255
var sb = new StringBuilder();
247256
if (String.Equals(frameworkName.Framework, ".NETPortable", StringComparison.OrdinalIgnoreCase))
248257
{

tests/NuGetGallery.Facts/ExtensionMethodsFacts.cs

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,19 @@ public class ExtensionMethodsFacts
1414
public class TheToFriendlyNameMethod
1515
{
1616
[Theory]
17+
[InlineData("net5.0", "net5.0")]
18+
[InlineData("net5.0", "NET5.0")]
19+
[InlineData("net5.0", "net5")]
20+
[InlineData("net5.0", "net50")]
21+
[InlineData("net5.0", "netcoreapp5.0")]
22+
[InlineData("net5.0", "netcoreapp50")]
23+
[InlineData("net5.0-windows", "net5.0-windows")]
24+
[InlineData("net5.0-windows9.0", "net5.0-windows9")]
25+
[InlineData("net5.0-ios14.0", "net5.0-ios14.0")]
26+
[InlineData("net5.0", "netcoreapp5.0-windows")] // See: https://github.com/NuGet/Home/issues/10177
27+
[InlineData("net5.0", "netcoreapp5.0-windows9")] // See: https://github.com/NuGet/Home/issues/10177
28+
[InlineData("net6.0", "net6.0")]
29+
[InlineData("net10.0", "net10.0")]
1730
[InlineData(".NETFramework 4.0", "net40")]
1831
[InlineData("Silverlight 4.0", "sl40")]
1932
[InlineData("WindowsPhone 8.0", "wp8")]

0 commit comments

Comments
 (0)