Skip to content
This repository was archived by the owner on Jan 23, 2023. It is now read-only.

Commit cf38f28

Browse files
jkotassafern
authored andcommitted
Switch over to shared Interop.Globalization.cs on Windows (#3528)
- Match CoreCLR refactoring done for invariant culture - Use actual unsafe types in the interop signatures instead of opaque IntPtr - Use Unsafe.As to get a pointer to stack allocated structure instead of allocating GCHandles - Remove use of NativeCallable for enumeration to make the same code work on both CoreRT and CoreCLR. (I have kelp the NativeCallable annotations commented out so that we can switch back to them once C# gets the intrinsics to make it possible.) Signed-off-by: dotnet-bot <dotnet-bot@microsoft.com> Signed-off-by: dotnet-bot-corefx-mirror <dotnet-bot@microsoft.com>
1 parent 8f12234 commit cf38f28

File tree

2 files changed

+9
-9
lines changed

2 files changed

+9
-9
lines changed

src/Common/src/CoreLib/Interop/Windows/Kernel32/Interop.Globalization.cs

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -89,20 +89,20 @@ internal extern static unsafe bool IsNLSDefinedString(
8989
internal static extern bool GetUserPreferredUILanguages(uint dwFlags, out uint pulNumLanguages, char [] pwszLanguagesBuffer, ref uint pcchLanguagesBuffer);
9090

9191
[DllImport("kernel32.dll", CharSet = CharSet.Unicode)]
92-
internal static extern int GetLocaleInfoEx(string lpLocaleName, uint LCType, IntPtr lpLCData, int cchData);
92+
internal static extern int GetLocaleInfoEx(string lpLocaleName, uint LCType, void* lpLCData, int cchData);
9393

9494
[DllImport("kernel32.dll", CharSet = CharSet.Unicode)]
95-
internal extern static bool EnumSystemLocalesEx(EnumLocalesProcEx lpLocaleEnumProcEx, uint dwFlags, IntPtr lParam, IntPtr reserved);
95+
internal extern static bool EnumSystemLocalesEx(EnumLocalesProcEx lpLocaleEnumProcEx, uint dwFlags, void* lParam, IntPtr reserved);
9696

97-
internal delegate BOOL EnumLocalesProcEx(IntPtr lpLocaleString, uint dwFlags, IntPtr lParam);
97+
internal delegate BOOL EnumLocalesProcEx(char* lpLocaleString, uint dwFlags, void* lParam);
9898

9999
[DllImport("kernel32.dll", CharSet = CharSet.Unicode)]
100100
internal extern static int ResolveLocaleName(string lpNameToResolve, char* lpLocaleName, int cchLocaleName);
101101

102102
[DllImport("kernel32.dll", CharSet = CharSet.Unicode)]
103-
internal extern static bool EnumTimeFormatsEx(EnumTimeFormatsProcEx lpTimeFmtEnumProcEx, string lpLocaleName, uint dwFlags, IntPtr lParam);
103+
internal extern static bool EnumTimeFormatsEx(EnumTimeFormatsProcEx lpTimeFmtEnumProcEx, string lpLocaleName, uint dwFlags, void* lParam);
104104

105-
internal delegate BOOL EnumTimeFormatsProcEx(IntPtr lpTimeFormatString, IntPtr lParam);
105+
internal delegate BOOL EnumTimeFormatsProcEx(char* lpTimeFormatString, void* lParam);
106106

107107
[DllImport("kernel32.dll", CharSet = CharSet.Unicode)]
108108
internal extern static int GetCalendarInfoEx(string lpLocaleName, uint Calendar, IntPtr lpReserved, uint CalType, IntPtr lpCalData, int cchData, out int lpValue);
@@ -111,12 +111,12 @@ internal extern static unsafe bool IsNLSDefinedString(
111111
internal extern static int GetCalendarInfoEx(string lpLocaleName, uint Calendar, IntPtr lpReserved, uint CalType, IntPtr lpCalData, int cchData, IntPtr lpValue);
112112

113113
[DllImport("kernel32.dll", CharSet = CharSet.Unicode)]
114-
internal extern static bool EnumCalendarInfoExEx(EnumCalendarInfoProcExEx pCalInfoEnumProcExEx, string lpLocaleName, uint Calendar, string lpReserved, uint CalType, IntPtr lParam);
114+
internal extern static bool EnumCalendarInfoExEx(EnumCalendarInfoProcExEx pCalInfoEnumProcExEx, string lpLocaleName, uint Calendar, string lpReserved, uint CalType, void* lParam);
115115

116-
internal delegate BOOL EnumCalendarInfoProcExEx(IntPtr lpCalendarInfoString, uint Calendar, IntPtr lpReserved, IntPtr lParam);
116+
internal delegate BOOL EnumCalendarInfoProcExEx(char* lpCalendarInfoString, uint Calendar, IntPtr lpReserved, void* lParam);
117117

118118
[StructLayout(LayoutKind.Sequential)]
119-
internal struct NlsVersionInfoEx
119+
internal struct NlsVersionInfoEx
120120
{
121121
internal int dwNLSVersionInfoSize;
122122
internal int dwNLSVersion;

src/Common/src/CoreLib/System.Private.CoreLib.Shared.projitems

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -476,7 +476,7 @@
476476
<Compile Include="$(MSBuildThisFileDirectory)Interop\Windows\Kernel32\Interop.GetLongPathNameW.cs"/>
477477
<Compile Include="$(MSBuildThisFileDirectory)Interop\Windows\Kernel32\Interop.GetTempFileNameW.cs"/>
478478
<Compile Include="$(MSBuildThisFileDirectory)Interop\Windows\Kernel32\Interop.GetTempPathW.cs"/>
479-
<Compile Include="$(MSBuildThisFileDirectory)Interop\Windows\Kernel32\Interop.Globalization.cs"/>
479+
<Compile Include="$(MSBuildThisFileDirectory)Interop\Windows\Kernel32\Interop.Globalization.cs" Condition="'$(EnableDummyGlobalizationImplementation)' != 'true'"/>
480480
<Compile Include="$(MSBuildThisFileDirectory)Interop\Windows\Kernel32\Interop.LockFile.cs"/>
481481
<Compile Include="$(MSBuildThisFileDirectory)Interop\Windows\Kernel32\Interop.OutputDebugString.cs"/>
482482
<Compile Include="$(MSBuildThisFileDirectory)Interop\Windows\Kernel32\Interop.ReadFile_SafeHandle_IntPtr.cs"/>

0 commit comments

Comments
 (0)