Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
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
Original file line number Diff line number Diff line change
Expand Up @@ -68,11 +68,13 @@ private static void Test(Span<char> span)
// When converting to AssemblyName, the culture name is lower-cased
// by the CultureInfo ctor that calls CultureData.GetCultureData
// which lowers the name for caching and normalization purposes.
// It lowers only the part before the `-` character, but we lower
// the whole string for the sake of simplicity of this test.

string lowerCase = fromTryParse.CultureName.ToLower();
if (lowerCase != "c")
{
Assert.Equal(lowerCase, fromParse.ToAssemblyName().CultureName);
Assert.Equal(lowerCase, fromParse.ToAssemblyName().CultureName!.ToLower());
}
else
{
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
// Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT license.

using System.Collections.Generic;
using System.Globalization;
using Xunit;

Expand Down Expand Up @@ -106,15 +107,24 @@ public void EmptyInputIsInvalid()
Assert.Throws<ArgumentException>(() => AssemblyNameInfo.Parse("".AsSpan()));
}

[Fact]
public void CultureNameGetLoweredByToAssemblyName()

public static IEnumerable<object[]> CultureNameGetLoweredByToAssemblyName_Arguments()
{
yield return new object[] { "aA", "aa" };
yield return new object[] { "B-BB", PlatformDetection.IsNetFramework ? "B-BB" : "b-BB" };
}

[ConditionalTheory(typeof(PlatformDetection), nameof(PlatformDetection.IsNotWindowsNanoServer))]
[MemberData(nameof(CultureNameGetLoweredByToAssemblyName_Arguments))]
public void CultureNameGetLoweredByToAssemblyName(string input, string expected)
{
AssemblyNameInfo assemblyNameInfo = AssemblyNameInfo.Parse("test,culture=aA".AsSpan());
Assert.Equal("aA", assemblyNameInfo.CultureName);
AssemblyNameInfo assemblyNameInfo = AssemblyNameInfo.Parse($"test,culture={input}".AsSpan());
Assert.Equal(input, assemblyNameInfo.CultureName);
// When converting to AssemblyName, the culture name is lower-cased
// by the CultureInfo ctor that calls CultureData.GetCultureData
// which lowers the name for caching and normalization purposes.
Assert.Equal("aa", assemblyNameInfo.ToAssemblyName().CultureName);
// It lowers only the part before the `-` character.
Assert.Equal(expected, assemblyNameInfo.ToAssemblyName().CultureName);
}

[Theory]
Expand Down
Loading