-
Notifications
You must be signed in to change notification settings - Fork 4.7k
/
LCIDTest.cs
62 lines (57 loc) · 2.07 KB
/
LCIDTest.cs
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
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
// Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT license.
using System;
using System.Globalization;
using System.Reflection;
using System.Runtime.InteropServices;
using System.Text;
using Xunit;
class LCIDNative
{
[DllImport(nameof(LCIDNative), CharSet = CharSet.Unicode)]
[LCIDConversion(1)]
public static extern void ReverseString(string str, out string result);
[DllImport(nameof(LCIDNative), CharSet = CharSet.Unicode)]
[LCIDConversion(0)]
public static extern bool VerifyValidLCIDPassed(int lcid);
}
public class LCIDTest
{
private static string Reverse(string s)
{
var chars = s.ToCharArray();
Array.Reverse(chars);
return new string(chars);
}
[Fact]
[PlatformSpecific(TestPlatforms.Windows)]
[SkipOnMono("PInvoke LCIDConversionAttribute not supported on Mono")]
[ActiveIssue("https://github.com/dotnet/runtimelab/issues/155", typeof(TestLibrary.Utilities), nameof(TestLibrary.Utilities.IsNativeAot))]
[ActiveIssue("https://github.com/dotnet/runtime/issues/91388", typeof(TestLibrary.PlatformDetection), nameof(TestLibrary.PlatformDetection.PlatformDoesNotSupportNativeTestAssets))]
public static int TestEntryPoint()
{
try
{
string testString = "Test string";
LCIDNative.ReverseString(testString, out string reversed);
Assert.Equal(Reverse(testString), reversed);
CultureInfo originalCulture = CultureInfo.CurrentCulture;
try
{
CultureInfo spanishCulture = new CultureInfo("es-ES", false);
CultureInfo.CurrentCulture = spanishCulture;
Assert.True(LCIDNative.VerifyValidLCIDPassed(CultureInfo.CurrentCulture.LCID));
}
finally
{
CultureInfo.CurrentCulture = originalCulture;
}
}
catch (System.Exception e)
{
Console.WriteLine(e.ToString());
return 101;
}
return 100;
}
}