diff options
author | Hugh Bellamy <hughbellars@gmail.com> | 2017-06-24 05:23:50 +0700 |
---|---|---|
committer | Tarek Mahmoud Sayed <tarekms@microsoft.com> | 2017-06-23 15:23:50 -0700 |
commit | ffe925a22778e33563eaf23c04a33933ca341e97 (patch) | |
tree | 2aa769fc016be4ce09d0c3a8dd8b5d9c66a160a2 /src/mscorlib | |
parent | 619334db7e5595888e6409570750ccffe4c4c126 (diff) | |
download | coreclr-ffe925a22778e33563eaf23c04a33933ca341e97.tar.gz coreclr-ffe925a22778e33563eaf23c04a33933ca341e97.tar.bz2 coreclr-ffe925a22778e33563eaf23c04a33933ca341e97.zip |
Update Windows parameter name for Normalize/IsNormalized with invalid form (#12430)
Diffstat (limited to 'src/mscorlib')
-rw-r--r-- | src/mscorlib/src/System/Text/Normalization.Windows.cs | 22 |
1 files changed, 17 insertions, 5 deletions
diff --git a/src/mscorlib/src/System/Text/Normalization.Windows.cs b/src/mscorlib/src/System/Text/Normalization.Windows.cs index 389dba743d..8e284e798d 100644 --- a/src/mscorlib/src/System/Text/Normalization.Windows.cs +++ b/src/mscorlib/src/System/Text/Normalization.Windows.cs @@ -18,7 +18,7 @@ namespace System.Text internal class Normalization { - internal static bool IsNormalized(String strInput, NormalizationForm normForm) + internal static bool IsNormalized(String strInput, NormalizationForm normalizationForm) { if (GlobalizationMode.Invariant) { @@ -32,7 +32,7 @@ namespace System.Text // 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); + bool result = Interop.Normaliz.IsNormalizedString((int)normalizationForm, strInput, strInput.Length); int lastError = Marshal.GetLastWin32Error(); switch (lastError) @@ -42,6 +42,11 @@ namespace System.Text case Interop.Errors.ERROR_INVALID_PARAMETER: case Interop.Errors.ERROR_NO_UNICODE_TRANSLATION: + if (!Enum.IsDefined(typeof(NormalizationForm), normalizationForm)) + { + throw new ArgumentException(SR.Argument_InvalidNormalizationForm, nameof(normalizationForm)); + } + throw new ArgumentException(SR.Argument_InvalidCharSequenceNoIndex, nameof(strInput)); case Interop.Errors.ERROR_NOT_ENOUGH_MEMORY: @@ -54,7 +59,7 @@ namespace System.Text return result; } - internal static String Normalize(String strInput, NormalizationForm normForm) + internal static String Normalize(String strInput, NormalizationForm normalizationForm) { if (GlobalizationMode.Invariant) { @@ -70,14 +75,21 @@ namespace System.Text // to 0 (ERROR_SUCCESS) before executing the calls. // Guess our buffer size first - int iLength = Interop.Normaliz.NormalizeString((int)normForm, strInput, strInput.Length, null, 0); + int iLength = Interop.Normaliz.NormalizeString((int)normalizationForm, 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 ((lastError != Interop.Errors.ERROR_SUCCESS) || iLength < 0) { if (lastError == Interop.Errors.ERROR_INVALID_PARAMETER) + { + if (!Enum.IsDefined(typeof(NormalizationForm), normalizationForm)) + { + throw new ArgumentException(SR.Argument_InvalidNormalizationForm, nameof(normalizationForm)); + } + throw new ArgumentException(SR.Argument_InvalidCharSequenceNoIndex, nameof(strInput)); + } // We shouldn't really be able to get here..., guessing length is // a trivial math function... @@ -102,7 +114,7 @@ namespace System.Text // 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); + iLength = Interop.Normaliz.NormalizeString((int)normalizationForm, strInput, strInput.Length, cBuffer, cBuffer.Length); lastError = Marshal.GetLastWin32Error(); if (lastError == Interop.Errors.ERROR_SUCCESS) |