diff --git a/src/libraries/Fuzzing/DotnetFuzzing/Fuzzers/AssemblyNameInfoFuzzer.cs b/src/libraries/Fuzzing/DotnetFuzzing/Fuzzers/AssemblyNameInfoFuzzer.cs index 32b7e8a2ff1b19..0fbc20941513e4 100644 --- a/src/libraries/Fuzzing/DotnetFuzzing/Fuzzers/AssemblyNameInfoFuzzer.cs +++ b/src/libraries/Fuzzing/DotnetFuzzing/Fuzzers/AssemblyNameInfoFuzzer.cs @@ -68,11 +68,13 @@ private static void Test(Span 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 { diff --git a/src/libraries/System.Reflection.Metadata/tests/Metadata/AssemblyNameInfoTests.cs b/src/libraries/System.Reflection.Metadata/tests/Metadata/AssemblyNameInfoTests.cs index d399f5582390cf..05db85d2f1d14c 100644 --- a/src/libraries/System.Reflection.Metadata/tests/Metadata/AssemblyNameInfoTests.cs +++ b/src/libraries/System.Reflection.Metadata/tests/Metadata/AssemblyNameInfoTests.cs @@ -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; @@ -106,15 +107,24 @@ public void EmptyInputIsInvalid() Assert.Throws(() => AssemblyNameInfo.Parse("".AsSpan())); } - [Fact] - public void CultureNameGetLoweredByToAssemblyName() + + public static IEnumerable 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]