summaryrefslogtreecommitdiff
path: root/src/coreclr/tests/src/Loader/binding/assemblies/assemblybugs/37910/Ii.cs
blob: 65f0ea68c0fbf6e4ef75ad61da1dd3f84ec06f58 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
// Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT license.
// See the LICENSE file in the project root for more information.
using System;
using System.Reflection;
using System.Runtime.InteropServices;

public class Program
{
    [DllImport("libc", EntryPoint = "setlocale")]
    public static extern IntPtr setlocale(int category, [MarshalAs(UnmanagedType.LPStr)] string locale);

    public static int Main()
    {
        Assembly a1 = Assembly.GetExecutingAssembly();

        // In case of Turkish locale:
        // towupper 'i' -> \x0130 (instead of 'I')
        // towlower 'I' -> \x0131 (instead of 'i')
        const string TRLocale = "tr_TR.UTF-8";
        IntPtr res = setlocale(6 /*LC_ALL*/, TRLocale);
        if (TRLocale != Marshal.PtrToStringAnsi(res))
        {
            Console.WriteLine("Failed! " + TRLocale + " locale was not found in system!");
            return -1;
        }

        Assembly a2 = Assembly.Load("Ii");

        if (a1 != a2)
        {
            Console.WriteLine("Failed!");
            return -2;
        }

        Console.WriteLine("Passed!");
        return 100;
    }
}