diff options
author | Jiyoung Yun <jy910.yun@samsung.com> | 2016-12-27 16:46:08 +0900 |
---|---|---|
committer | Jiyoung Yun <jy910.yun@samsung.com> | 2016-12-27 16:46:08 +0900 |
commit | db20f3f1bb8595633a7e16c8900fd401a453a6b5 (patch) | |
tree | e5435159cd1bf0519276363a6fe1663d1721bed3 /src/mscorlib/src/System/Globalization/CharUnicodeInfo.cs | |
parent | 4b4aad7217d3292650e77eec2cf4c198ea9c3b4b (diff) | |
download | coreclr-db20f3f1bb8595633a7e16c8900fd401a453a6b5.tar.gz coreclr-db20f3f1bb8595633a7e16c8900fd401a453a6b5.tar.bz2 coreclr-db20f3f1bb8595633a7e16c8900fd401a453a6b5.zip |
Imported Upstream version 1.0.0.9127upstream/1.0.0.9127
Diffstat (limited to 'src/mscorlib/src/System/Globalization/CharUnicodeInfo.cs')
-rw-r--r-- | src/mscorlib/src/System/Globalization/CharUnicodeInfo.cs | 66 |
1 files changed, 28 insertions, 38 deletions
diff --git a/src/mscorlib/src/System/Globalization/CharUnicodeInfo.cs b/src/mscorlib/src/System/Globalization/CharUnicodeInfo.cs index 63151951f9..2822b418ef 100644 --- a/src/mscorlib/src/System/Globalization/CharUnicodeInfo.cs +++ b/src/mscorlib/src/System/Globalization/CharUnicodeInfo.cs @@ -23,6 +23,7 @@ namespace System.Globalization { using System.Runtime.Versioning; using System.Reflection; using System.Security; + using System.Diagnostics; using System.Diagnostics.Contracts; @@ -46,14 +47,11 @@ namespace System.Globalization { static bool s_initialized = InitTable(); // The native pointer to the 12:4:4 index table of the Unicode cateogry data. - [SecurityCritical] unsafe static ushort* s_pCategoryLevel1Index; - [SecurityCritical] unsafe static byte* s_pCategoriesValue; // The native pointer to the 12:4:4 index table of the Unicode numeric data. // The value of this index table is an index into the real value table stored in s_pNumericValues. - [SecurityCritical] unsafe static ushort* s_pNumericLevel1Index; // The numeric value table, which is indexed by s_pNumericLevel1Index. @@ -61,12 +59,10 @@ namespace System.Globalization { // unsafe static double* s_pNumericValues; // To get around the IA64 alignment issue. Our double data is aligned in 8-byte boundary, but loader loads the embeded table starting // at 4-byte boundary. This cause a alignment issue since double is 8-byte. - [SecurityCritical] unsafe static byte* s_pNumericValues; // The digit value table, which is indexed by s_pNumericLevel1Index. It shares the same indice as s_pNumericValues. // Every item contains the value for decimal digit/digit value. - [SecurityCritical] unsafe static DigitValues* s_pDigitValues; internal const String UNICODE_INFO_FILE_NAME = "charinfo.nlp"; @@ -111,7 +107,6 @@ namespace System.Globalization { //use. We allocate this once in the class initializer and then we don't need to worry //about it again. // - [System.Security.SecuritySafeCritical] // auto-generated unsafe static bool InitTable() { // Go to native side and get pointer to the native table @@ -143,8 +138,8 @@ namespace System.Globalization { //////////////////////////////////////////////////////////////////////// internal static int InternalConvertToUtf32(String s, int index) { - Contract.Assert(s != null, "s != null"); - Contract.Assert(index >= 0 && index < s.Length, "index < s.Length"); + Debug.Assert(s != null, "s != null"); + Debug.Assert(index >= 0 && index < s.Length, "index < s.Length"); if (index < s.Length - 1) { int temp1 = (int)s[index] - HIGH_SURROGATE_START; if (temp1 >= 0 && temp1 <= 0x3ff) { @@ -181,9 +176,9 @@ namespace System.Globalization { //////////////////////////////////////////////////////////////////////// internal static int InternalConvertToUtf32(String s, int index, out int charLength) { - Contract.Assert(s != null, "s != null"); - Contract.Assert(s.Length > 0, "s.Length > 0"); - Contract.Assert(index >= 0 && index < s.Length, "index >= 0 && index < s.Length"); + Debug.Assert(s != null, "s != null"); + Debug.Assert(s.Length > 0, "s.Length > 0"); + Debug.Assert(index >= 0 && index < s.Length, "index >= 0 && index < s.Length"); charLength = 1; if (index < s.Length - 1) { int temp1 = (int)s[index] - HIGH_SURROGATE_START; @@ -209,8 +204,8 @@ namespace System.Globalization { internal static bool IsWhiteSpace(String s, int index) { - Contract.Assert(s != null, "s!=null"); - Contract.Assert(index >= 0 && index < s.Length, "index >= 0 && index < s.Length"); + Debug.Assert(s != null, "s!=null"); + Debug.Assert(index >= 0 && index < s.Length, "index >= 0 && index < s.Length"); UnicodeCategory uc = GetUnicodeCategory(s, index); // In Unicode 3.0, U+2028 is the only character which is under the category "LineSeparator". @@ -245,9 +240,8 @@ namespace System.Globalization { // // Note that for ch in the range D800-DFFF we just treat it as any other non-numeric character // - [System.Security.SecuritySafeCritical] // auto-generated internal unsafe static double InternalGetNumericValue(int ch) { - Contract.Assert(ch >= 0 && ch <= 0x10ffff, "ch is not in valid Unicode range."); + Debug.Assert(ch >= 0 && ch <= 0x10ffff, "ch is not in valid Unicode range."); // Get the level 2 item from the highest 12 bit (8 - 19) of ch. ushort index = s_pNumericLevel1Index[ch >> 8]; // Get the level 2 WORD offset from the 4 - 7 bit of ch. This provides the base offset of the level 3 table. @@ -278,9 +272,8 @@ namespace System.Globalization { // // Note that for ch in the range D800-DFFF we just treat it as any other non-numeric character // - [System.Security.SecuritySafeCritical] // auto-generated internal unsafe static DigitValues* InternalGetDigitValues(int ch) { - Contract.Assert(ch >= 0 && ch <= 0x10ffff, "ch is not in valid Unicode range."); + Debug.Assert(ch >= 0 && ch <= 0x10ffff, "ch is not in valid Unicode range."); // Get the level 2 item from the highest 12 bit (8 - 19) of ch. ushort index = s_pNumericLevel1Index[ch >> 8]; // Get the level 2 WORD offset from the 4 - 7 bit of ch. This provides the base offset of the level 3 table. @@ -292,12 +285,10 @@ namespace System.Globalization { return &(s_pDigitValues[pBytePtr[(ch & 0x000f)]]); } - [System.Security.SecuritySafeCritical] // auto-generated internal unsafe static sbyte InternalGetDecimalDigitValue(int ch) { return (InternalGetDigitValues(ch)->decimalDigit); } - [System.Security.SecuritySafeCritical] // auto-generated internal unsafe static sbyte InternalGetDigitValue(int ch) { return (InternalGetDigitValues(ch)->digit); } @@ -326,10 +317,10 @@ namespace System.Globalization { public static double GetNumericValue(String s, int index) { if (s == null) { - throw new ArgumentNullException("s"); + throw new ArgumentNullException(nameof(s)); } if (index < 0 || index >= s.Length) { - throw new ArgumentOutOfRangeException("index", Environment.GetResourceString("ArgumentOutOfRange_Index")); + throw new ArgumentOutOfRangeException(nameof(index), Environment.GetResourceString("ArgumentOutOfRange_Index")); } Contract.EndContractBlock(); return (InternalGetNumericValue(InternalConvertToUtf32(s, index))); @@ -361,10 +352,10 @@ namespace System.Globalization { public static int GetDecimalDigitValue(String s, int index) { if (s == null) { - throw new ArgumentNullException("s"); + throw new ArgumentNullException(nameof(s)); } if (index < 0 || index >= s.Length) { - throw new ArgumentOutOfRangeException("index", Environment.GetResourceString("ArgumentOutOfRange_Index")); + throw new ArgumentOutOfRangeException(nameof(index), Environment.GetResourceString("ArgumentOutOfRange_Index")); } Contract.EndContractBlock(); @@ -398,10 +389,10 @@ namespace System.Globalization { public static int GetDigitValue(String s, int index) { if (s == null) { - throw new ArgumentNullException("s"); + throw new ArgumentNullException(nameof(s)); } if (index < 0 || index >= s.Length) { - throw new ArgumentOutOfRangeException("index", Environment.GetResourceString("ArgumentOutOfRange_Index")); + throw new ArgumentOutOfRangeException(nameof(index), Environment.GetResourceString("ArgumentOutOfRange_Index")); } Contract.EndContractBlock(); return (InternalGetDigitValue(InternalConvertToUtf32(s, index))); @@ -415,9 +406,9 @@ namespace System.Globalization { public static UnicodeCategory GetUnicodeCategory(String s, int index) { if (s==null) - throw new ArgumentNullException("s"); + throw new ArgumentNullException(nameof(s)); if (((uint)index)>=((uint)s.Length)) { - throw new ArgumentOutOfRangeException("index"); + throw new ArgumentOutOfRangeException(nameof(index)); } Contract.EndContractBlock(); return InternalGetUnicodeCategory(s, index); @@ -441,9 +432,8 @@ namespace System.Globalization { // //////////////////////////////////////////////////////////////////////// - [System.Security.SecuritySafeCritical] // auto-generated internal unsafe static byte InternalGetCategoryValue(int ch, int offset) { - Contract.Assert(ch >= 0 && ch <= 0x10ffff, "ch is not in valid Unicode range."); + Debug.Assert(ch >= 0 && ch <= 0x10ffff, "ch is not in valid Unicode range."); // Get the level 2 item from the highest 12 bit (8 - 19) of ch. ushort index = s_pCategoryLevel1Index[ch >> 8]; // Get the level 2 WORD offset from the 4 - 7 bit of ch. This provides the base offset of the level 3 table. @@ -457,7 +447,7 @@ namespace System.Globalization { // Make sure that OtherNotAssigned is the last category in UnicodeCategory. // If that changes, change the following assertion as well. // - //Contract.Assert(uc >= 0 && uc <= UnicodeCategory.OtherNotAssigned, "Table returns incorrect Unicode category"); + //Debug.Assert(uc >= 0 && uc <= UnicodeCategory.OtherNotAssigned, "Table returns incorrect Unicode category"); return (uc); } @@ -467,9 +457,9 @@ namespace System.Globalization { internal static BidiCategory GetBidiCategory(String s, int index) { if (s==null) - throw new ArgumentNullException("s"); + throw new ArgumentNullException(nameof(s)); if (((uint)index)>=((uint)s.Length)) { - throw new ArgumentOutOfRangeException("index"); + throw new ArgumentOutOfRangeException(nameof(index)); } Contract.EndContractBlock(); return ((BidiCategory)InternalGetCategoryValue(InternalConvertToUtf32(s, index), BIDI_CATEGORY_OFFSET)); @@ -489,8 +479,8 @@ namespace System.Globalization { //////////////////////////////////////////////////////////////////////// internal static UnicodeCategory InternalGetUnicodeCategory(String value, int index) { - Contract.Assert(value != null, "value can not be null"); - Contract.Assert(index < value.Length, "index < value.Length"); + Debug.Assert(value != null, "value can not be null"); + Debug.Assert(index < value.Length, "index < value.Length"); return (InternalGetUnicodeCategory(InternalConvertToUtf32(value, index))); } @@ -503,15 +493,15 @@ namespace System.Globalization { //////////////////////////////////////////////////////////////////////// internal static UnicodeCategory InternalGetUnicodeCategory(String str, int index, out int charLength) { - Contract.Assert(str != null, "str can not be null"); - Contract.Assert(str.Length > 0, "str.Length > 0");; - Contract.Assert(index >= 0 && index < str.Length, "index >= 0 && index < str.Length"); + Debug.Assert(str != null, "str can not be null"); + Debug.Assert(str.Length > 0, "str.Length > 0");; + Debug.Assert(index >= 0 && index < str.Length, "index >= 0 && index < str.Length"); return (InternalGetUnicodeCategory(InternalConvertToUtf32(str, index, out charLength))); } internal static bool IsCombiningCategory(UnicodeCategory uc) { - Contract.Assert(uc >= 0, "uc >= 0"); + Debug.Assert(uc >= 0, "uc >= 0"); return ( uc == UnicodeCategory.NonSpacingMark || uc == UnicodeCategory.SpacingCombiningMark || |