Clean up Normalization code (dotnet/coreclr#9941)
authorTarek Mahmoud Sayed <tarekms@microsoft.com>
Fri, 3 Mar 2017 22:50:38 +0000 (14:50 -0800)
committerJan Kotas <jkotas@microsoft.com>
Fri, 3 Mar 2017 22:50:38 +0000 (14:50 -0800)
Commit migrated from https://github.com/dotnet/coreclr/commit/63757399c44f92ac2e89a83a70cf27c53cfa16c0

src/coreclr/src/classlibnative/inc/nlsinfo.h
src/coreclr/src/classlibnative/nls/nlsinfo.cpp
src/coreclr/src/mscorlib/PinvokeAnalyzerExceptionList.analyzerdata [new file with mode: 0644]
src/coreclr/src/mscorlib/System.Private.CoreLib.csproj
src/coreclr/src/mscorlib/shared/Interop/Windows/Interop.Errors.cs
src/coreclr/src/mscorlib/src/Interop/Windows/Normaliz/Interop.Normalization.cs [new file with mode: 0644]
src/coreclr/src/mscorlib/src/SR.cs
src/coreclr/src/mscorlib/src/System/Text/Normalization.Windows.cs
src/coreclr/src/vm/ecalllist.h

index 6c32fed..505827b 100644 (file)
@@ -39,16 +39,6 @@ struct CodePageDataItem {
     const char     * names;
 };
 
-// Normalization
-typedef BOOL (*PFN_NORMALIZATION_IS_NORMALIZED_STRING)
-    ( int NormForm, LPCWSTR lpInString, int cchInString);
-
-typedef int (*PFN_NORMALIZATION_NORMALIZE_STRING)
-    ( int NormForm, LPCWSTR lpInString, int cchInString, LPWSTR lpOutString, int cchOutString);
-
-typedef BYTE* (*PFN_NORMALIZATION_INIT_NORMALIZATION)
-    ( int NormForm, BYTE* pTableData);
-
 class COMNlsInfo
 {
 public:
@@ -73,36 +63,6 @@ public:
     static FCDECL0(EncodingDataItem *, nativeGetEncodingTableDataPointer);
     static FCDECL0(CodePageDataItem *, nativeGetCodePageTableDataPointer);
 
-    //
-    // Native helper function for methods in Normalization
-    //
-    // On Windows 7 we use the normalization data embedded inside the corelib to get better results.
-    // On Windows 8 and up we use the OS for normalization. 
-    // That is why we need to keep these fcalls and not doing it through pinvokes.
-
-    static FCDECL6(int, nativeNormalizationNormalizeString,
-        int NormForm, int& iError,
-        StringObject* inString, int inLength,
-        CHARArray* outChars, int outLength);
-    static FCDECL4(FC_BOOL_RET, nativeNormalizationIsNormalizedString,
-        int NormForm, int& iError,
-        StringObject* inString, int cwLength);
-
-    static void QCALLTYPE nativeNormalizationInitNormalization(int NormForm, BYTE* pTableData);
-
-private:
-    //
-    //  Definitions.
-    //
-
-#ifndef FEATURE_COREFX_GLOBALIZATION
-    // Normalization
-    static HMODULE m_hNormalization;
-    static PFN_NORMALIZATION_IS_NORMALIZED_STRING m_pfnNormalizationIsNormalizedStringFunc;
-    static PFN_NORMALIZATION_NORMALIZE_STRING m_pfnNormalizationNormalizeStringFunc;
-    static PFN_NORMALIZATION_INIT_NORMALIZATION m_pfnNormalizationInitNormalizationFunc;
-#endif
-
 private:
     //
     // Internal encoding data tables.
@@ -114,4 +74,4 @@ private:
     const static CodePageDataItem CodePageDataTable[];
 };
 
-#endif  // _NLSINFO_H_
+#endif  // _NLSINFO_H_
\ No newline at end of file
index b1d65e3..fa288c0 100644 (file)
 // Language ID for CHT (Hong-Kong)
 #define LANGID_ZH_HK            0x0c04
 
-#ifndef FEATURE_COREFX_GLOBALIZATION
-//
-// Normalization Implementation
-//
-#define NORMALIZATION_DLL       MAKEDLLNAME(W("normalization"))
-HMODULE COMNlsInfo::m_hNormalization = NULL;
-PFN_NORMALIZATION_IS_NORMALIZED_STRING COMNlsInfo::m_pfnNormalizationIsNormalizedStringFunc = NULL;
-PFN_NORMALIZATION_NORMALIZE_STRING COMNlsInfo::m_pfnNormalizationNormalizeStringFunc = NULL;
-PFN_NORMALIZATION_INIT_NORMALIZATION COMNlsInfo::m_pfnNormalizationInitNormalizationFunc = NULL;
-#endif // FEATURE_COREFX_GLOBALIZATION
 
 INT32 COMNlsInfo::CallGetUserDefaultUILanguage()
 {
@@ -185,146 +175,6 @@ FCIMPL0(CodePageDataItem *, COMNlsInfo::nativeGetCodePageTableDataPointer)
 }
 FCIMPLEND
 
-#ifndef FEATURE_COREFX_GLOBALIZATION
-//
-// Normalization
-//
-
-FCIMPL6(int, COMNlsInfo::nativeNormalizationNormalizeString,
-            int NormForm, int& iError,
-            StringObject* inChars, int inLength,
-            CHARArray* outChars, int outLength )
-{
-    CONTRACTL
-    {
-        FCALL_CHECK;
-        PRECONDITION(CheckPointer(inChars));
-        PRECONDITION(CheckPointer(outChars, NULL_OK));
-    } CONTRACTL_END;
-
-    // Dereference our string
-    STRINGREF inString(inChars);
-    LPWSTR inCharsBuffer = inString->GetBuffer();
-
-    CHARARRAYREF outCharArray(outChars);
-    LPWSTR outCharsBuffer = (outCharArray != NULL) ? ((LPWSTR) (outCharArray->GetDirectPointerToNonObjectElements())) : NULL;
-
-    // The OS APIs do not always set last error in success, so we have to do it explicitly
-    SetLastError(ERROR_SUCCESS);
-
-    int iResult = m_pfnNormalizationNormalizeStringFunc(
-            NormForm, inCharsBuffer, inLength, outCharsBuffer, outLength);
-
-    // Get our error if necessary
-    if (iResult <= 0)
-    {
-        // if the length is <= 0 there was an error
-        iError = GetLastError();
-
-        // Go ahead and return positive lengths/indexes so we don't get confused
-        iResult = -iResult;
-    }
-    else
-    {
-        iError = 0; // ERROR_SUCCESS
-    }
-
-    return iResult;
-}
-FCIMPLEND
-
-FCIMPL4( FC_BOOL_RET, COMNlsInfo::nativeNormalizationIsNormalizedString,
-            int NormForm, int& iError,
-            StringObject* chars, int inLength )
-{
-    CONTRACTL
-    {
-        FCALL_CHECK;
-        PRECONDITION(CheckPointer(chars));
-    } CONTRACTL_END;
-
-    STRINGREF inString(chars);
-    LPWSTR charsBuffer = inString->GetBuffer();
-
-    // The OS APIs do not always set last error in success, so we have to do it explicitly
-    SetLastError(ERROR_SUCCESS);
-
-    // Ask if its normalized
-    BOOL bResult = m_pfnNormalizationIsNormalizedStringFunc( NormForm, charsBuffer, inLength);
-
-    // May need an error
-    if (bResult == false)
-    {
-        // If its false there may have been an error
-        iError = GetLastError();
-    }
-    else
-    {
-        iError = 0; // ERROR_SUCCESS
-    }
-
-    FC_RETURN_BOOL(bResult);
-}
-FCIMPLEND
-
-void QCALLTYPE COMNlsInfo::nativeNormalizationInitNormalization(int NormForm, BYTE* pTableData)
-{
-    QCALL_CONTRACT;
-
-    BEGIN_QCALL;
-
-    if (m_hNormalization == NULL)
-    {
-        HMODULE hNormalization = NULL;
-
-        if (pTableData == NULL)
-        {
-            // Use OS implementation
-            hNormalization = GetModuleHandleW(W("kernel32.dll"));
-            if (!hNormalization)
-               ThrowLastError();
-        }
-
-        _ASSERTE(hNormalization != NULL);
-        m_hNormalization = hNormalization;
-    }
-
-    if (m_pfnNormalizationIsNormalizedStringFunc == NULL)
-    {
-        FARPROC pfn = GetProcAddress(m_hNormalization, "IsNormalizedString");
-        if (pfn == NULL)
-            ThrowLastError();
-        m_pfnNormalizationIsNormalizedStringFunc = (PFN_NORMALIZATION_IS_NORMALIZED_STRING)pfn;
-    }
-
-    if (m_pfnNormalizationNormalizeStringFunc == NULL)
-    {
-        FARPROC pfn = GetProcAddress(m_hNormalization, "NormalizeString");
-        if (pfn == NULL)
-            ThrowLastError();
-        m_pfnNormalizationNormalizeStringFunc = (PFN_NORMALIZATION_NORMALIZE_STRING)pfn;
-    }
-
-    if (pTableData != NULL)
-    {
-        if (m_pfnNormalizationInitNormalizationFunc == NULL)
-        {
-            FARPROC pfn = GetProcAddress(m_hNormalization, "InitNormalization");
-            if (pfn == NULL)
-                ThrowLastError();
-            m_pfnNormalizationInitNormalizationFunc = (PFN_NORMALIZATION_INIT_NORMALIZATION)pfn;
-        }
-
-        BYTE* pResult = m_pfnNormalizationInitNormalizationFunc( NormForm, pTableData);
-        if (pResult == NULL)
-            ThrowOutOfMemory();
-    }
-
-    END_QCALL;
-}
-
-#endif // FEATURE_COREFX_GLOBALIZATION
-
 /**
  * This function returns the number of items in EncodingDataTable.
  */
diff --git a/src/coreclr/src/mscorlib/PinvokeAnalyzerExceptionList.analyzerdata b/src/coreclr/src/mscorlib/PinvokeAnalyzerExceptionList.analyzerdata
new file mode 100644 (file)
index 0000000..4bbdcca
--- /dev/null
@@ -0,0 +1,3 @@
+<!-- Not a bug, these APIs are in the allowed list but under kernel32 and we need it under normaliz.dll -->
+normaliz.dll!IsNormalizedString
+normaliz.dll!NormalizeString
index 216dcf3..2990d76 100644 (file)
     <Compile Include="$(BclSourcesRoot)\System\HResults.cs" />
     <Compile Include="$(BclSourcesRoot)\Interop\Windows\kernel32\Interop.Globalization.cs" />
     <Compile Include="$(BclSourcesRoot)\Interop\Windows\Normaliz\Interop.Idna.cs" />
+    <Compile Include="$(BclSourcesRoot)\Interop\Windows\Normaliz\Interop.Normalization.cs" />
   </ItemGroup>
   <ItemGroup>
     <Compile Include="$(BclSourcesRoot)\System\Security\SecureString.cs" />
index 9280d8f..97746fd 100644 (file)
@@ -35,6 +35,7 @@ internal partial class Interop
         internal const int ERROR_MUTANT_LIMIT_EXCEEDED = 0x24B;
         internal const int ERROR_OPERATION_ABORTED = 0x3E3;
         internal const int ERROR_IO_PENDING = 0x3E5;
+        internal const int ERROR_NO_UNICODE_TRANSLATION = 0x459;
         internal const int ERROR_NOT_FOUND = 0x490;
         internal const int ERROR_BAD_IMPERSONATION_LEVEL = 0x542;
         internal const int E_FILENOTFOUND = unchecked((int)0x80070002);
diff --git a/src/coreclr/src/mscorlib/src/Interop/Windows/Normaliz/Interop.Normalization.cs b/src/coreclr/src/mscorlib/src/Interop/Windows/Normaliz/Interop.Normalization.cs
new file mode 100644 (file)
index 0000000..3e49f1f
--- /dev/null
@@ -0,0 +1,24 @@
+// 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.Runtime.InteropServices;
+
+internal partial class Interop
+{
+    internal partial class Normaliz
+    {
+        [DllImport("Normaliz.dll", CharSet = CharSet.Unicode, SetLastError = true)]
+        internal static extern bool IsNormalizedString(int normForm, string source, int length);
+
+        [DllImport("Normaliz.dll", CharSet = CharSet.Unicode, SetLastError = true)]
+        internal static extern int NormalizeString(
+                                        int normForm,
+                                        string source,
+                                        int sourceLength,
+                                        [System.Runtime.InteropServices.OutAttribute()]
+                                        char[] destination,
+                                        int destinationLength);
+    }
+}
index d760e44..10f6d21 100644 (file)
@@ -26,6 +26,11 @@ internal static class SR
         get { return Environment.GetResourceString("Arg_InvalidHexStyle"); }
     }
 
+    public static string Arg_OutOfMemoryException
+    {
+        get { return Environment.GetResourceString("Arg_OutOfMemoryException"); }
+    }
+
     public static string ArgumentNull_Array
     {
         get { return Environment.GetResourceString("ArgumentNull_Array"); }
@@ -838,4 +843,9 @@ internal static class SR
 
     internal static string PlatformNotSupported_OSXFileLocking =>
         Environment.GetResourceString("PlatformNotSupported_OSXFileLocking");
+
+    internal static string UnknownError_Num
+    {
+        get { return Environment.GetResourceString("UnknownError_Num"); }
+    }
 }
index 4287967..1e08817 100644 (file)
@@ -18,160 +18,30 @@ namespace System.Text
 
     internal class Normalization
     {
-        //
-        // Flags that track whether given normalization form was initialized
-        //
-        private static volatile bool NFC;
-        private static volatile bool NFD;
-        private static volatile bool NFKC;
-        private static volatile bool NFKD;
-        private static volatile bool IDNA;
-        private static volatile bool NFCDisallowUnassigned;
-        private static volatile bool NFDDisallowUnassigned;
-        private static volatile bool NFKCDisallowUnassigned;
-        private static volatile bool NFKDDisallowUnassigned;
-        private static volatile bool IDNADisallowUnassigned;
-        private static volatile bool Other;
-
-        // These are error codes we get back from the Normalization DLL
-        private const int ERROR_SUCCESS = 0;
-        private const int ERROR_NOT_ENOUGH_MEMORY = 8;
-        private const int ERROR_INVALID_PARAMETER = 87;
-        private const int ERROR_INSUFFICIENT_BUFFER = 122;
-        private const int ERROR_NO_UNICODE_TRANSLATION = 1113;
-
-        static private unsafe void InitializeForm(NormalizationForm form, String strDataFile)
+        internal static bool IsNormalized(String strInput, NormalizationForm normForm)
         {
-            byte* pTables = null;
-
-            // Normalization uses OS on Win8
-            if (!Environment.IsWindows8OrAbove)
-            {
-                if (strDataFile == null)
-                {
-                    // They were supposed to have a form that we know about!
-                    throw new ArgumentException(
-                        Environment.GetResourceString("Argument_InvalidNormalizationForm"));
-                }
-
-                // Tell the DLL where to find our data
-                pTables = GlobalizationAssembly.GetGlobalizationResourceBytePtr(
-                   typeof(Normalization).Assembly, strDataFile);
-                if (pTables == null)
-                {
-                    // Unable to load the specified normalizationForm,
-                    // tables not loaded from file
-                    throw new ArgumentException(
-                        Environment.GetResourceString("Argument_InvalidNormalizationForm"));
-                }
-            }
+            Debug.Assert(strInput != null);
 
-            nativeNormalizationInitNormalization(form, pTables);
-        }
+            // The only way to know if IsNormalizedString failed is through checking the Win32 last error
+            // IsNormalizedString pinvoke has SetLastError attribute property which will set the last error 
+            // to 0 (ERROR_SUCCESS) before executing the calls.
+            bool result = Interop.Normaliz.IsNormalizedString((int)normForm, strInput, strInput.Length);
 
-        static private void EnsureInitialized(NormalizationForm form)
-        {
-            switch ((ExtendedNormalizationForms)form)
+            int lastError = Marshal.GetLastWin32Error();
+            switch (lastError)
             {
-                case ExtendedNormalizationForms.FormC:
-                    if (NFC) return;
-                    InitializeForm(form, "normnfc.nlp");
-                    NFC = true;
-                    break;
-
-                case ExtendedNormalizationForms.FormD:
-                    if (NFD) return;
-                    InitializeForm(form, "normnfd.nlp");
-                    NFD = true;
-                    break;
-
-                case ExtendedNormalizationForms.FormKC:
-                    if (NFKC) return;
-                    InitializeForm(form, "normnfkc.nlp");
-                    NFKC = true;
-                    break;
-
-                case ExtendedNormalizationForms.FormKD:
-                    if (NFKD) return;
-                    InitializeForm(form, "normnfkd.nlp");
-                    NFKD = true;
-                    break;
-
-                case ExtendedNormalizationForms.FormIdna:
-                    if (IDNA) return;
-                    InitializeForm(form, "normidna.nlp");
-                    IDNA = true;
+                case Interop.Errors.ERROR_SUCCESS:
                     break;
 
-                case ExtendedNormalizationForms.FormCDisallowUnassigned:
-                    if (NFCDisallowUnassigned) return;
-                    InitializeForm(form, "normnfc.nlp");
-                    NFCDisallowUnassigned = true;
-                    break;
+                case Interop.Errors.ERROR_INVALID_PARAMETER:
+                case Interop.Errors.ERROR_NO_UNICODE_TRANSLATION:
+                    throw new ArgumentException(SR.Argument_InvalidCharSequenceNoIndex, nameof(strInput));
 
-                case ExtendedNormalizationForms.FormDDisallowUnassigned:
-                    if (NFDDisallowUnassigned) return;
-                    InitializeForm(form, "normnfd.nlp");
-                    NFDDisallowUnassigned = true;
-                    break;
-
-                case ExtendedNormalizationForms.FormKCDisallowUnassigned:
-                    if (NFKCDisallowUnassigned) return;
-                    InitializeForm(form, "normnfkc.nlp");
-                    NFKCDisallowUnassigned = true;
-                    break;
-
-                case ExtendedNormalizationForms.FormKDDisallowUnassigned:
-                    if (NFKDDisallowUnassigned) return;
-                    InitializeForm(form, "normnfkd.nlp");
-                    NFKDDisallowUnassigned = true;
-                    break;
-
-                case ExtendedNormalizationForms.FormIdnaDisallowUnassigned:
-                    if (IDNADisallowUnassigned) return;
-                    InitializeForm(form, "normidna.nlp");
-                    IDNADisallowUnassigned = true;
-                    break;
+                case Interop.Errors.ERROR_NOT_ENOUGH_MEMORY:
+                    throw new OutOfMemoryException(SR.Arg_OutOfMemoryException);
 
                 default:
-                    if (Other) return;
-                    InitializeForm(form, null);
-                    Other = true;
-                    break;
-            }
-        }
-
-        internal static bool IsNormalized(String strInput, NormalizationForm normForm)
-        {
-            Contract.Requires(strInput != null);
-
-            EnsureInitialized(normForm);
-
-            int iError = ERROR_SUCCESS;
-            bool result = nativeNormalizationIsNormalizedString(
-                                normForm,
-                                ref iError,
-                                strInput,
-                                strInput.Length);
-
-            switch (iError)
-            {
-                // Success doesn't need to do anything
-                case ERROR_SUCCESS:
-                    break;
-
-                // Do appropriate stuff for the individual errors:
-                case ERROR_INVALID_PARAMETER:
-                case ERROR_NO_UNICODE_TRANSLATION:
-                    throw new ArgumentException(
-                        Environment.GetResourceString("Argument_InvalidCharSequenceNoIndex"),
-                        nameof(strInput));
-                case ERROR_NOT_ENOUGH_MEMORY:
-                    throw new OutOfMemoryException(
-                        Environment.GetResourceString("Arg_OutOfMemoryException"));
-                default:
-                    throw new InvalidOperationException(
-                        Environment.GetResourceString("UnknownError_Num", iError));
+                    throw new InvalidOperationException(SR.Format(SR.UnknownError_Num, lastError));
             }
 
             return result;
@@ -179,37 +49,34 @@ namespace System.Text
 
         internal static String Normalize(String strInput, NormalizationForm normForm)
         {
-            Contract.Requires(strInput != null);
+            Debug.Assert(strInput != null);
 
-            EnsureInitialized(normForm);
-
-            int iError = ERROR_SUCCESS;
+            // we depend on Win32 last error when calling NormalizeString
+            // NormalizeString pinvoke has SetLastError attribute property which will set the last error 
+            // to 0 (ERROR_SUCCESS) before executing the calls.
 
             // Guess our buffer size first
-            int iLength = nativeNormalizationNormalizeString(normForm, ref iError, strInput, strInput.Length, null, 0);
+            int iLength = Interop.Normaliz.NormalizeString((int)normForm, strInput, strInput.Length, null, 0);
 
+            int lastError = Marshal.GetLastWin32Error();
             // Could have an error (actually it'd be quite hard to have an error here)
-            if (iError != ERROR_SUCCESS)
+            if ((lastError != Interop.Errors.ERROR_SUCCESS) || iLength < 0)
             {
-                if (iError == ERROR_INVALID_PARAMETER)
-                    throw new ArgumentException(
-                        Environment.GetResourceString("Argument_InvalidCharSequenceNoIndex"),
-                        nameof(strInput));
+                if (lastError == Interop.Errors.ERROR_INVALID_PARAMETER)
+                    throw new ArgumentException(SR.Argument_InvalidCharSequenceNoIndex, nameof(strInput));
 
                 // We shouldn't really be able to get here..., guessing length is
                 // a trivial math function...
                 // Can't really be Out of Memory, but just in case:
-                if (iError == ERROR_NOT_ENOUGH_MEMORY)
-                    throw new OutOfMemoryException(
-                        Environment.GetResourceString("Arg_OutOfMemoryException"));
+                if (lastError == Interop.Errors.ERROR_NOT_ENOUGH_MEMORY)
+                    throw new OutOfMemoryException(SR.Arg_OutOfMemoryException);
 
                 // Who knows what happened?  Not us!
-                throw new InvalidOperationException(
-                    Environment.GetResourceString("UnknownError_Num", iError));
+                throw new InvalidOperationException(SR.Format(SR.UnknownError_Num, lastError));
             }
 
             // Don't break for empty strings (only possible for D & KD and not really possible at that)
-            if (iLength == 0) return String.Empty;
+            if (iLength == 0) return string.Empty;
 
             // Someplace to stick our buffer
             char[] cBuffer = null;
@@ -219,60 +86,39 @@ namespace System.Text
                 // (re)allocation buffer and normalize string
                 cBuffer = new char[iLength];
 
-                iLength = nativeNormalizationNormalizeString(
-                                    normForm,
-                                    ref iError,
-                                    strInput,
-                                    strInput.Length,
-                                    cBuffer,
-                                    cBuffer.Length);
+                // NormalizeString pinvoke has SetLastError attribute property which will set the last error 
+                // to 0 (ERROR_SUCCESS) before executing the calls.
+                iLength = Interop.Normaliz.NormalizeString((int)normForm, strInput, strInput.Length, cBuffer, cBuffer.Length);
+                lastError = Marshal.GetLastWin32Error();
 
-                if (iError == ERROR_SUCCESS)
+                if (lastError == Interop.Errors.ERROR_SUCCESS)
                     break;
 
                 // Could have an error (actually it'd be quite hard to have an error here)
-                switch (iError)
+                switch (lastError)
                 {
                     // Do appropriate stuff for the individual errors:
-                    case ERROR_INSUFFICIENT_BUFFER:
+                    case Interop.Errors.ERROR_INSUFFICIENT_BUFFER:
+                        iLength = Math.Abs(iLength);
                         Debug.Assert(iLength > cBuffer.Length, "Buffer overflow should have iLength > cBuffer.Length");
                         continue;
 
-                    case ERROR_INVALID_PARAMETER:
-                    case ERROR_NO_UNICODE_TRANSLATION:
+                    case Interop.Errors.ERROR_INVALID_PARAMETER:
+                    case Interop.Errors.ERROR_NO_UNICODE_TRANSLATION:
                         // Illegal code point or order found.  Ie: FFFE or D800 D800, etc.
-                        throw new ArgumentException(
-                            Environment.GetResourceString("Argument_InvalidCharSequence", iLength),
-                            nameof(strInput));
-                    case ERROR_NOT_ENOUGH_MEMORY:
-                        throw new OutOfMemoryException(
-                            Environment.GetResourceString("Arg_OutOfMemoryException"));
+                        throw new ArgumentException(SR.Argument_InvalidCharSequenceNoIndex, nameof(strInput));
+
+                    case Interop.Errors.ERROR_NOT_ENOUGH_MEMORY:
+                        throw new OutOfMemoryException(SR.Arg_OutOfMemoryException);
 
                     default:
                         // We shouldn't get here...
-                        throw new InvalidOperationException(
-                            Environment.GetResourceString("UnknownError_Num", iError));
+                        throw new InvalidOperationException(SR.Format(SR.UnknownError_Num, lastError));
                 }
             }
 
             // Copy our buffer into our new string, which will be the appropriate size
-            return new String(cBuffer, 0, iLength);
+            return new string(cBuffer, 0, iLength);
         }
-
-        [MethodImplAttribute(MethodImplOptions.InternalCall)]
-        unsafe private static extern int nativeNormalizationNormalizeString(
-            NormalizationForm normForm, ref int iError,
-            String lpSrcString, int cwSrcLength,
-            char[] lpDstString, int cwDstLength);
-
-        [MethodImplAttribute(MethodImplOptions.InternalCall)]
-        unsafe private static extern bool nativeNormalizationIsNormalizedString(
-            NormalizationForm normForm, ref int iError,
-            String lpString, int cwLength);
-
-        [SuppressUnmanagedCodeSecurity]
-        [DllImport(JitHelpers.QCall, CharSet = CharSet.Unicode)]
-        unsafe private static extern void nativeNormalizationInitNormalization(
-            NormalizationForm normForm, byte* pTableData);
     }
 }
index a420c52..5f3d4c5 100644 (file)
@@ -225,14 +225,6 @@ FCFuncStart(gSafeBufferFuncs)
     FCFuncElement("StructureToPtrNative", SafeBuffer::StructureToPtr)
 FCFuncEnd()
 
-#ifndef FEATURE_COREFX_GLOBALIZATION
-FCFuncStart(gNormalizationFuncs)
-    FCFuncElement("nativeNormalizationIsNormalizedString", COMNlsInfo::nativeNormalizationIsNormalizedString)
-    FCFuncElement("nativeNormalizationNormalizeString", COMNlsInfo::nativeNormalizationNormalizeString)
-    QCFuncElement("nativeNormalizationInitNormalization", COMNlsInfo::nativeNormalizationInitNormalization)
-FCFuncEnd()
-#endif // FEATURE_COREFX_GLOBALIZATION
-
 FCFuncStart(gTypedReferenceFuncs)
     FCFuncElement("InternalToObject", ReflectionInvocation::TypedReferenceToObject)
     FCFuncElement("InternalSetTypedReference", ReflectionInvocation::SetTypedReference)
@@ -1427,9 +1419,6 @@ FCClassElement("MngdSafeArrayMarshaler", "System.StubHelpers", gMngdSafeArrayMar
 FCClassElement("ModuleBuilder", "System.Reflection.Emit", gCOMModuleBuilderFuncs)
 FCClassElement("ModuleHandle", "System", gCOMModuleHandleFuncs)
 FCClassElement("Monitor", "System.Threading", gMonitorFuncs)
-#ifndef FEATURE_COREFX_GLOBALIZATION
-FCClassElement("Normalization", "System.Text", gNormalizationFuncs)
-#endif // FEATURE_COREFX_GLOBALIZATION
 FCClassElement("Number", "System", gNumberFuncs)
 #ifdef FEATURE_COMINTEROP
 FCClassElement("OAVariantLib", "Microsoft.Win32", gOAVariantFuncs)