Skip to content

[Libraries][Android] Turkish Culture edge case System.Collections.NonGeneric.Tests fail on Android #37069

Closed

Description

@mdh1418

Several tests from System.Collections fail on Android

System.Collections.NonGeneric.Tests:

  • System.Collections.Tests.CaseInsensitiveHashCodeProviderTests.Ctor_CultureInfo_GetHashCodeCompare_TurkishI
  • System.Collections.Tests.CaseInsensitiveHashCodeProviderTests.Default_Compare_TurkishI
  • System.Collections.Tests.CaseInsensitiveComparerTests.Ctor_CultureInfo_Compare_TurkishI
<test name="System.Collections.Tests.CaseInsensitiveHashCodeProviderTests.Ctor_CultureInfo_GetHashCodeCompare_TurkishI" type="System.Collections.Tests.CaseInsensitiveHashCodeProviderTests" method="Ctor_CultureInfo_GetHashCodeCompare_TurkishI" time="0.032986" result="Fail">
  <failure exception-type="Xunit.Sdk.EqualException">
    <message><![CDATA[Assert.Equal() Failure\nExpected: False\nActual:   True]]></message>
    <stack-trace><![CDATA[   at System.Collections.Tests.CaseInsensitiveHashCodeProviderTests.Ctor_CultureInfo_GetHashCodeCompare_TurkishI() in /Users/mdhwang/runtime/src/libraries/System.Collections.NonGeneric/tests/CaseInsensitiveHashCodeProviderTests.cs:line 140
		at System.Reflection.RuntimeMethodInfo.Invoke(Object obj, BindingFlags invokeAttr, Binder binder, Object[] parameters, CultureInfo culture) in /Users/mdhwang/runtime/src/mono/netcore/System.Private.CoreLib/src/System/Reflection/RuntimeMethodInfo.cs:line 359]]></stack-trace>
  </failure>
</test>
<test name="System.Collections.Tests.CaseInsensitiveHashCodeProviderTests.Default_Compare_TurkishI" type="System.Collections.Tests.CaseInsensitiveHashCodeProviderTests" method="Default_Compare_TurkishI" time="0.002206" result="Fail">
  <failure exception-type="Xunit.Sdk.FalseException">
    <message><![CDATA[Assert.False() Failure\nExpected: False\nActual:   True]]></message>
    <stack-trace><![CDATA[   at System.Collections.Tests.CaseInsensitiveHashCodeProviderTests.Default_Compare_TurkishI() in /Users/mdhwang/runtime/src/libraries/System.Collections.NonGeneric/tests/CaseInsensitiveHashCodeProviderTests.cs:line 181
		at System.Reflection.RuntimeMethodInfo.Invoke(Object obj, BindingFlags invokeAttr, Binder binder, Object[] parameters, CultureInfo culture) in /Users/mdhwang/runtime/src/mono/netcore/System.Private.CoreLib/src/System/Reflection/RuntimeMethodInfo.cs:line 359]]></stack-trace>
  </failure>
</test>
<test name="System.Collections.Tests.CaseInsensitiveComparerTests.Ctor_CultureInfo_Compare_TurkishI" type="System.Collections.Tests.CaseInsensitiveComparerTests" method="Ctor_CultureInfo_Compare_TurkishI" time="0.001527" result="Fail">
  <failure exception-type="Xunit.Sdk.EqualException">
    <message><![CDATA[Assert.Equal() Failure\nExpected: 1\nActual:   0]]></message>
    <stack-trace><![CDATA[   at System.Collections.Tests.CaseInsensitiveComparerTests.Ctor_CultureInfo_Compare_TurkishI() in /Users/mdhwang/runtime/src/libraries/System.Collections.NonGeneric/tests/CaseInsensitiveComparerTests.cs:line 105
		at System.Reflection.RuntimeMethodInfo.Invoke(Object obj, BindingFlags invokeAttr, Binder binder, Object[] parameters, CultureInfo culture) in /Users/mdhwang/runtime/src/mono/netcore/System.Private.CoreLib/src/System/Reflection/RuntimeMethodInfo.cs:line 359]]></stack-trace>
  </failure>
</test>

Activity

  1. added
    untriaged
    on May 27, 2020
  2. added this to the 6.0.0 milestone on Jun 24, 2020
  3. removed
    untriaged
    on Jun 24, 2020
  4. changed the title [-]System.Collections tests fail on Android[/-] [+]System.Collections.NonGeneric.Tests tests fail on Android[/+] on Mar 31, 2021
  5. changed the title [-]System.Collections.NonGeneric.Tests tests fail on Android[/-] [+]System.Collections.NonGeneric.Tests and System.Collections.Specialized.Tests tests fail on Android[/+] on Apr 7, 2021
  6. changed the title [-]System.Collections.NonGeneric.Tests and System.Collections.Specialized.Tests tests fail on Android[/-] [+][Libraries][Android] Turkish Culture edge cade System.Collections.NonGeneric.Tests fail on Android[/+] on Aug 6, 2021
  7. mdh1418 commented on Aug 6, 2021

    @mdh1418
    MemberAuthor

    #56407 may be related with respect to Turkish culture failing.

  8. modified the milestones: 6.0.0, 7.0.0 on Aug 6, 2021
  9. danmoseley commented on Aug 6, 2021

    @danmoseley
    Contributor

    It's the same issue. The special casing behavior of Turkish I. This isn't new so even if these devices have old ICU it ought to work. @tarekgh have you seen this fail?

  10. tarekgh commented on Aug 6, 2021

    @tarekgh
    Member

    It looks to me on Android there is one of the following cultures have Turkish I behavior.

        "cs-CZ","da-DK","de-DE","el-GR","en-US",
        "es-ES","fi-FI","fr-FR","hu-HU","it-IT",
        "ja-JP","ko-KR","nb-NO","nl-NL","pl-PL",
        "pt-BR","pt-PT","ru-RU","sv-SE",
        "zh-CN","zh-HK","zh-TW"
    

    I suggested if we can manually check that on the failed device or at least update the test to print the culture name that is failed.

  11. mdh1418 commented on Aug 6, 2021

    @mdh1418
    MemberAuthor

    @danmoseley @tarekgh

    public void Ctor_CultureInfo_GetHashCodeCompare_TurkishI()
    {
        var cultureNames = Helpers.TestCultureNames;
    
        foreach (string cultureName in cultureNames)
        {
            CultureInfo culture;
            try
            {
                culture = new CultureInfo(cultureName);
            }
            catch (CultureNotFoundException)
            {
                continue;
            }
    
            var provider = new CaseInsensitiveHashCodeProvider(culture);
    
            // Turkish has lower-case and upper-case version of the dotted "i", so the upper case of "i" (U+0069) isn't "I" (U+0049)
            // but rather U+0130.
            Console.WriteLine($"MitchellHwang: {cultureName}");
            Console.WriteLine($"{provider.GetHashCode("file")} == {provider.GetHashCode("FILE")}");
            Assert.Equal(
                culture.Name != "tr-TR",
                provider.GetHashCode("file") == provider.GetHashCode("FILE"));
        }
    }
    
    Test collection for System.Collections.Tests.CaseInsensitiveHashCodeProviderTests
    08-06 13:30:04.389  8740  8766 D DOTNET  : assembly_preload_hook: xunit.assert  /data/user/0/net.dot.System.Collections.NonGeneric.Tests/files
    MitchellHwang: cs-CZ
    2113348816 == 2113348816
    MitchellHwang: da-DK
    2113348816 == 2113348816
    MitchellHwang: de-DE
    2113348816 == 2113348816
    MitchellHwang: el-GR
    2113348816 == 2113348816
    MitchellHwang: en-US
    2113348816 == 2113348816
    MitchellHwang: es-ES
    2113348816 == 2113348816
    MitchellHwang: fi-FI
    2113348816 == 2113348816
    MitchellHwang: fr-FR
    2113348816 == 2113348816
    MitchellHwang: hu-HU
    2113348816 == 2113348816
    MitchellHwang: it-IT
    2113348816 == 2113348816
    MitchellHwang: ja-JP
    2113348816 == 2113348816
    MitchellHwang: ko-KR
    2113348816 == 2113348816
    MitchellHwang: nb-NO
    2113348816 == 2113348816
    MitchellHwang: nl-NL
    2113348816 == 2113348816
    MitchellHwang: pl-PL
    2113348816 == 2113348816
    MitchellHwang: pt-BR
    2113348816 == 2113348816
    MitchellHwang: pt-PT
    2113348816 == 2113348816
    MitchellHwang: ru-RU
    2113348816 == 2113348816
    MitchellHwang: sv-SE
    2113348816 == 2113348816
    MitchellHwang: tr-TR
    2113348816 == 2113348816
       Test name: System.Collections.Tests.CaseInsensitiveHashCodeProviderTests.Ctor_CultureInfo_GetHashCodeCompare_TurkishI
       Exception messages: Assert.Equal() Failure
    Expected: False
    Actual:   True
    

    So it looks like provider.GetHashCode("file") and provider.GetHashCode("FILE") are incorrectly the same for tr-TR.

  12. tarekgh commented on Aug 6, 2021

    @tarekgh
    Member

    In this case the issue would be related to the ICU used in Android or Mono could be doing something different than coreclr.

    https://source.dot.net/#System.Private.CoreLib/CompareInfo.Icu.cs,739

  13. danmoseley commented on Aug 6, 2021

    @danmoseley
    Contributor

    @mdh1418 what version of libicu is on this device?

    I'm not sure where it is or the file name, but eg on Ubuntu I have

    dan@LAPTOP-P6UJDVTA:/lib$ find . -name "libicudata.so" | ldd --version
    ldd (Ubuntu GLIBC 2.31-0ubuntu9.3) 2.31
    

    I wonder whether it's particular to this Android version/distribution that it hasn't come up before. Windows has had this behavior for nearly 20 years so I would be surprised if it was only recently fixed in ICU/CLDR.

  14. danmoseley commented on Aug 6, 2021

    @danmoseley
    Contributor

    Either way, it's very unlikely that we can do anything about it. The only question in my mind is whether this is true for all Android flavors, and whether we're testing on one that should be updated.

  15. tarekgh commented on Aug 6, 2021

    @tarekgh
    Member

    I believe Android has customized version of ICU, so the version wouldn't help much here. We need to confirm if this is issue with the ICU version installed on Android or there is something different between Mono and coreclr in such code path.

    @danmoseley just FYI, on Ubuntu, you can get the ICU version by running the command uconv -V

  16. steveisok commented on Aug 6, 2021

    @steveisok
    Member

    The ICU version is set to the API level. This table shows the breakdown. It's unknown how much they customize, but there clearly are subtle differences between desktop, Android, and what we provide in iOS. Also, there theoretically could be differences between devices / carriers as I believe they have full control over what Android they ship.

  17. danmoseley commented on Aug 6, 2021

    @danmoseley
    Contributor

    This appears to suggest that the behavior was supported starting in v28, but your table shows that as the lowest version.
    https://www.unicode.org/cldr/cldr-aux/charts/28/delta/transform-tr-Lower.html

  18. changed the title [-][Libraries][Android] Turkish Culture edge cade System.Collections.NonGeneric.Tests fail on Android[/-] [+][Libraries][Android] Turkish Culture edge case System.Collections.NonGeneric.Tests fail on Android[/+] on Mar 4, 2022
  19. steveisok commented on Jul 7, 2022

    @steveisok
    Member

    I believe there's nothing we can really do about this since Android controls what ICU they ship. I'm going to close this issue, but anyone feels otherwise, please reopen.

  20. ghost locked as resolved and limited conversation to collaborators on Aug 6, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

      Milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions