From dff1a185802abd109371f0317ce84d290c6675f6 Mon Sep 17 00:00:00 2001 From: Jan Kotas Date: Wed, 31 Aug 2016 17:21:40 -0700 Subject: [PATCH] Update Unix System.Globalization implementation from CoreRT (#7004) --- .../corefx/System/Globalization/Calendar.cs | 17 +- .../System/Globalization/CalendarData.Windows.cs | 90 ++- .../corefx/System/Globalization/CalendarData.cs | 1 - .../Globalization/CalendricalCalculationsHelper.cs | 154 +++--- .../corefx/System/Globalization/CharUnicodeInfo.cs | 4 - .../System/Globalization/CharUnicodeInfoData.cs | 3 +- .../Globalization/ChineseLunisolarCalendar.cs | 27 +- .../System/Globalization/CompareInfo.Unix.cs | 44 +- .../System/Globalization/CompareInfo.Windows.cs | 146 +++-- .../corefx/System/Globalization/CompareInfo.cs | 34 +- .../System/Globalization/CultureData.Unix.cs | 46 +- .../System/Globalization/CultureData.Windows.cs | 112 ++-- .../corefx/System/Globalization/CultureData.cs | 615 ++++++++++----------- .../System/Globalization/CultureInfo.Windows.cs | 3 +- .../corefx/System/Globalization/CultureInfo.cs | 7 +- .../Globalization/CultureNotFoundException.cs | 18 +- .../System/Globalization/DateTimeFormatInfo.cs | 284 +++++----- .../Globalization/DateTimeFormatInfoScanner.cs | 25 +- .../Globalization/EastAsianLunisolarCalendar.cs | 4 +- .../Globalization/GregorianCalendarHelper.cs | 8 +- .../corefx/System/Globalization/HebrewCalendar.cs | 72 +-- .../corefx/System/Globalization/HebrewNumber.cs | 28 +- .../corefx/System/Globalization/HijriCalendar.cs | 43 +- .../System/Globalization/JapaneseCalendar.cs | 2 +- .../Globalization/JapaneseLunisolarCalendar.cs | 4 +- .../corefx/System/Globalization/JulianCalendar.cs | 46 +- .../corefx/System/Globalization/KoreanCalendar.cs | 19 +- .../Globalization/KoreanLunisolarCalendar.cs | 27 +- .../System/Globalization/NumberFormatInfo.cs | 16 +- .../corefx/System/Globalization/PersianCalendar.cs | 53 +- .../corefx/System/Globalization/RegionInfo.cs | 59 +- .../corefx/System/Globalization/StringInfo.cs | 32 +- .../corefx/System/Globalization/TaiwanCalendar.cs | 2 +- .../Globalization/TaiwanLunisolarCalendar.cs | 27 +- .../System/Globalization/TextElementEnumerator.cs | 72 ++- .../corefx/System/Globalization/TextInfo.Unix.cs | 22 +- .../System/Globalization/TextInfo.Windows.cs | 34 +- .../corefx/System/Globalization/TextInfo.cs | 73 +-- .../System/Globalization/ThaiBuddhistCalendar.cs | 4 +- .../corefx/System/Globalization/TimeSpanStyles.cs | 1 + .../System/Globalization/UmAlQuraCalendar.cs | 63 +-- .../corefx/System/Globalization/UnicodeCategory.cs | 14 - 42 files changed, 1054 insertions(+), 1301 deletions(-) diff --git a/src/mscorlib/corefx/System/Globalization/Calendar.cs b/src/mscorlib/corefx/System/Globalization/Calendar.cs index 77120cb..343682d 100644 --- a/src/mscorlib/corefx/System/Globalization/Calendar.cs +++ b/src/mscorlib/corefx/System/Globalization/Calendar.cs @@ -62,10 +62,10 @@ namespace System.Globalization internal const long MaxMillis = (long)DaysTo10000 * MillisPerDay; - private int m_currentEraValue = -1; + private int _currentEraValue = -1; [OptionalField(VersionAdded = 2)] - private bool m_isReadOnly = false; + private bool _isReadOnly = false; #if INSIDE_CLR internal const CalendarId CAL_HEBREW = CalendarId.HEBREW; @@ -137,7 +137,7 @@ namespace System.Globalization [System.Runtime.InteropServices.ComVisible(false)] public bool IsReadOnly { - get { return (m_isReadOnly); } + get { return (_isReadOnly); } } //////////////////////////////////////////////////////////////////////// @@ -178,7 +178,7 @@ namespace System.Globalization internal void VerifyWritable() { - if (m_isReadOnly) + if (_isReadOnly) { throw new InvalidOperationException(SR.InvalidOperation_ReadOnly); } @@ -186,7 +186,7 @@ namespace System.Globalization internal void SetReadOnlyState(bool readOnly) { - m_isReadOnly = readOnly; + _isReadOnly = readOnly; } @@ -204,12 +204,12 @@ namespace System.Globalization get { // The following code assumes that the current era value can not be -1. - if (m_currentEraValue == -1) + if (_currentEraValue == -1) { Contract.Assert(BaseCalendarID != CalendarId.UNINITIALIZED_VALUE, "[Calendar.CurrentEraValue] Expected a real calendar ID"); - m_currentEraValue = CalendarData.GetCalendarData(BaseCalendarID).iCurrentEra; + _currentEraValue = CalendarData.GetCalendarData(BaseCalendarID).iCurrentEra; } - return (m_currentEraValue); + return (_currentEraValue); } } @@ -840,7 +840,6 @@ namespace System.Globalization throw new ArgumentOutOfRangeException(null, SR.ArgumentOutOfRange_BadHourMinuteSecond); } - [System.Security.SecuritySafeCritical] // auto-generated internal static int GetSystemTwoDigitYearSetting(CalendarId CalID, int defaultYearValue) { // Call nativeGetTwoDigitYearMax diff --git a/src/mscorlib/corefx/System/Globalization/CalendarData.Windows.cs b/src/mscorlib/corefx/System/Globalization/CalendarData.Windows.cs index 7f61721..bdf3ff1 100644 --- a/src/mscorlib/corefx/System/Globalization/CalendarData.Windows.cs +++ b/src/mscorlib/corefx/System/Globalization/CalendarData.Windows.cs @@ -1,6 +1,7 @@ // 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; using System.Runtime.CompilerServices; @@ -139,15 +140,11 @@ namespace System.Globalization } GCHandle contextHandle = GCHandle.Alloc(data); - try { - EnumCalendarInfoExExCallback callback = new EnumCalendarInfoExExCallback(EnumCalendarsCallback); - Interop.mincore_private.LParamCallbackContext context = new Interop.mincore_private.LParamCallbackContext(); - context.lParam = (IntPtr)contextHandle; - // Now call the enumeration API. Work is done by our callback function - Interop.mincore_private.EnumCalendarInfoExEx(callback, localeName, ENUM_ALL_CALENDARS, null, CAL_ICALINTVALUE, context); + IntPtr callback = AddrofIntrinsics.AddrOf>(EnumCalendarsCallback); + Interop.mincore.EnumCalendarInfoExEx(callback, localeName, ENUM_ALL_CALENDARS, null, CAL_ICALINTVALUE, (IntPtr)contextHandle); } finally { @@ -171,30 +168,30 @@ namespace System.Globalization // PAL Layer ends here - const uint CAL_RETURN_NUMBER = 0x20000000; - const uint CAL_RETURN_GENITIVE_NAMES = 0x10000000; - const uint CAL_NOUSEROVERRIDE = 0x80000000; - const uint CAL_SCALNAME = 0x00000002; - const uint CAL_SMONTHDAY = 0x00000038; - const uint CAL_SSHORTDATE = 0x00000005; - const uint CAL_SLONGDATE = 0x00000006; - const uint CAL_SYEARMONTH = 0x0000002f; - const uint CAL_SDAYNAME7 = 0x0000000d; - const uint CAL_SABBREVDAYNAME7 = 0x00000014; - const uint CAL_SMONTHNAME1 = 0x00000015; - const uint CAL_SABBREVMONTHNAME1 = 0x00000022; - const uint CAL_SSHORTESTDAYNAME7 = 0x00000037; - const uint CAL_SERASTRING = 0x00000004; - const uint CAL_SABBREVERASTRING = 0x00000039; - const uint CAL_ICALINTVALUE = 0x00000001; - const uint CAL_ITWODIGITYEARMAX = 0x00000030; - - const uint ENUM_ALL_CALENDARS = 0xffffffff; - - const uint LOCALE_SSHORTDATE = 0x0000001F; - const uint LOCALE_SLONGDATE = 0x00000020; - const uint LOCALE_SYEARMONTH = 0x00001006; - const uint LOCALE_ICALENDARTYPE = 0x00001009; + private const uint CAL_RETURN_NUMBER = 0x20000000; + private const uint CAL_RETURN_GENITIVE_NAMES = 0x10000000; + private const uint CAL_NOUSEROVERRIDE = 0x80000000; + private const uint CAL_SCALNAME = 0x00000002; + private const uint CAL_SMONTHDAY = 0x00000038; + private const uint CAL_SSHORTDATE = 0x00000005; + private const uint CAL_SLONGDATE = 0x00000006; + private const uint CAL_SYEARMONTH = 0x0000002f; + private const uint CAL_SDAYNAME7 = 0x0000000d; + private const uint CAL_SABBREVDAYNAME7 = 0x00000014; + private const uint CAL_SMONTHNAME1 = 0x00000015; + private const uint CAL_SABBREVMONTHNAME1 = 0x00000022; + private const uint CAL_SSHORTESTDAYNAME7 = 0x00000037; + private const uint CAL_SERASTRING = 0x00000004; + private const uint CAL_SABBREVERASTRING = 0x00000039; + private const uint CAL_ICALINTVALUE = 0x00000001; + private const uint CAL_ITWODIGITYEARMAX = 0x00000030; + + private const uint ENUM_ALL_CALENDARS = 0xffffffff; + + private const uint LOCALE_SSHORTDATE = 0x0000001F; + private const uint LOCALE_SLONGDATE = 0x00000020; + private const uint LOCALE_SYEARMONTH = 0x00001006; + private const uint LOCALE_ICALENDARTYPE = 0x00001009; //////////////////////////////////////////////////////////////////////// // @@ -272,16 +269,17 @@ namespace System.Globalization } // Context for EnumCalendarInfoExEx callback. - class EnumData + private class EnumData { public string userOverride; public LowLevelList strings; } // EnumCalendarInfoExEx callback itself. - static unsafe bool EnumCalendarInfoCallback(IntPtr lpCalendarInfoString, uint calendar, IntPtr pReserved, Interop.mincore_private.LParamCallbackContext contextHandle) + [NativeCallable(CallingConvention = CallingConvention.StdCall)] + private static unsafe Interop.BOOL EnumCalendarInfoCallback(IntPtr lpCalendarInfoString, uint calendar, IntPtr pReserved, IntPtr lParam) { - EnumData context = (EnumData)((GCHandle)contextHandle.lParam).Target; + EnumData context = (EnumData)((GCHandle)lParam).Target; try { string calendarInfo = new string((char*)lpCalendarInfoString); @@ -290,11 +288,11 @@ namespace System.Globalization if (context.userOverride != calendarInfo) context.strings.Add(calendarInfo); - return true; + return Interop.BOOL.TRUE; } catch (Exception) { - return false; + return Interop.BOOL.FALSE; } } @@ -334,12 +332,9 @@ namespace System.Globalization GCHandle contextHandle = GCHandle.Alloc(context); try { - EnumCalendarInfoExExCallback callback = new EnumCalendarInfoExExCallback(EnumCalendarInfoCallback); - Interop.mincore_private.LParamCallbackContext ctx = new Interop.mincore_private.LParamCallbackContext(); - ctx.lParam = (IntPtr)contextHandle; - // Now call the enumeration API. Work is done by our callback function - Interop.mincore_private.EnumCalendarInfoExEx(callback, localeName, (uint)calendar, null, calType, ctx); + IntPtr callback = AddrofIntrinsics.AddrOf>(EnumCalendarInfoCallback); + Interop.mincore.EnumCalendarInfoExEx(callback, localeName, (uint)calendar, null, calType, (IntPtr)contextHandle); } finally { @@ -379,7 +374,7 @@ namespace System.Globalization // OUT pOutputStrings The output string[] value. // //////////////////////////////////////////////////////////////////////// - static bool GetCalendarDayInfo(string localeName, CalendarId calendar, uint calType, out string[] outputStrings) + private static bool GetCalendarDayInfo(string localeName, CalendarId calendar, uint calType, out string[] outputStrings) { bool result = true; @@ -412,7 +407,7 @@ namespace System.Globalization // OUT pOutputStrings The output string[] value. // //////////////////////////////////////////////////////////////////////// - static bool GetCalendarMonthInfo(string localeName, CalendarId calendar, uint calType, out string[] outputStrings) + private static bool GetCalendarMonthInfo(string localeName, CalendarId calendar, uint calType, out string[] outputStrings) { // // We'll need a new array of 13 items @@ -434,26 +429,27 @@ namespace System.Globalization // // struct to help our calendar data enumaration callback // - class EnumCalendarsData + private class EnumCalendarsData { public int userOverride; // user override value (if found) public LowLevelList calendars; // list of calendars found so far } - static bool EnumCalendarsCallback(IntPtr lpCalendarInfoString, uint calendar, IntPtr reserved, Interop.mincore_private.LParamCallbackContext cxt) + [NativeCallable(CallingConvention = CallingConvention.StdCall)] + private static Interop.BOOL EnumCalendarsCallback(IntPtr lpCalendarInfoString, uint calendar, IntPtr reserved, IntPtr lParam) { - EnumCalendarsData context = (EnumCalendarsData)((GCHandle)cxt.lParam).Target; + EnumCalendarsData context = (EnumCalendarsData)((GCHandle)lParam).Target; try { // If we had a user override, check to make sure this differs if (context.userOverride != calendar) context.calendars.Add((int)calendar); - return true; + return Interop.BOOL.TRUE; } catch (Exception) { - return false; + return Interop.BOOL.FALSE; } } diff --git a/src/mscorlib/corefx/System/Globalization/CalendarData.cs b/src/mscorlib/corefx/System/Globalization/CalendarData.cs index 96c8bd4..3b89b1e 100644 --- a/src/mscorlib/corefx/System/Globalization/CalendarData.cs +++ b/src/mscorlib/corefx/System/Globalization/CalendarData.cs @@ -10,7 +10,6 @@ using System.Collections.Generic; namespace System.Globalization { - // // List of calendar data // Note the we cache overrides. // Note that localized names (resource names) aren't available from here. diff --git a/src/mscorlib/corefx/System/Globalization/CalendricalCalculationsHelper.cs b/src/mscorlib/corefx/System/Globalization/CalendricalCalculationsHelper.cs index 7084511..ba7601b 100644 --- a/src/mscorlib/corefx/System/Globalization/CalendricalCalculationsHelper.cs +++ b/src/mscorlib/corefx/System/Globalization/CalendricalCalculationsHelper.cs @@ -2,56 +2,56 @@ // 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.Diagnostics.Contracts; + namespace System.Globalization { - using System; - using System.Diagnostics.Contracts; - internal class CalendricalCalculationsHelper { - const double FullCircleOfArc = 360.0; // 360.0; - const int HalfCircleOfArc = 180; - const double TwelveHours = 0.5; // half a day - const double Noon2000Jan01 = 730120.5; + private const double FullCircleOfArc = 360.0; // 360.0; + private const int HalfCircleOfArc = 180; + private const double TwelveHours = 0.5; // half a day + private const double Noon2000Jan01 = 730120.5; internal const double MeanTropicalYearInDays = 365.242189; - const double MeanSpeedOfSun = MeanTropicalYearInDays / FullCircleOfArc; - const double LongitudeSpring = 0.0; - const double TwoDegreesAfterSpring = 2.0; - const int SecondsPerDay = 24 * 60 * 60; // 24 hours * 60 minutes * 60 seconds - - const int DaysInUniformLengthCentury = 36525; - const int SecondsPerMinute = 60; - const int MinutesPerDegree = 60; - - static long StartOf1810 = GetNumberOfDays(new DateTime(1810, 1, 1)); - static long StartOf1900Century = GetNumberOfDays(new DateTime(1900, 1, 1)); - - static double[] Coefficients1900to1987 = new double[] { -0.00002, 0.000297, 0.025184, -0.181133, 0.553040, -0.861938, 0.677066, -0.212591 }; - static double[] Coefficients1800to1899 = new double[] { -0.000009, 0.003844, 0.083563, 0.865736, 4.867575, 15.845535, 31.332267, 38.291999, 28.316289, 11.636204, 2.043794 }; - static double[] Coefficients1700to1799 = new double[] { 8.118780842, -0.005092142, 0.003336121, -0.0000266484 }; - static double[] Coefficients1620to1699 = new double[] { 196.58333, -4.0675, 0.0219167 }; - static double[] LambdaCoefficients = new double[] { 280.46645, 36000.76983, 0.0003032 }; - static double[] AnomalyCoefficients = new double[] { 357.52910, 35999.05030, -0.0001559, -0.00000048 }; - static double[] EccentricityCoefficients = new double[] { 0.016708617, -0.000042037, -0.0000001236 }; - static double[] Coefficients = new double[] { Angle(23, 26, 21.448), Angle(0, 0, -46.8150), Angle(0, 0, -0.00059), Angle(0, 0, 0.001813) }; - static double[] CoefficientsA = new double[] { 124.90, -1934.134, 0.002063 }; - static double[] CoefficientsB = new double[] { 201.11, 72001.5377, 0.00057 }; - - static double RadiansFromDegrees(double degree) + private const double MeanSpeedOfSun = MeanTropicalYearInDays / FullCircleOfArc; + private const double LongitudeSpring = 0.0; + private const double TwoDegreesAfterSpring = 2.0; + private const int SecondsPerDay = 24 * 60 * 60; // 24 hours * 60 minutes * 60 seconds + + private const int DaysInUniformLengthCentury = 36525; + private const int SecondsPerMinute = 60; + private const int MinutesPerDegree = 60; + + private static readonly long StartOf1810 = GetNumberOfDays(new DateTime(1810, 1, 1)); + private static readonly long StartOf1900Century = GetNumberOfDays(new DateTime(1900, 1, 1)); + + private static readonly double[] s_coefficients1900to1987 = new double[] { -0.00002, 0.000297, 0.025184, -0.181133, 0.553040, -0.861938, 0.677066, -0.212591 }; + private static readonly double[] s_coefficients1800to1899 = new double[] { -0.000009, 0.003844, 0.083563, 0.865736, 4.867575, 15.845535, 31.332267, 38.291999, 28.316289, 11.636204, 2.043794 }; + private static readonly double[] s_coefficients1700to1799 = new double[] { 8.118780842, -0.005092142, 0.003336121, -0.0000266484 }; + private static readonly double[] s_coefficients1620to1699 = new double[] { 196.58333, -4.0675, 0.0219167 }; + private static readonly double[] s_lambdaCoefficients = new double[] { 280.46645, 36000.76983, 0.0003032 }; + private static readonly double[] s_anomalyCoefficients = new double[] { 357.52910, 35999.05030, -0.0001559, -0.00000048 }; + private static readonly double[] s_eccentricityCoefficients = new double[] { 0.016708617, -0.000042037, -0.0000001236 }; + private static readonly double[] s_coefficients = new double[] { Angle(23, 26, 21.448), Angle(0, 0, -46.8150), Angle(0, 0, -0.00059), Angle(0, 0, 0.001813) }; + private static readonly double[] s_coefficientsA = new double[] { 124.90, -1934.134, 0.002063 }; + private static readonly double[] s_coefficientsB = new double[] { 201.11, 72001.5377, 0.00057 }; + + private static double RadiansFromDegrees(double degree) { return degree * Math.PI / 180; } - static double SinOfDegree(double degree) + private static double SinOfDegree(double degree) { return Math.Sin(RadiansFromDegrees(degree)); } - static double CosOfDegree(double degree) + private static double CosOfDegree(double degree) { return Math.Cos(RadiansFromDegrees(degree)); } - static double TanOfDegree(double degree) + private static double TanOfDegree(double degree) { return Math.Tan(RadiansFromDegrees(degree)); } @@ -61,9 +61,9 @@ namespace System.Globalization return ((seconds / SecondsPerMinute + minutes) / MinutesPerDegree) + degrees; } - static double Obliquity(double julianCenturies) + private static double Obliquity(double julianCenturies) { - return PolynomialSum(Coefficients, julianCenturies); + return PolynomialSum(s_coefficients, julianCenturies); } internal static long GetNumberOfDays(DateTime date) @@ -71,12 +71,12 @@ namespace System.Globalization return date.Ticks / GregorianCalendar.TicksPerDay; } - static int GetGregorianYear(double numberOfDays) + private static int GetGregorianYear(double numberOfDays) { return new DateTime(Math.Min((long)(Math.Floor(numberOfDays) * GregorianCalendar.TicksPerDay), DateTime.MaxValue.Ticks)).Year; } - enum CorrectionAlgorithm + private enum CorrectionAlgorithm { Default, Year1988to2019, @@ -86,7 +86,7 @@ namespace System.Globalization Year1620to1699 } - struct EphemerisCorrectionAlgorithmMap + private struct EphemerisCorrectionAlgorithmMap { public EphemerisCorrectionAlgorithmMap(int year, CorrectionAlgorithm algorithm) { @@ -98,7 +98,7 @@ namespace System.Globalization internal CorrectionAlgorithm _algorithm; }; - static EphemerisCorrectionAlgorithmMap[] EphemerisCorrectionTable = new EphemerisCorrectionAlgorithmMap[] + private static readonly EphemerisCorrectionAlgorithmMap[] s_ephemerisCorrectionTable = new EphemerisCorrectionAlgorithmMap[] { // lowest year that starts algorithm, algorithm to use new EphemerisCorrectionAlgorithmMap(2020, CorrectionAlgorithm.Default), @@ -110,13 +110,13 @@ namespace System.Globalization new EphemerisCorrectionAlgorithmMap(int.MinValue, CorrectionAlgorithm.Default) // default must be last }; - static double Reminder(double divisor, double dividend) + private static double Reminder(double divisor, double dividend) { double whole = Math.Floor(divisor / dividend); return divisor - (dividend * whole); } - static double NormalizeLongitude(double longitude) + private static double NormalizeLongitude(double longitude) { longitude = Reminder(longitude, FullCircleOfArc); if (longitude < 0) @@ -131,11 +131,11 @@ namespace System.Globalization return longitude / FullCircleOfArc; } - static double PolynomialSum(double[] coefficients, double indeterminate) + private static double PolynomialSum(double[] coefficients, double indeterminate) { double sum = coefficients[0]; double indeterminateRaised = 1; - for (int i=1; i= 0 && ch <= 0x10ffff, "ch is not in valid Unicode range."); @@ -268,7 +265,6 @@ 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."); diff --git a/src/mscorlib/corefx/System/Globalization/CharUnicodeInfoData.cs b/src/mscorlib/corefx/System/Globalization/CharUnicodeInfoData.cs index e4fefd8..7284cfd 100644 --- a/src/mscorlib/corefx/System/Globalization/CharUnicodeInfoData.cs +++ b/src/mscorlib/corefx/System/Globalization/CharUnicodeInfoData.cs @@ -8,8 +8,7 @@ namespace System.Globalization { public static partial class CharUnicodeInfo { - // THE FOLLOWING DATA IS AUTO GENERATED BY GenUnicodeProp.pl SCRIPT - // UNDER THE PATH ...\fx\tools\devdiv\Globalization\Tables\Tools\UnicodeProperties + // THE FOLLOWING DATA IS AUTO GENERATED BY GenUnicodeProp.pl SCRIPT UNDER THE TOOLS FOLDER // PLEASE DON'T MODIFY BY HAND diff --git a/src/mscorlib/corefx/System/Globalization/ChineseLunisolarCalendar.cs b/src/mscorlib/corefx/System/Globalization/ChineseLunisolarCalendar.cs index 6fd6d1a..48f6201 100644 --- a/src/mscorlib/corefx/System/Globalization/ChineseLunisolarCalendar.cs +++ b/src/mscorlib/corefx/System/Globalization/ChineseLunisolarCalendar.cs @@ -27,7 +27,6 @@ namespace System.Globalization // public const int ChineseEra = 1; - //internal static Calendar m_defaultInstance; internal const int MIN_LUNISOLAR_YEAR = 1901; internal const int MAX_LUNISOLAR_YEAR = 2100; @@ -72,7 +71,7 @@ namespace System.Globalization } - static readonly int[,] yinfo = + private static readonly int[,] s_yinfo = { /*Y LM Lmon Lday DaysPerMonth D1 D2 D3 D4 D5 D6 D7 D8 D9 D10 D11 D12 D13 #Days 1901 */ @@ -331,7 +330,7 @@ namespace System.Globalization } Contract.EndContractBlock(); - return yinfo[LunarYear - MIN_LUNISOLAR_YEAR, Index]; + return s_yinfo[LunarYear - MIN_LUNISOLAR_YEAR, Index]; } internal override int GetYear(int year, DateTime time) @@ -359,32 +358,10 @@ namespace System.Globalization return year; } - - /*=================================GetDefaultInstance========================== - **Action: Internal method to provide a default intance of ChineseLunisolarCalendar. Used by NLS+ implementation - ** and other calendars. - **Returns: - **Arguments: - **Exceptions: - ============================================================================*/ - - /* - internal static Calendar GetDefaultInstance() - { - if (m_defaultInstance == null) { - m_defaultInstance = new ChineseLunisolarCalendar(); - } - return (m_defaultInstance); - } - */ - - // Construct an instance of ChineseLunisolar calendar. - public ChineseLunisolarCalendar() { } - [System.Runtime.InteropServices.ComVisible(false)] public override int GetEra(DateTime time) { diff --git a/src/mscorlib/corefx/System/Globalization/CompareInfo.Unix.cs b/src/mscorlib/corefx/System/Globalization/CompareInfo.Unix.cs index da394ca..2aaf5a2 100644 --- a/src/mscorlib/corefx/System/Globalization/CompareInfo.Unix.cs +++ b/src/mscorlib/corefx/System/Globalization/CompareInfo.Unix.cs @@ -11,28 +11,26 @@ namespace System.Globalization { public partial class CompareInfo { - [SecurityCritical] [NonSerialized] - private Interop.GlobalizationInterop.SafeSortHandle m_sortHandle; + private Interop.GlobalizationInterop.SafeSortHandle _sortHandle; [NonSerialized] - private bool m_isAsciiEqualityOrdinal; + private bool _isAsciiEqualityOrdinal; [SecuritySafeCritical] internal CompareInfo(CultureInfo culture) { - m_name = culture.m_name; + _name = culture.m_name; InitSort(culture); } private void InitSort(CultureInfo culture) { - m_sortName = culture.SortName; - m_sortHandle = Interop.GlobalizationInterop.GetSortHandle(GetNullTerminatedUtf8String(m_sortName)); - m_isAsciiEqualityOrdinal = (m_sortName == "en-US" || m_sortName == ""); + _sortName = culture.SortName; + _sortHandle = Interop.GlobalizationInterop.GetSortHandle(GetNullTerminatedUtf8String(_sortName)); + _isAsciiEqualityOrdinal = (_sortName == "en-US" || _sortName == ""); } - [SecurityCritical] internal static unsafe int IndexOfOrdinal(string source, string value, int startIndex, int count, bool ignoreCase) { Contract.Assert(source != null); @@ -77,7 +75,6 @@ namespace System.Globalization return -1; } - [SecurityCritical] internal static unsafe int LastIndexOfOrdinal(string source, string value, int startIndex, int count, bool ignoreCase) { Contract.Assert(source != null); @@ -133,13 +130,11 @@ namespace System.Globalization return GetHashCodeOfStringCore(source, options, forceRandomizedHashing: false, additionalEntropy: 0); } - [SecurityCritical] private static unsafe int CompareStringOrdinalIgnoreCase(char* string1, int count1, char* string2, int count2) { return Interop.GlobalizationInterop.CompareStringOrdinalIgnoreCase(string1, count1, string2, count2); } - [SecurityCritical] private unsafe int CompareString(string string1, int offset1, int length1, string string2, int offset2, int length2, CompareOptions options) { Contract.Assert(string1 != null); @@ -150,12 +145,11 @@ namespace System.Globalization { fixed (char* pString2 = string2) { - return Interop.GlobalizationInterop.CompareString(m_sortHandle, pString1 + offset1, length1, pString2 + offset2, length2, options); + return Interop.GlobalizationInterop.CompareString(_sortHandle, pString1 + offset1, length1, pString2 + offset2, length2, options); } } } - [SecurityCritical] private unsafe int IndexOfCore(string source, string target, int startIndex, int count, CompareOptions options) { Contract.Assert(!string.IsNullOrEmpty(source)); @@ -172,20 +166,19 @@ namespace System.Globalization return IndexOfOrdinal(source, target, startIndex, count, ignoreCase: false); } - if (m_isAsciiEqualityOrdinal && CanUseAsciiOrdinalForOptions(options) && source.IsFastSort() && target.IsFastSort()) + if (_isAsciiEqualityOrdinal && CanUseAsciiOrdinalForOptions(options) && source.IsFastSort() && target.IsFastSort()) { return IndexOf(source, target, startIndex, count, GetOrdinalCompareOptions(options)); } fixed (char* pSource = source) { - int index = Interop.GlobalizationInterop.IndexOf(m_sortHandle, target, target.Length, pSource + startIndex, count, options); + int index = Interop.GlobalizationInterop.IndexOf(_sortHandle, target, target.Length, pSource + startIndex, count, options); return index != -1 ? index + startIndex : -1; } } - [SecurityCritical] private unsafe int LastIndexOfCore(string source, string target, int startIndex, int count, CompareOptions options) { Contract.Assert(!string.IsNullOrEmpty(source)); @@ -202,7 +195,7 @@ namespace System.Globalization return LastIndexOfOrdinal(source, target, startIndex, count, ignoreCase: false); } - if (m_isAsciiEqualityOrdinal && CanUseAsciiOrdinalForOptions(options) && source.IsFastSort() && target.IsFastSort()) + if (_isAsciiEqualityOrdinal && CanUseAsciiOrdinalForOptions(options) && source.IsFastSort() && target.IsFastSort()) { return LastIndexOf(source, target, startIndex, count, GetOrdinalCompareOptions(options)); } @@ -213,7 +206,7 @@ namespace System.Globalization fixed (char* pSource = source) { - int lastIndex = Interop.GlobalizationInterop.LastIndexOf(m_sortHandle, target, target.Length, pSource + (startIndex - count + 1), count, options); + int lastIndex = Interop.GlobalizationInterop.LastIndexOf(_sortHandle, target, target.Length, pSource + (startIndex - count + 1), count, options); return lastIndex != -1 ? lastIndex + leftStartIndex : -1; } @@ -226,12 +219,12 @@ namespace System.Globalization Contract.Assert(!string.IsNullOrEmpty(prefix)); Contract.Assert((options & (CompareOptions.Ordinal | CompareOptions.OrdinalIgnoreCase)) == 0); - if (m_isAsciiEqualityOrdinal && CanUseAsciiOrdinalForOptions(options) && source.IsFastSort() && prefix.IsFastSort()) + if (_isAsciiEqualityOrdinal && CanUseAsciiOrdinalForOptions(options) && source.IsFastSort() && prefix.IsFastSort()) { return IsPrefix(source, prefix, GetOrdinalCompareOptions(options)); } - return Interop.GlobalizationInterop.StartsWith(m_sortHandle, prefix, prefix.Length, source, source.Length, options); + return Interop.GlobalizationInterop.StartsWith(_sortHandle, prefix, prefix.Length, source, source.Length, options); } [SecuritySafeCritical] @@ -241,12 +234,12 @@ namespace System.Globalization Contract.Assert(!string.IsNullOrEmpty(suffix)); Contract.Assert((options & (CompareOptions.Ordinal | CompareOptions.OrdinalIgnoreCase)) == 0); - if (m_isAsciiEqualityOrdinal && CanUseAsciiOrdinalForOptions(options) && source.IsFastSort() && suffix.IsFastSort()) + if (_isAsciiEqualityOrdinal && CanUseAsciiOrdinalForOptions(options) && source.IsFastSort() && suffix.IsFastSort()) { return IsSuffix(source, suffix, GetOrdinalCompareOptions(options)); } - return Interop.GlobalizationInterop.EndsWith(m_sortHandle, suffix, suffix.Length, source, source.Length, options); + return Interop.GlobalizationInterop.EndsWith(_sortHandle, suffix, suffix.Length, source, source.Length, options); } // ----------------------------- @@ -264,13 +257,13 @@ namespace System.Globalization return 0; } - int sortKeyLength = Interop.GlobalizationInterop.GetSortKey(m_sortHandle, source, source.Length, null, 0, options); + int sortKeyLength = Interop.GlobalizationInterop.GetSortKey(_sortHandle, source, source.Length, null, 0, options); // As an optimization, for small sort keys we allocate the buffer on the stack. if (sortKeyLength <= 256) { byte* pSortKey = stackalloc byte[sortKeyLength]; - Interop.GlobalizationInterop.GetSortKey(m_sortHandle, source, source.Length, pSortKey, sortKeyLength, options); + Interop.GlobalizationInterop.GetSortKey(_sortHandle, source, source.Length, pSortKey, sortKeyLength, options); return InternalHashSortKey(pSortKey, sortKeyLength, false, additionalEntropy); } @@ -278,12 +271,11 @@ namespace System.Globalization fixed(byte* pSortKey = sortKey) { - Interop.GlobalizationInterop.GetSortKey(m_sortHandle, source, source.Length, pSortKey, sortKeyLength, options); + Interop.GlobalizationInterop.GetSortKey(_sortHandle, source, source.Length, pSortKey, sortKeyLength, options); return InternalHashSortKey(pSortKey, sortKeyLength, false, additionalEntropy); } } - [SecurityCritical] [DllImport(JitHelpers.QCall)] [SuppressUnmanagedCodeSecurity] private static unsafe extern int InternalHashSortKey(byte* sortKey, int sortKeyLength, [MarshalAs(UnmanagedType.Bool)] bool forceRandomizedHashing, long additionalEntropy); diff --git a/src/mscorlib/corefx/System/Globalization/CompareInfo.Windows.cs b/src/mscorlib/corefx/System/Globalization/CompareInfo.Windows.cs index 557d427..d7d0e9c 100644 --- a/src/mscorlib/corefx/System/Globalization/CompareInfo.Windows.cs +++ b/src/mscorlib/corefx/System/Globalization/CompareInfo.Windows.cs @@ -7,22 +7,48 @@ using System.Diagnostics.Contracts; namespace System.Globalization { public partial class CompareInfo - { + { internal unsafe CompareInfo(CultureInfo culture) { - this.m_name = culture.m_name; + _name = culture._name; InitSort(culture); } private void InitSort(CultureInfo culture) { - this.m_sortName = culture.SortName; + _sortName = culture.SortName; const uint LCMAP_SORTHANDLE = 0x20000000; - long handle; - int ret = Interop.mincore.LCMapStringEx(m_sortName, LCMAP_SORTHANDLE, null, 0, (IntPtr)(&handle), IntPtr.Size, IntPtr.Zero, IntPtr.Zero, IntPtr.Zero); - _sortHandle = ret > 0 ? (IntPtr)handle : IntPtr.Zero; + _name = culture._name; + _sortName = culture.SortName; + + IntPtr handle; + int ret = Interop.mincore.LCMapStringEx(_sortName, LCMAP_SORTHANDLE, null, 0, &handle, IntPtr.Size, null, null, IntPtr.Zero); + _sortHandle = ret > 0 ? handle : IntPtr.Zero; + } + + private static unsafe int FindStringOrdinal( + uint dwFindStringOrdinalFlags, + string stringSource, + int offset, + int cchSource, + string value, + int cchValue, + bool bIgnoreCase) + { + fixed (char* pSource = stringSource) + fixed (char* pValue = value) + { + int ret = Interop.mincore.FindStringOrdinal( + dwFindStringOrdinalFlags, + pSource + offset, + cchSource, + pValue, + cchValue, + bIgnoreCase ? 1 : 0); + return ret < 0 ? ret : ret + offset; + } } internal static int IndexOfOrdinal(string source, string value, int startIndex, int count, bool ignoreCase) @@ -30,8 +56,7 @@ namespace System.Globalization Contract.Assert(source != null); Contract.Assert(value != null); - return Interop.mincore.FindStringOrdinal(FIND_FROMSTART, source, startIndex, count, value, value.Length, ignoreCase); - + return FindStringOrdinal(FIND_FROMSTART, source, startIndex, count, value, value.Length, ignoreCase); } internal static int LastIndexOfOrdinal(string source, string value, int startIndex, int count, bool ignoreCase) @@ -39,7 +64,7 @@ namespace System.Globalization Contract.Assert(source != null); Contract.Assert(value != null); - return Interop.mincore.FindStringOrdinal(FIND_FROMEND, source, startIndex - count + 1, count, value, value.Length, ignoreCase); + return FindStringOrdinal(FIND_FROMEND, source, startIndex - count + 1, count, value, value.Length, ignoreCase); } private unsafe int GetHashCodeOfStringCore(string source, CompareOptions options) @@ -53,12 +78,12 @@ namespace System.Globalization } int tmpHash = 0; - - if (Interop.mincore.LCMapStringEx(m_sortName, - LCMAP_HASH | (uint)GetNativeCompareFlags(options), - source, source.Length, - (IntPtr)(&tmpHash), sizeof(int), - IntPtr.Zero, IntPtr.Zero, IntPtr.Zero) == 0) + + if (Interop.mincore.LCMapStringEx(_sortHandle != IntPtr.Zero ? null : _sortName, + LCMAP_HASH | (uint)GetNativeCompareFlags(options), + source, source.Length, + &tmpHash, sizeof(int), + null, null, _sortHandle) == 0) { Environment.FailFast("LCMapStringEx failed!"); } @@ -72,25 +97,69 @@ namespace System.Globalization return Interop.mincore.CompareStringOrdinal(string1, count1, string2, count2, true) - 2; } - private int CompareString(string string1, int offset1, int length1, string string2, int offset2, int length2, CompareOptions options) + private unsafe int CompareString(string string1, int offset1, int length1, string string2, int offset2, int length2, CompareOptions options) { Contract.Assert(string1 != null); Contract.Assert(string2 != null); Contract.Assert((options & (CompareOptions.Ordinal | CompareOptions.OrdinalIgnoreCase)) == 0); - int result = Interop.mincore.CompareStringEx(_sortHandle != IntPtr.Zero ? null : m_sortName, - GetNativeCompareFlags(options), - string1, offset1, length1, - string2, offset2, length2, - _sortHandle); + string localeName = _sortHandle != IntPtr.Zero ? null : _sortName; - if (result == 0) + fixed (char* pLocaleName = localeName) + fixed (char* pString1 = string1) + fixed (char* pString2 = string2) { - Environment.FailFast("CompareStringEx failed"); + int result = Interop.mincore.CompareStringEx( + pLocaleName, + (uint)GetNativeCompareFlags(options), + pString1 + offset1, + length1, + pString2 + offset2, + length2, + null, + null, + _sortHandle); + + if (result == 0) + { + Environment.FailFast("CompareStringEx failed"); + } + + // Map CompareStringEx return value to -1, 0, 1. + return result - 2; } + } + + private unsafe int FindString( + uint dwFindNLSStringFlags, + string lpStringSource, + int startSource, + int cchSource, + string lpStringValue, + int startValue, + int cchValue) + { + string localeName = _sortHandle != IntPtr.Zero ? null : _sortName; - // Map CompareStringEx return value to -1, 0, 1. - return result - 2; + fixed (char* pLocaleName = localeName) + fixed (char* pSource = lpStringSource) + fixed (char* pValue = lpStringValue) + { + char* pS = pSource + startSource; + char* pV = pValue + startValue; + + return Interop.mincore.FindNLSStringEx( + pLocaleName, + dwFindNLSStringFlags, + pS, + cchSource, + pV, + cchValue, + null, + null, + null, + _sortHandle); + } } private int IndexOfCore(string source, string target, int startIndex, int count, CompareOptions options) @@ -108,15 +177,13 @@ namespace System.Globalization } else { - int retValue = Interop.mincore.FindNLSStringEx(_sortHandle != IntPtr.Zero ? null : m_sortName, - FIND_FROMSTART | (uint)GetNativeCompareFlags(options), + int retValue = FindString(FIND_FROMSTART | (uint)GetNativeCompareFlags(options), source, startIndex, count, target, 0, - target.Length, - _sortHandle); + target.Length); if (retValue >= 0) { return retValue + startIndex; @@ -141,15 +208,13 @@ namespace System.Globalization } else { - int retValue = Interop.mincore.FindNLSStringEx(_sortHandle != IntPtr.Zero ? null : m_sortName, - FIND_FROMEND | (uint)GetNativeCompareFlags(options), + int retValue = FindString(FIND_FROMEND | (uint)GetNativeCompareFlags(options), source, startIndex - count + 1, count, target, 0, - target.Length, - _sortHandle); + target.Length); if (retValue >= 0) { @@ -157,7 +222,7 @@ namespace System.Globalization } } - return -1; + return -1; } private bool StartsWith(string source, string prefix, CompareOptions options) @@ -166,15 +231,13 @@ namespace System.Globalization Contract.Assert(!string.IsNullOrEmpty(prefix)); Contract.Assert((options & (CompareOptions.Ordinal | CompareOptions.OrdinalIgnoreCase)) == 0); - return Interop.mincore.FindNLSStringEx(_sortHandle != IntPtr.Zero ? null : m_sortName, - FIND_STARTSWITH | (uint)GetNativeCompareFlags(options), + return FindString(FIND_STARTSWITH | (uint)GetNativeCompareFlags(options), source, 0, source.Length, prefix, 0, - prefix.Length, - _sortHandle) >= 0; + prefix.Length) >= 0; } private bool EndsWith(string source, string suffix, CompareOptions options) @@ -183,16 +246,13 @@ namespace System.Globalization Contract.Assert(!string.IsNullOrEmpty(suffix)); Contract.Assert((options & (CompareOptions.Ordinal | CompareOptions.OrdinalIgnoreCase)) == 0); - return Interop.mincore.FindNLSStringEx(_sortHandle != IntPtr.Zero ? null : m_sortName, - FIND_ENDSWITH | (uint)GetNativeCompareFlags(options), + return FindString(FIND_ENDSWITH | (uint)GetNativeCompareFlags(options), source, 0, source.Length, suffix, 0, - suffix.Length, - _sortHandle) >= 0; - + suffix.Length) >= 0; } // PAL ends here diff --git a/src/mscorlib/corefx/System/Globalization/CompareInfo.cs b/src/mscorlib/corefx/System/Globalization/CompareInfo.cs index 9cfa16b..3f819dd 100644 --- a/src/mscorlib/corefx/System/Globalization/CompareInfo.cs +++ b/src/mscorlib/corefx/System/Globalization/CompareInfo.cs @@ -4,13 +4,11 @@ //////////////////////////////////////////////////////////////////////////// // -// Class: CompareInfo // // // Purpose: This class implements a set of methods for comparing // strings. // -// Date: August 12, 1998 // //////////////////////////////////////////////////////////////////////////// @@ -67,9 +65,9 @@ namespace System.Globalization // locale, which is what SCOMPAREINFO does. [OptionalField(VersionAdded = 2)] - private String m_name; // The name used to construct this CompareInfo + private String _name; // The name used to construct this CompareInfo [NonSerialized] - private String m_sortName; // The name that defines our behavior + private String _sortName; // The name that defines our behavior /*=================================GetCompareInfo========================== **Action: Get the CompareInfo for the specified culture. @@ -94,7 +92,7 @@ namespace System.Globalization [OnDeserializing] private void OnDeserializing(StreamingContext ctx) { - m_name = null; + _name = null; } void IDeserializationCallback.OnDeserialization(Object sender) @@ -110,9 +108,9 @@ namespace System.Globalization private void OnDeserialized() { - if (m_name != null) + if (_name != null) { - InitSort(CultureInfo.GetCultureInfo(m_name)); + InitSort(CultureInfo.GetCultureInfo(_name)); } } @@ -137,13 +135,13 @@ namespace System.Globalization { get { - Contract.Assert(m_name != null, "CompareInfo.Name Expected m_name to be set"); - if (m_name == "zh-CHT" || m_name == "zh-CHS") + Contract.Assert(_name != null, "CompareInfo.Name Expected _name to be set"); + if (_name == "zh-CHT" || _name == "zh-CHS") { - return m_name; + return _name; } - return m_sortName; + return _sortName; } } @@ -163,7 +161,6 @@ namespace System.Globalization return (Compare(string1, string2, CompareOptions.None)); } - [System.Security.SecuritySafeCritical] // auto-generated public unsafe virtual int Compare(String string1, String string2, CompareOptions options) { if (options == CompareOptions.OrdinalIgnoreCase) @@ -237,7 +234,6 @@ namespace System.Globalization } - [System.Security.SecuritySafeCritical] // auto-generated public unsafe virtual int Compare(String string1, int offset1, int length1, String string2, int offset2, int length2, CompareOptions options) { if (options == CompareOptions.OrdinalIgnoreCase) @@ -304,7 +300,6 @@ namespace System.Globalization options); } - [System.Security.SecurityCritical] private static int CompareOrdinal(string string1, int offset1, int length1, string string2, int offset2, int length2) { int result = String.CompareOrdinal(string1, offset1, string2, offset2, @@ -321,7 +316,6 @@ namespace System.Globalization // it assumes the strings are Ascii string till we hit non Ascii character in strA or strB and then we continue the comparison by // calling the OS. // - [System.Security.SecuritySafeCritical] internal static unsafe int CompareOrdinalIgnoreCase(string strA, int indexA, int lengthA, string strB, int indexB, int lengthB) { Contract.Assert(indexA + lengthA <= strA.Length); @@ -377,7 +371,6 @@ namespace System.Globalization // String.Empty, true is returned. // //////////////////////////////////////////////////////////////////////// - [System.Security.SecuritySafeCritical] // auto-generated public unsafe virtual bool IsPrefix(String source, String prefix, CompareOptions options) { if (source == null || prefix == null) @@ -424,7 +417,6 @@ namespace System.Globalization // String.Empty, true is returned. // //////////////////////////////////////////////////////////////////////// - [System.Security.SecuritySafeCritical] // auto-generated public unsafe virtual bool IsSuffix(String source, String suffix, CompareOptions options) { if (source == null || suffix == null) @@ -555,7 +547,6 @@ namespace System.Globalization return IndexOf(source, value, startIndex, count, CompareOptions.None); } - [System.Security.SecuritySafeCritical] // auto-generated public unsafe virtual int IndexOf(String source, char value, int startIndex, int count, CompareOptions options) { // Validate inputs @@ -571,7 +562,6 @@ namespace System.Globalization if (options == CompareOptions.OrdinalIgnoreCase) { - // TODO: NLS Arrowhead: Make this not need a new String() return source.IndexOf(value.ToString(), startIndex, count, StringComparison.OrdinalIgnoreCase); } @@ -584,7 +574,6 @@ namespace System.Globalization } - [System.Security.SecuritySafeCritical] // auto-generated public unsafe virtual int IndexOf(String source, String value, int startIndex, int count, CompareOptions options) { // Validate inputs @@ -716,7 +705,6 @@ namespace System.Globalization } - [System.Security.SecuritySafeCritical] // auto-generated public unsafe virtual int LastIndexOf(String source, char value, int startIndex, int count, CompareOptions options) { // Verify Arguments @@ -753,15 +741,13 @@ namespace System.Globalization if (options == CompareOptions.OrdinalIgnoreCase) { - // TODO: NLS Arrowhead - Make this not need a new String() return source.LastIndexOf(value.ToString(), startIndex, count, StringComparison.OrdinalIgnoreCase); } - return LastIndexOfCore(source, new string(value, 1), startIndex, count, options); + return LastIndexOfCore(source, value.ToString(), startIndex, count, options); } - [System.Security.SecuritySafeCritical] // auto-generated public unsafe virtual int LastIndexOf(String source, String value, int startIndex, int count, CompareOptions options) { // Verify Arguments diff --git a/src/mscorlib/corefx/System/Globalization/CultureData.Unix.cs b/src/mscorlib/corefx/System/Globalization/CultureData.Unix.cs index dcbd4bc..58aae2f 100644 --- a/src/mscorlib/corefx/System/Globalization/CultureData.Unix.cs +++ b/src/mscorlib/corefx/System/Globalization/CultureData.Unix.cs @@ -25,10 +25,10 @@ namespace System.Globalization [SecuritySafeCritical] private unsafe bool InitCultureData() { - Contract.Assert(this.sRealName != null); + Contract.Assert(_sRealName != null); string alternateSortName = string.Empty; - string realNameBuffer = this.sRealName; + string realNameBuffer = _sRealName; // Basic validation if (realNameBuffer.Contains("@")) @@ -50,38 +50,38 @@ namespace System.Globalization } // Get the locale name from ICU - if (!GetLocaleName(realNameBuffer, out this.sWindowsName)) + if (!GetLocaleName(realNameBuffer, out _sWindowsName)) { return false; // fail } // Replace the ICU collation keyword with an _ - index = this.sWindowsName.IndexOf(ICU_COLLATION_KEYWORD, StringComparison.Ordinal); + index = _sWindowsName.IndexOf(ICU_COLLATION_KEYWORD, StringComparison.Ordinal); if (index >= 0) { - this.sName = this.sWindowsName.Substring(0, index) + "_" + alternateSortName; + _sName = _sWindowsName.Substring(0, index) + "_" + alternateSortName; } else { - this.sName = this.sWindowsName; + _sName = _sWindowsName; } - this.sRealName = this.sName; - this.sSpecificCulture = this.sRealName; // we don't attempt to find a non-neutral locale if a neutral is passed in (unlike win32) + _sRealName = _sName; + _sSpecificCulture = _sRealName; // we don't attempt to find a non-neutral locale if a neutral is passed in (unlike win32) - this.iLanguage = this.ILANGUAGE; - if (this.iLanguage == 0) + _iLanguage = this.ILANGUAGE; + if (_iLanguage == 0) { - this.iLanguage = LOCALE_CUSTOM_UNSPECIFIED; + _iLanguage = LOCALE_CUSTOM_UNSPECIFIED; } - this.bNeutral = (this.SISO3166CTRYNAME.Length == 0); + _bNeutral = (this.SISO3166CTRYNAME.Length == 0); // Remove the sort from sName unless custom culture - if (!this.bNeutral) + if (!_bNeutral) { - if (!IsCustomCultureId(this.iLanguage)) + if (!IsCustomCultureId(_iLanguage)) { - this.sName = this.sWindowsName.Substring(0, index); + _sName = _sWindowsName.Substring(0, index); } } return true; @@ -123,8 +123,8 @@ namespace System.Globalization private string GetLocaleInfo(LocaleStringData type) { - Contract.Assert(this.sWindowsName != null, "[CultureData.GetLocaleInfo] Expected this.sWindowsName to be populated already"); - return GetLocaleInfo(this.sWindowsName, type); + Contract.Assert(_sWindowsName != null, "[CultureData.GetLocaleInfo] Expected _sWindowsName to be populated already"); + return GetLocaleInfo(_sWindowsName, type); } // For LOCALE_SPARENT we need the option of using the "real" name (forcing neutral names) instead of the @@ -158,7 +158,7 @@ namespace System.Globalization [SecuritySafeCritical] private int GetLocaleInfo(LocaleNumberData type) { - Contract.Assert(this.sWindowsName != null, "[CultureData.GetLocaleInfo(LocaleNumberData)] Expected this.sWindowsName to be populated already"); + Contract.Assert(_sWindowsName != null, "[CultureData.GetLocaleInfo(LocaleNumberData)] Expected _sWindowsName to be populated already"); switch (type) { @@ -169,7 +169,7 @@ namespace System.Globalization int value = 0; - bool result = Interop.GlobalizationInterop.GetLocaleInfoInt(this.sWindowsName, (uint)type, ref value); + bool result = Interop.GlobalizationInterop.GetLocaleInfoInt(_sWindowsName, (uint)type, ref value); if (!result) { // Failed, just use 0 @@ -182,11 +182,11 @@ namespace System.Globalization [SecuritySafeCritical] private int[] GetLocaleInfo(LocaleGroupingData type) { - Contract.Assert(this.sWindowsName != null, "[CultureData.GetLocaleInfo(LocaleGroupingData)] Expected this.sWindowsName to be populated already"); + Contract.Assert(_sWindowsName != null, "[CultureData.GetLocaleInfo(LocaleGroupingData)] Expected _sWindowsName to be populated already"); int primaryGroupingSize = 0; int secondaryGroupingSize = 0; - bool result = Interop.GlobalizationInterop.GetLocaleInfoGroupingSizes(this.sWindowsName, (uint)type, ref primaryGroupingSize, ref secondaryGroupingSize); + bool result = Interop.GlobalizationInterop.GetLocaleInfoGroupingSizes(_sWindowsName, (uint)type, ref primaryGroupingSize, ref secondaryGroupingSize); if (!result) { Contract.Assert(false, "[CultureData.GetLocaleInfo(LocaleGroupingData type)] failed"); @@ -208,11 +208,11 @@ namespace System.Globalization [SecuritySafeCritical] private string GetTimeFormatString(bool shortFormat) { - Contract.Assert(this.sWindowsName != null, "[CultureData.GetTimeFormatString(bool shortFormat)] Expected this.sWindowsName to be populated already"); + Contract.Assert(_sWindowsName != null, "[CultureData.GetTimeFormatString(bool shortFormat)] Expected _sWindowsName to be populated already"); StringBuilder sb = StringBuilderCache.Acquire(ICU_ULOC_KEYWORD_AND_VALUES_CAPACITY); - bool result = Interop.GlobalizationInterop.GetLocaleTimeFormat(this.sWindowsName, shortFormat, sb, sb.Capacity); + bool result = Interop.GlobalizationInterop.GetLocaleTimeFormat(_sWindowsName, shortFormat, sb, sb.Capacity); if (!result) { // Failed, just use empty string diff --git a/src/mscorlib/corefx/System/Globalization/CultureData.Windows.cs b/src/mscorlib/corefx/System/Globalization/CultureData.Windows.cs index f1f5eab..9969ecb 100644 --- a/src/mscorlib/corefx/System/Globalization/CultureData.Windows.cs +++ b/src/mscorlib/corefx/System/Globalization/CultureData.Windows.cs @@ -1,8 +1,11 @@ +// 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.Collections.Generic; using System.Diagnostics.Contracts; using System.Runtime.InteropServices; using System.Text; - using Internal.Runtime.Augments; namespace System.Globalization @@ -14,7 +17,7 @@ namespace System.Globalization private const uint LOCALE_SISO3166CTRYNAME = 0x0000005A; private const uint TIME_NOSECONDS = 0x00000002; - + /// /// Check with the OS to see if this is a valid culture. /// If so we populate a limited number of fields. If its not valid we return false. @@ -55,9 +58,9 @@ namespace System.Globalization const uint LOCALE_ILANGUAGE = 0x00000001; const uint LOCALE_INEUTRAL = 0x00000071; const uint LOCALE_SNAME = 0x0000005c; - + int result; - string realNameBuffer = this.sRealName; + string realNameBuffer = _sRealName; char* pBuffer = stackalloc char[LOCALE_NAME_MAX_LENGTH]; result = Interop.mincore.GetLocaleInfoEx(realNameBuffer, LOCALE_SNAME, pBuffer, LOCALE_NAME_MAX_LENGTH); @@ -71,8 +74,8 @@ namespace System.Globalization // It worked, note that the name is the locale name, so use that (even for neutrals) // We need to clean up our "real" name, which should look like the windows name right now // so overwrite the input with the cleaned up name - this.sRealName = new String(pBuffer, 0, result - 1); - realNameBuffer = this.sRealName; + _sRealName = new String(pBuffer, 0, result - 1); + realNameBuffer = _sRealName; // Check for neutrality, don't expect to fail // (buffer has our name in it, so we don't have to do the gc. stuff) @@ -84,21 +87,21 @@ namespace System.Globalization } // Remember our neutrality - this.bNeutral = *((uint*)pBuffer) != 0; + _bNeutral = *((uint*)pBuffer) != 0; // Note: Parents will be set dynamically // Start by assuming the windows name'll be the same as the specific name since windows knows // about specifics on all versions. Only for downlevel Neutral locales does this have to change. - this.sWindowsName = realNameBuffer; + _sWindowsName = realNameBuffer; // Neutrals and non-neutrals are slightly different - if (this.bNeutral) + if (_bNeutral) { // Neutral Locale // IETF name looks like neutral name - this.sName = realNameBuffer; + _sName = realNameBuffer; // Specific locale name is whatever ResolveLocaleName (win7+) returns. // (Buffer has our name in it, and we can recycle that because windows resolves it before writing to the buffer) @@ -111,7 +114,7 @@ namespace System.Globalization } // We found a locale name, so use it. // In vista this should look like a sort name (de-DE_phoneb) or a specific culture (en-US) and be in the "pretty" form - this.sSpecificCulture = new String(pBuffer, 0, result - 1); + _sSpecificCulture = new String(pBuffer, 0, result - 1); } else { @@ -121,9 +124,9 @@ namespace System.Globalization // On mac we'll use this as well, even for neutrals. There's no obvious specific // culture to use and this isn't exposed, but behaviorally this is correct on mac. // Note that specifics include the sort name (de-DE_phoneb) - this.sSpecificCulture = realNameBuffer; + _sSpecificCulture = realNameBuffer; - this.sName = realNameBuffer; + _sName = realNameBuffer; // We need the IETF name (sname) // If we aren't an alt sort locale then this is the same as the windows name. @@ -136,15 +139,15 @@ namespace System.Globalization return false; } - this.iLanguage = *((int*)pBuffer); + _iLanguage = *((int*)pBuffer); - if (!IsCustomCultureId(this.iLanguage)) + if (!IsCustomCultureId(_iLanguage)) { // not custom locale int index = realNameBuffer.IndexOf('_'); if (index > 0 && index < realNameBuffer.Length) { - this.sName = realNameBuffer.Substring(0, index); + _sName = realNameBuffer.Substring(0, index); } } } @@ -153,16 +156,14 @@ namespace System.Globalization return true; } - [System.Security.SecurityCritical] private string GetLocaleInfo(LocaleStringData type) { - Contract.Assert(this.sWindowsName != null, "[CultureData.DoGetLocaleInfo] Expected this.sWindowsName to be populated by already"); - return GetLocaleInfo(this.sWindowsName, type); + Contract.Assert(_sWindowsName != null, "[CultureData.DoGetLocaleInfo] Expected _sWindowsName to be populated by already"); + return GetLocaleInfo(_sWindowsName, type); } // For LOCALE_SPARENT we need the option of using the "real" name (forcing neutral names) instead of the // "windows" name, which can be specific for downlevel (< windows 7) os's. - [System.Security.SecurityCritical] private string GetLocaleInfo(string localeName, LocaleStringData type) { uint lctype = (uint)type; @@ -182,30 +183,31 @@ namespace System.Globalization // Ask OS for data, note that we presume it returns success, so we have to know that // sWindowsName is valid before calling. - Contract.Assert(this.sWindowsName != null, "[CultureData.DoGetLocaleInfoInt] Expected this.sWindowsName to be populated by already"); - int result = Interop.mincore.GetLocaleInfoExInt(this.sWindowsName, lctype); + Contract.Assert(_sWindowsName != null, "[CultureData.DoGetLocaleInfoInt] Expected _sWindowsName to be populated by already"); + int result = Interop.mincore.GetLocaleInfoExInt(_sWindowsName, lctype); return result; } private int[] GetLocaleInfo(LocaleGroupingData type) { - return ConvertWin32GroupString(GetLocaleInfoFromLCType(this.sWindowsName, (uint)type, UseUserOverride)); + return ConvertWin32GroupString(GetLocaleInfoFromLCType(_sWindowsName, (uint)type, UseUserOverride)); } private string GetTimeFormatString() { const uint LOCALE_STIMEFORMAT = 0x00001003; - return ReescapeWin32String(GetLocaleInfoFromLCType(this.sWindowsName, LOCALE_STIMEFORMAT, UseUserOverride)); + return ReescapeWin32String(GetLocaleInfoFromLCType(_sWindowsName, LOCALE_STIMEFORMAT, UseUserOverride)); } private int GetFirstDayOfWeek() { - Contract.Assert(this.sWindowsName != null, "[CultureData.DoGetLocaleInfoInt] Expected this.sWindowsName to be populated by already"); + Contract.Assert(_sWindowsName != null, "[CultureData.DoGetLocaleInfoInt] Expected _sWindowsName to be populated by already"); - int result = Interop.mincore.GetLocaleInfoExInt(this.sWindowsName, - LocaleNumberData.FirstDayOfWeek | (!UseUserOverride ? LOCALE_NOUSEROVERRIDE : 0)); + const uint LOCALE_IFIRSTDAYOFWEEK = 0x0000100C; + + int result = Interop.mincore.GetLocaleInfoExInt(_sWindowsName, LOCALE_IFIRSTDAYOFWEEK | (!UseUserOverride ? LOCALE_NOUSEROVERRIDE : 0)); // Win32 and .NET disagree on the numbering for days of the week, so we have to convert. return ConvertFirstDayOfWeekMonToSun(result); @@ -214,8 +216,8 @@ namespace System.Globalization private String[] GetTimeFormats() { // Note that this gets overrides for us all the time - Contract.Assert(this.sWindowsName != null, "[CultureData.DoEnumTimeFormats] Expected this.sWindowsName to be populated by already"); - String[] result = ReescapeWin32Strings(nativeEnumTimeFormats(this.sWindowsName, 0, UseUserOverride)); + Contract.Assert(_sWindowsName != null, "[CultureData.DoEnumTimeFormats] Expected _sWindowsName to be populated by already"); + String[] result = ReescapeWin32Strings(nativeEnumTimeFormats(_sWindowsName, 0, UseUserOverride)); return result; } @@ -223,8 +225,8 @@ namespace System.Globalization private String[] GetShortTimeFormats() { // Note that this gets overrides for us all the time - Contract.Assert(this.sWindowsName != null, "[CultureData.DoEnumShortTimeFormats] Expected this.sWindowsName to be populated by already"); - String[] result = ReescapeWin32Strings(nativeEnumTimeFormats(this.sWindowsName, TIME_NOSECONDS, UseUserOverride)); + Contract.Assert(_sWindowsName != null, "[CultureData.DoEnumShortTimeFormats] Expected _sWindowsName to be populated by already"); + String[] result = ReescapeWin32Strings(nativeEnumTimeFormats(_sWindowsName, TIME_NOSECONDS, UseUserOverride)); return result; } @@ -234,7 +236,7 @@ namespace System.Globalization private static CultureData GetCultureDataFromRegionName(String regionName) { Contract.Assert(regionName != null); - + const uint LOCALE_SUPPLEMENTAL = 0x00000002; const uint LOCALE_SPECIFICDATA = 0x00000020; @@ -245,11 +247,8 @@ namespace System.Globalization GCHandle contextHandle = GCHandle.Alloc(context); try { - EnumLocalesProcEx callback = new EnumLocalesProcEx(EnumSystemLocalesProc); - Interop.mincore_private.LParamCallbackContext ctx = new Interop.mincore_private.LParamCallbackContext(); - ctx.lParam = (IntPtr)contextHandle; - - Interop.mincore_obsolete.EnumSystemLocalesEx(callback, LOCALE_SPECIFICDATA | LOCALE_SUPPLEMENTAL, ctx, IntPtr.Zero); + IntPtr callback = AddrofIntrinsics.AddrOf>(EnumSystemLocalesProc); + Interop.mincore.EnumSystemLocalesEx(callback, LOCALE_SPECIFICDATA | LOCALE_SUPPLEMENTAL, (IntPtr)contextHandle, IntPtr.Zero); } finally { @@ -277,12 +276,11 @@ namespace System.Globalization private static CultureInfo GetUserDefaultCulture() { - return (CultureInfo)WinRTInterop.Callbacks.GetUserDefaultCulture(); + return (CultureInfo)WinRTInterop.Callbacks.GetUserDefaultCulture(); } // PAL methods end here. - [System.Security.SecurityCritical] private static string GetLocaleInfoFromLCType(string localeName, uint lctype, bool useUserOveride) { Contract.Assert(localeName != null, "[CultureData.GetLocaleInfoFromLCType] Expected localeName to be not be null"); @@ -456,16 +454,17 @@ namespace System.Globalization // Context for EnumCalendarInfoExEx callback. - class EnumLocaleData + private class EnumLocaleData { public string regionName; public string cultureName; } // EnumSystemLocaleEx callback. - static unsafe bool EnumSystemLocalesProc(IntPtr lpLocaleString, uint flags, Interop.mincore_private.LParamCallbackContext contextHandle) + [NativeCallable(CallingConvention = CallingConvention.StdCall)] + private static unsafe Interop.BOOL EnumSystemLocalesProc(IntPtr lpLocaleString, uint flags, IntPtr contextHandle) { - EnumLocaleData context = (EnumLocaleData)((GCHandle)contextHandle.lParam).Target; + EnumLocaleData context = (EnumLocaleData)((GCHandle)contextHandle).Target; try { string cultureName = new string((char*)lpLocaleString); @@ -473,36 +472,37 @@ namespace System.Globalization if (regionName != null && regionName.Equals(context.regionName, StringComparison.OrdinalIgnoreCase)) { context.cultureName = cultureName; - return false; // we found a match, then stop the enumeration + return Interop.BOOL.FALSE; // we found a match, then stop the enumeration } - return true; + return Interop.BOOL.TRUE; } catch (Exception) { - return false; + return Interop.BOOL.FALSE; } } // Context for EnumTimeFormatsEx callback. - class EnumData + private class EnumData { public LowLevelList strings; } // EnumTimeFormatsEx callback itself. - private static unsafe bool EnumTimeCallback(IntPtr lpTimeFormatString, Interop.mincore_private.LParamCallbackContext contextHandle) + [NativeCallable(CallingConvention = CallingConvention.StdCall)] + private static unsafe Interop.BOOL EnumTimeCallback(IntPtr lpTimeFormatString, IntPtr lParam) { - EnumData context = (EnumData)((GCHandle)contextHandle.lParam).Target; + EnumData context = (EnumData)((GCHandle)lParam).Target; try { context.strings.Add(new string((char*)lpTimeFormatString)); - return true; + return Interop.BOOL.TRUE; } catch (Exception) { - return false; + return Interop.BOOL.FALSE; } } @@ -515,15 +515,11 @@ namespace System.Globalization data.strings = new LowLevelList(); GCHandle dataHandle = GCHandle.Alloc(data); - try { - EnumTimeFormatsProcEx callback = new EnumTimeFormatsProcEx(EnumTimeCallback); - Interop.mincore_private.LParamCallbackContext cxt = new Interop.mincore_private.LParamCallbackContext(); - cxt.lParam = (IntPtr)dataHandle; - // Now call the enumeration API. Work is done by our callback function - Interop.mincore_private.EnumTimeFormatsEx(callback, localeName, (uint)dwFlags, cxt); + IntPtr callback = AddrofIntrinsics.AddrOf>(EnumTimeCallback); + Interop.mincore.EnumTimeFormatsEx(callback, localeName, (uint)dwFlags, (IntPtr)dataHandle); } finally { @@ -561,7 +557,5 @@ namespace System.Globalization return null; } - - } -} \ No newline at end of file +} diff --git a/src/mscorlib/corefx/System/Globalization/CultureData.cs b/src/mscorlib/corefx/System/Globalization/CultureData.cs index ee2d95c..eb71318 100644 --- a/src/mscorlib/corefx/System/Globalization/CultureData.cs +++ b/src/mscorlib/corefx/System/Globalization/CultureData.cs @@ -1,4 +1,4 @@ -// Licensed to the .NET Foundation under one or more agreements. +// 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. @@ -56,88 +56,88 @@ namespace System.Globalization // internal partial class CultureData { - const int undef = -1; - const int LOCALE_CUSTOM_UNSPECIFIED = 0x1000; - const int LOCALE_CUSTOM_DEFAULT = 0x0c00; + private const int undef = -1; + private const int LOCALE_CUSTOM_UNSPECIFIED = 0x1000; + private const int LOCALE_CUSTOM_DEFAULT = 0x0c00; // Override flag - private String sRealName; // Name you passed in (ie: en-US, en, or de-DE_phoneb) - private String sWindowsName; // Name OS thinks the object is (ie: de-DE_phoneb, or en-US (even if en was passed in)) + private String _sRealName; // Name you passed in (ie: en-US, en, or de-DE_phoneb) + private String _sWindowsName; // Name OS thinks the object is (ie: de-DE_phoneb, or en-US (even if en was passed in)) // Identity - private String sName; // locale name (ie: en-us, NO sort info, but could be neutral) - private String sParent; // Parent name (which may be a custom locale/culture) - private String sLocalizedDisplayName; // Localized pretty name for this locale - private String sEnglishDisplayName; // English pretty name for this locale - private String sNativeDisplayName; // Native pretty name for this locale - private String sSpecificCulture; // The culture name to be used in CultureInfo.CreateSpecificCulture(), en-US form if neutral, sort name if sort + private String _sName; // locale name (ie: en-us, NO sort info, but could be neutral) + private String _sParent; // Parent name (which may be a custom locale/culture) + private String _sLocalizedDisplayName; // Localized pretty name for this locale + private String _sEnglishDisplayName; // English pretty name for this locale + private String _sNativeDisplayName; // Native pretty name for this locale + private String _sSpecificCulture; // The culture name to be used in CultureInfo.CreateSpecificCulture(), en-US form if neutral, sort name if sort // Language - private String sISO639Language; // ISO 639 Language Name - private String sLocalizedLanguage; // Localized name for this language - private String sEnglishLanguage; // English name for this language - private String sNativeLanguage; // Native name of this language + private String _sISO639Language; // ISO 639 Language Name + private String _sLocalizedLanguage; // Localized name for this language + private String _sEnglishLanguage; // English name for this language + private String _sNativeLanguage; // Native name of this language // Region - private String sRegionName; // (RegionInfo) - private String sLocalizedCountry; // localized country name - private String sEnglishCountry; // english country name (RegionInfo) - private String sNativeCountry; // native country name - private String sISO3166CountryName; // ISO 3166 (RegionInfo), ie: US + private String _sRegionName; // (RegionInfo) + private String _sLocalizedCountry; // localized country name + private String _sEnglishCountry; // english country name (RegionInfo) + private String _sNativeCountry; // native country name + private String _sISO3166CountryName; // ISO 3166 (RegionInfo), ie: US // Numbers - private String sPositiveSign; // (user can override) positive sign - private String sNegativeSign; // (user can override) negative sign - private String[] saNativeDigits; // (user can override) native characters for digits 0-9 + private String _sPositiveSign; // (user can override) positive sign + private String _sNegativeSign; // (user can override) negative sign + private String[] _saNativeDigits; // (user can override) native characters for digits 0-9 // (nfi populates these 5, don't have to be = undef) - private int iDigits; // (user can override) number of fractional digits - private int iNegativeNumber; // (user can override) negative number format - private int[] waGrouping; // (user can override) grouping of digits - private String sDecimalSeparator; // (user can override) decimal separator - private String sThousandSeparator; // (user can override) thousands separator - private String sNaN; // Not a Number - private String sPositiveInfinity; // + Infinity - private String sNegativeInfinity; // - Infinity + private int _iDigits; // (user can override) number of fractional digits + private int _iNegativeNumber; // (user can override) negative number format + private int[] _waGrouping; // (user can override) grouping of digits + private String _sDecimalSeparator; // (user can override) decimal separator + private String _sThousandSeparator; // (user can override) thousands separator + private String _sNaN; // Not a Number + private String _sPositiveInfinity; // + Infinity + private String _sNegativeInfinity; // - Infinity // Percent - private int iNegativePercent = undef; // Negative Percent (0-3) - private int iPositivePercent = undef; // Positive Percent (0-11) - private String sPercent; // Percent (%) symbol - private String sPerMille; // PerMille (‰) symbol + private int _iNegativePercent = undef; // Negative Percent (0-3) + private int _iPositivePercent = undef; // Positive Percent (0-11) + private String _sPercent; // Percent (%) symbol + private String _sPerMille; // PerMille symbol // Currency - private String sCurrency; // (user can override) local monetary symbol - private String sIntlMonetarySymbol; // international monetary symbol (RegionInfo) + private String _sCurrency; // (user can override) local monetary symbol + private String _sIntlMonetarySymbol; // international monetary symbol (RegionInfo) // (nfi populates these 4, don't have to be = undef) - private int iCurrencyDigits; // (user can override) # local monetary fractional digits - private int iCurrency; // (user can override) positive currency format - private int iNegativeCurrency; // (user can override) negative currency format - private int[] waMonetaryGrouping; // (user can override) monetary grouping of digits - private String sMonetaryDecimal; // (user can override) monetary decimal separator - private String sMonetaryThousand; // (user can override) monetary thousands separator + private int _iCurrencyDigits; // (user can override) # local monetary fractional digits + private int _iCurrency; // (user can override) positive currency format + private int _iNegativeCurrency; // (user can override) negative currency format + private int[] _waMonetaryGrouping; // (user can override) monetary grouping of digits + private String _sMonetaryDecimal; // (user can override) monetary decimal separator + private String _sMonetaryThousand; // (user can override) monetary thousands separator // Misc - private int iMeasure = undef; // (user can override) system of measurement 0=metric, 1=US (RegionInfo) - private String sListSeparator; // (user can override) list separator + private int _iMeasure = undef; // (user can override) system of measurement 0=metric, 1=US (RegionInfo) + private String _sListSeparator; // (user can override) list separator // Time - private String sAM1159; // (user can override) AM designator - private String sPM2359; // (user can override) PM designator - private String sTimeSeparator; - private volatile String[] saLongTimes; // (user can override) time format - private volatile String[] saShortTimes; // short time format - private volatile String[] saDurationFormats; // time duration format + private String _sAM1159; // (user can override) AM designator + private String _sPM2359; // (user can override) PM designator + private String _sTimeSeparator; + private volatile String[] _saLongTimes; // (user can override) time format + private volatile String[] _saShortTimes; // short time format + private volatile String[] _saDurationFormats; // time duration format // Calendar specific data - private int iFirstDayOfWeek = undef; // (user can override) first day of week (gregorian really) - private int iFirstWeekOfYear = undef; // (user can override) first week of year (gregorian really) - private volatile CalendarId[] waCalendars; // all available calendar type(s). The first one is the default calendar + private int _iFirstDayOfWeek = undef; // (user can override) first day of week (gregorian really) + private int _iFirstWeekOfYear = undef; // (user can override) first week of year (gregorian really) + private volatile CalendarId[] _waCalendars; // all available calendar type(s). The first one is the default calendar // Store for specific data about each calendar - private CalendarData[] calendars; // Store for specific calendar data + private CalendarData[] _calendars; // Store for specific calendar data // Text information - private int iReadingLayout = undef; // Reading layout data + private int _iReadingLayout = undef; // Reading layout data // 0 - Left to right (eg en-US) // 1 - Right to left (eg arabic locales) // 2 - Vertical top to bottom with columns to the left and also left to right (ja-JP locales) @@ -145,9 +145,9 @@ namespace System.Globalization // CoreCLR depends on this even though its not exposed publicly. - private int iLanguage; // locale ID (0409) - NO sort information - private bool bUseOverrides; // use user overrides? - private bool bNeutral; // Flags for the culture (ie: neutral or not right now) + private int _iLanguage; // locale ID (0409) - NO sort information + private bool _bUseOverrides; // use user overrides? + private bool _bNeutral; // Flags for the culture (ie: neutral or not right now) // Region Name to Culture Name mapping table @@ -302,7 +302,6 @@ namespace System.Globalization private static volatile StringCultureDataDictionary s_cachedRegions; private static volatile StringStringDictionary s_RegionNames; - [System.Security.SecurityCritical] // auto-generated internal static CultureData GetCultureDataForRegion(String cultureName, bool useUserOverride) { // First do a shortcut for Invariant @@ -336,7 +335,7 @@ namespace System.Globalization else { // Check the hash table - lock (m_lock) + lock (s_lock) { tempHashTable.TryGetValue(hashName, out retVal); } @@ -372,7 +371,7 @@ namespace System.Globalization if (retVal != null && (retVal.IsNeutralCulture == false)) { // first add it to the cache - lock (m_lock) + lock (s_lock) { tempHashTable[hashName] = retVal; } @@ -409,85 +408,86 @@ namespace System.Globalization // Basics // Note that we override the resources since this IS NOT supposed to change (by definition) - invariant.bUseOverrides = false; - invariant.sRealName = ""; // Name you passed in (ie: en-US, en, or de-DE_phoneb) - invariant.sWindowsName = ""; // Name OS thinks the object is (ie: de-DE_phoneb, or en-US (even if en was passed in)) + invariant._bUseOverrides = false; + invariant._sRealName = ""; // Name you passed in (ie: en-US, en, or de-DE_phoneb) + invariant._sWindowsName = ""; // Name OS thinks the object is (ie: de-DE_phoneb, or en-US (even if en was passed in)) // Identity - invariant.sName = ""; // locale name (ie: en-us) - invariant.sParent = ""; // Parent name (which may be a custom locale/culture) - invariant.bNeutral = false; // Flags for the culture (ie: neutral or not right now) - invariant.sEnglishDisplayName = "Invariant Language (Invariant Country)"; // English pretty name for this locale - invariant.sNativeDisplayName = "Invariant Language (Invariant Country)"; // Native pretty name for this locale - invariant.sSpecificCulture = ""; // The culture name to be used in CultureInfo.CreateSpecificCulture() + invariant._sName = ""; // locale name (ie: en-us) + invariant._sParent = ""; // Parent name (which may be a custom locale/culture) + invariant._bNeutral = false; // Flags for the culture (ie: neutral or not right now) + invariant._sEnglishDisplayName = "Invariant Language (Invariant Country)"; // English pretty name for this locale + invariant._sNativeDisplayName = "Invariant Language (Invariant Country)"; // Native pretty name for this locale + invariant._sSpecificCulture = ""; // The culture name to be used in CultureInfo.CreateSpecificCulture() // Language - invariant.sISO639Language = "iv"; // ISO 639 Language Name - invariant.sLocalizedLanguage = "Invariant Language"; // Display name for this Language - invariant.sEnglishLanguage = "Invariant Language"; // English name for this language - invariant.sNativeLanguage = "Invariant Language"; // Native name of this language + invariant._sISO639Language = "iv"; // ISO 639 Language Name + invariant._sLocalizedLanguage = "Invariant Language"; // Display name for this Language + invariant._sEnglishLanguage = "Invariant Language"; // English name for this language + invariant._sNativeLanguage = "Invariant Language"; // Native name of this language // Region - invariant.sRegionName = "IV"; // (RegionInfo) - invariant.sEnglishCountry = "Invariant Country"; // english country name (RegionInfo) - invariant.sNativeCountry = "Invariant Country"; // native country name (Windows Only) - invariant.sISO3166CountryName = "IV"; // (RegionInfo), ie: US + invariant._sRegionName = "IV"; // (RegionInfo) + invariant._sEnglishCountry = "Invariant Country"; // english country name (RegionInfo) + invariant._sNativeCountry = "Invariant Country"; // native country name (Windows Only) + invariant._sISO3166CountryName = "IV"; // (RegionInfo), ie: US // Numbers - invariant.sPositiveSign = "+"; // positive sign - invariant.sNegativeSign = "-"; // negative sign - invariant.saNativeDigits = new String[] { "0", "1", "2", "3", "4", "5", "6", "7", "8", "9" }; // native characters for digits 0-9 - invariant.iDigits = 2; // number of fractional digits - invariant.iNegativeNumber = 1; // negative number format - invariant.waGrouping = new int[] { 3 }; // grouping of digits - invariant.sDecimalSeparator = "."; // decimal separator - invariant.sThousandSeparator = ","; // thousands separator - invariant.sNaN = "NaN"; // Not a Number - invariant.sPositiveInfinity = "Infinity"; // + Infinity - invariant.sNegativeInfinity = "-Infinity"; // - Infinity + invariant._sPositiveSign = "+"; // positive sign + invariant._sNegativeSign = "-"; // negative sign + invariant._saNativeDigits = new String[] { "0", "1", "2", "3", "4", "5", "6", "7", "8", "9" }; // native characters for digits 0-9 + invariant._iDigits = 2; // number of fractional digits + invariant._iNegativeNumber = 1; // negative number format + invariant._waGrouping = new int[] { 3 }; // grouping of digits + invariant._sDecimalSeparator = "."; // decimal separator + invariant._sThousandSeparator = ","; // thousands separator + invariant._sNaN = "NaN"; // Not a Number + invariant._sPositiveInfinity = "Infinity"; // + Infinity + invariant._sNegativeInfinity = "-Infinity"; // - Infinity // Percent - invariant.iNegativePercent = 0; // Negative Percent (0-3) - invariant.iPositivePercent = 0; // Positive Percent (0-11) - invariant.sPercent = "%"; // Percent (%) symbol - invariant.sPerMille = "\x2030"; // PerMille(‰) symbol + invariant._iNegativePercent = 0; // Negative Percent (0-3) + invariant._iPositivePercent = 0; // Positive Percent (0-11) + invariant._sPercent = "%"; // Percent (%) symbol + invariant._sPerMille = "\x2030"; // PerMille symbol // Currency - invariant.sCurrency = "\x00a4"; // local monetary symbol "¤: for international monetary symbol - invariant.sIntlMonetarySymbol = "XDR"; // international monetary symbol (RegionInfo) - invariant.iCurrencyDigits = 2; // # local monetary fractional digits - invariant.iCurrency = 0; // positive currency format - invariant.iNegativeCurrency = 0; // negative currency format - invariant.waMonetaryGrouping = new int[] { 3 }; // monetary grouping of digits - invariant.sMonetaryDecimal = "."; // monetary decimal separator - invariant.sMonetaryThousand = ","; // monetary thousands separator + invariant._sCurrency = "\x00a4"; // local monetary symbol: for international monetary symbol + invariant._sIntlMonetarySymbol = "XDR"; // international monetary symbol (RegionInfo) + invariant._iCurrencyDigits = 2; // # local monetary fractional digits + invariant._iCurrency = 0; // positive currency format + invariant._iNegativeCurrency = 0; // negative currency format + invariant._waMonetaryGrouping = new int[] { 3 }; // monetary grouping of digits + invariant._sMonetaryDecimal = "."; // monetary decimal separator + invariant._sMonetaryThousand = ","; // monetary thousands separator // Misc - invariant.iMeasure = 0; // system of measurement 0=metric, 1=US (RegionInfo) - invariant.sListSeparator = ","; // list separator + invariant._iMeasure = 0; // system of measurement 0=metric, 1=US (RegionInfo) + invariant._sListSeparator = ","; // list separator // Time - invariant.sAM1159 = "AM"; // AM designator - invariant.sPM2359 = "PM"; // PM designator - invariant.saLongTimes = new String[] { "HH:mm:ss" }; // time format - invariant.saShortTimes = new String[] { "HH:mm", "hh:mm tt", "H:mm", "h:mm tt" }; // short time format - invariant.saDurationFormats = new String[] { "HH:mm:ss" }; // time duration format + invariant._sAM1159 = "AM"; // AM designator + invariant._sPM2359 = "PM"; // PM designator + invariant._saLongTimes = new String[] { "HH:mm:ss" }; // time format + invariant._saShortTimes = new String[] { "HH:mm", "hh:mm tt", "H:mm", "h:mm tt" }; // short time format + invariant._saDurationFormats = new String[] { "HH:mm:ss" }; // time duration format + // Calendar specific data - invariant.iFirstDayOfWeek = 0; // first day of week - invariant.iFirstWeekOfYear = 0; // first week of year - invariant.waCalendars = new CalendarId[] { CalendarId.GREGORIAN }; // all available calendar type(s). The first one is the default calendar + invariant._iFirstDayOfWeek = 0; // first day of week + invariant._iFirstWeekOfYear = 0; // first week of year + invariant._waCalendars = new CalendarId[] { CalendarId.GREGORIAN }; // all available calendar type(s). The first one is the default calendar // Store for specific data about each calendar - invariant.calendars = new CalendarData[CalendarData.MAX_CALENDARS]; - invariant.calendars[0] = CalendarData.Invariant; + invariant._calendars = new CalendarData[CalendarData.MAX_CALENDARS]; + invariant._calendars[0] = CalendarData.Invariant; // Text information - invariant.iReadingLayout = 0; + invariant._iReadingLayout = 0; - // Language - invariant.iLanguage = 0x007f; // locale ID (0409) - NO sort information + // These are desktop only, not coreclr + invariant._iLanguage = 0x007f; // locale ID (0409) - NO sort information // Remember it s_Invariant = invariant; } @@ -501,7 +501,7 @@ namespace System.Globalization /////////////// // Cache of cultures we've already looked up private static volatile StringCultureDataDictionary s_cachedCultures; - private static readonly Lock m_lock = new Lock(); + private static readonly Lock s_lock = new Lock(); internal static CultureData GetCultureData(String cultureName, bool useUserOverride) { @@ -524,7 +524,7 @@ namespace System.Globalization // Check the hash table bool ret; CultureData retVal; - lock (m_lock) + lock (s_lock) { ret = tempHashTable.TryGetValue(hashName, out retVal); } @@ -542,7 +542,7 @@ namespace System.Globalization } // Found one, add it to the cache - lock (m_lock) + lock (s_lock) { tempHashTable[hashName] = culture; } @@ -557,8 +557,8 @@ namespace System.Globalization private static CultureData CreateCultureData(string cultureName, bool useUserOverride) { CultureData culture = new CultureData(); - culture.bUseOverrides = useUserOverride; - culture.sRealName = cultureName; + culture._bUseOverrides = useUserOverride; + culture._sRealName = cultureName; // Ask native code if that one's real if (culture.InitCultureData() == false) @@ -575,7 +575,7 @@ namespace System.Globalization private bool InitCompatibilityCultureData() { // for compatibility handle the deprecated ids: zh-chs, zh-cht - string cultureName = this.sRealName; + string cultureName = _sRealName; string fallbackCultureName; string realCultureName; @@ -593,14 +593,14 @@ namespace System.Globalization return false; } - this.sRealName = fallbackCultureName; + _sRealName = fallbackCultureName; if (InitCultureData() == false) { return false; } // fixup our data - this.sName = realCultureName; // the name that goes back to the user - this.sParent = fallbackCultureName; + _sName = realCultureName; // the name that goes back to the user + _sParent = fallbackCultureName; return true; } @@ -622,17 +622,17 @@ namespace System.Globalization { get { - Contract.Assert(this.sRealName != null, "[CultureData.CultureName] Expected this.sRealName to be populated by already"); + Contract.Assert(_sRealName != null, "[CultureData.CultureName] Expected _sRealName to be populated by already"); // since windows doesn't know about zh-CHS and zh-CHT, // we leave sRealName == zh-Hanx but we still need to // pretend that it was zh-CHX. - switch (this.sName) + switch (_sName) { case "zh-CHS": case "zh-CHT": - return this.sName; + return _sName; } - return this.sRealName; + return _sRealName; } } @@ -641,7 +641,7 @@ namespace System.Globalization { get { - return this.bUseOverrides; + return _bUseOverrides; } } @@ -650,11 +650,11 @@ namespace System.Globalization { get { - if (this.sName == null) + if (_sName == null) { - this.sName = String.Empty; + _sName = String.Empty; } - return this.sName; + return _sName; } } @@ -663,32 +663,31 @@ namespace System.Globalization { get { - if (this.sParent == null) + if (_sParent == null) { // Ask using the real name, so that we get parents of neutrals - this.sParent = GetLocaleInfo(this.sRealName, LocaleStringData.ParentName); + _sParent = GetLocaleInfo(_sRealName, LocaleStringData.ParentName); } - return this.sParent; + return _sParent; } } // Localized pretty name for this locale (ie: Inglis (estados Unitos)) internal String SLOCALIZEDDISPLAYNAME { - [System.Security.SecurityCritical] // auto-generated get { - if (this.sLocalizedDisplayName == null) + if (_sLocalizedDisplayName == null) { if (this.IsSupplementalCustomCulture) { if (this.IsNeutralCulture) { - this.sLocalizedDisplayName = this.SNATIVELANGUAGE; + _sLocalizedDisplayName = this.SNATIVELANGUAGE; } else { - this.sLocalizedDisplayName = this.SNATIVEDISPLAYNAME; + _sLocalizedDisplayName = this.SNATIVEDISPLAYNAME; } } else @@ -700,15 +699,15 @@ namespace System.Globalization if (SNAME.Equals(ZH_CHT, StringComparison.OrdinalIgnoreCase)) { - this.sLocalizedDisplayName = GetLanguageDisplayName("zh-Hant"); + _sLocalizedDisplayName = GetLanguageDisplayName("zh-Hant"); } - else if (SNAME.Equals(ZH_CHS, StringComparison.OrdinalIgnoreCase)) + else if (SNAME.Equals(ZH_CHS, StringComparison.OrdinalIgnoreCase)) { - this.sLocalizedDisplayName = GetLanguageDisplayName("zh-Hans"); + _sLocalizedDisplayName = GetLanguageDisplayName("zh-Hans"); } else { - this.sLocalizedDisplayName = GetLanguageDisplayName(SNAME); + _sLocalizedDisplayName = GetLanguageDisplayName(SNAME); } } catch (Exception) @@ -717,12 +716,12 @@ namespace System.Globalization } } // If it hasn't been found (Windows 8 and up), fallback to the system - if (String.IsNullOrEmpty(this.sLocalizedDisplayName)) + if (String.IsNullOrEmpty(_sLocalizedDisplayName)) { // If its neutral use the language name if (this.IsNeutralCulture) { - this.sLocalizedDisplayName = this.SLOCALIZEDLANGUAGE; + _sLocalizedDisplayName = this.SLOCALIZEDLANGUAGE; } else { @@ -734,47 +733,46 @@ namespace System.Globalization ((ci = GetUserDefaultCulture()) != null) && !CultureInfo.DefaultThreadCurrentUICulture.Name.Equals(ci.Name)) { - this.sLocalizedDisplayName = this.SNATIVEDISPLAYNAME; + _sLocalizedDisplayName = this.SNATIVEDISPLAYNAME; } else { - this.sLocalizedDisplayName = GetLocaleInfo(LocaleStringData.LocalizedDisplayName); + _sLocalizedDisplayName = GetLocaleInfo(LocaleStringData.LocalizedDisplayName); } } } } - return this.sLocalizedDisplayName; + return _sLocalizedDisplayName; } } // English pretty name for this locale (ie: English (United States)) internal String SENGDISPLAYNAME { - [System.Security.SecurityCritical] // auto-generated get { - if (this.sEnglishDisplayName == null) + if (_sEnglishDisplayName == null) { // If its neutral use the language name if (this.IsNeutralCulture) { - this.sEnglishDisplayName = this.SENGLISHLANGUAGE; + _sEnglishDisplayName = this.SENGLISHLANGUAGE; // differentiate the legacy display names - switch (this.sName) + switch (_sName) { case "zh-CHS": case "zh-CHT": - this.sEnglishDisplayName += " Legacy"; + _sEnglishDisplayName += " Legacy"; break; } } else { - this.sEnglishDisplayName = GetLocaleInfo(LocaleStringData.EnglishDisplayName); + _sEnglishDisplayName = GetLocaleInfo(LocaleStringData.EnglishDisplayName); // if it isn't found build one: - if (String.IsNullOrEmpty(this.sEnglishDisplayName)) + if (String.IsNullOrEmpty(_sEnglishDisplayName)) { // Our existing names mostly look like: // "English" + "United States" -> "English (United States)" @@ -782,58 +780,57 @@ namespace System.Globalization if (this.SENGLISHLANGUAGE[this.SENGLISHLANGUAGE.Length - 1] == ')') { // "Azeri (Latin)" + "Azerbaijan" -> "Azeri (Latin, Azerbaijan)" - this.sEnglishDisplayName = - this.SENGLISHLANGUAGE.Substring(0, this.sEnglishLanguage.Length - 1) + + _sEnglishDisplayName = + this.SENGLISHLANGUAGE.Substring(0, _sEnglishLanguage.Length - 1) + ", " + this.SENGCOUNTRY + ")"; } else { // "English" + "United States" -> "English (United States)" - this.sEnglishDisplayName = this.SENGLISHLANGUAGE + " (" + this.SENGCOUNTRY + ")"; + _sEnglishDisplayName = this.SENGLISHLANGUAGE + " (" + this.SENGCOUNTRY + ")"; } } } } - return this.sEnglishDisplayName; + return _sEnglishDisplayName; } } // Native pretty name for this locale (ie: Deutsch (Deutschland)) internal String SNATIVEDISPLAYNAME { - [System.Security.SecurityCritical] // auto-generated get { - if (this.sNativeDisplayName == null) + if (_sNativeDisplayName == null) { // If its neutral use the language name if (this.IsNeutralCulture) { - this.sNativeDisplayName = this.SNATIVELANGUAGE; + _sNativeDisplayName = this.SNATIVELANGUAGE; // differentiate the legacy display names - switch (this.sName) + switch (_sName) { case "zh-CHS": - this.sNativeDisplayName += " \u65E7\u7248"; + _sNativeDisplayName += " \u65E7\u7248"; break; case "zh-CHT": - this.sNativeDisplayName += " \u820A\u7248"; + _sNativeDisplayName += " \u820A\u7248"; break; } } else { - this.sNativeDisplayName = GetLocaleInfo(LocaleStringData.NativeDisplayName); + _sNativeDisplayName = GetLocaleInfo(LocaleStringData.NativeDisplayName); // if it isn't found build one: - if (String.IsNullOrEmpty(this.sNativeDisplayName)) + if (String.IsNullOrEmpty(_sNativeDisplayName)) { // These should primarily be "Deutsch (Deutschland)" type names - this.sNativeDisplayName = this.SNATIVELANGUAGE + " (" + this.SNATIVECOUNTRY + ")"; + _sNativeDisplayName = this.SNATIVELANGUAGE + " (" + this.SNATIVECOUNTRY + ")"; } } } - return this.sNativeDisplayName; + return _sNativeDisplayName; } } @@ -846,11 +843,11 @@ namespace System.Globalization { get { - if (this.sISO639Language == null) + if (_sISO639Language == null) { - this.sISO639Language = GetLocaleInfo(LocaleStringData.Iso639LanguageName); + _sISO639Language = GetLocaleInfo(LocaleStringData.Iso639LanguageName); } - return this.sISO639Language; + return _sISO639Language; } } @@ -858,10 +855,9 @@ namespace System.Globalization // This is only valid for Windows 8 and higher neutrals: internal String SLOCALIZEDLANGUAGE { - [System.Security.SecurityCritical] // auto-generated get { - if (this.sLocalizedLanguage == null) + if (_sLocalizedLanguage == null) { // Usually the UI culture shouldn't be different than what we got from WinRT except // if DefaultThreadCurrentUICulture was set @@ -871,43 +867,41 @@ namespace System.Globalization ((ci = GetUserDefaultCulture()) != null) && !CultureInfo.DefaultThreadCurrentUICulture.Name.Equals(ci.Name)) { - this.sLocalizedLanguage = SNATIVELANGUAGE; + _sLocalizedLanguage = SNATIVELANGUAGE; } else { - this.sLocalizedLanguage = GetLocaleInfo(LocaleStringData.LocalizedLanguageName); + _sLocalizedLanguage = GetLocaleInfo(LocaleStringData.LocalizedLanguageName); } } - return this.sLocalizedLanguage; + return _sLocalizedLanguage; } } // English name for this language (Windows Only) ie: German internal String SENGLISHLANGUAGE { - [System.Security.SecurityCritical] // auto-generated get { - if (this.sEnglishLanguage == null) + if (_sEnglishLanguage == null) { - this.sEnglishLanguage = GetLocaleInfo(LocaleStringData.EnglishLanguageName); + _sEnglishLanguage = GetLocaleInfo(LocaleStringData.EnglishLanguageName); } - return this.sEnglishLanguage; + return _sEnglishLanguage; } } // Native name of this language (Windows Only) ie: Deutsch internal String SNATIVELANGUAGE { - [System.Security.SecurityCritical] // auto-generated get { - if (this.sNativeLanguage == null) + if (_sNativeLanguage == null) { - this.sNativeLanguage = GetLocaleInfo(LocaleStringData.NativeLanguageName); + _sNativeLanguage = GetLocaleInfo(LocaleStringData.NativeLanguageName); } - return this.sNativeLanguage; + return _sNativeLanguage; } } @@ -918,14 +912,13 @@ namespace System.Globalization // region name (eg US) internal String SREGIONNAME { - [System.Security.SecurityCritical] // auto-generated get { - if (this.sRegionName == null) + if (_sRegionName == null) { - this.sRegionName = GetLocaleInfo(LocaleStringData.Iso3166CountryName); + _sRegionName = GetLocaleInfo(LocaleStringData.Iso3166CountryName); } - return this.sRegionName; + return _sRegionName; } } @@ -933,68 +926,64 @@ namespace System.Globalization // localized name for the country internal string SLOCALIZEDCOUNTRY { - [System.Security.SecurityCritical] // auto-generated get { - if (this.sLocalizedCountry == null) + if (_sLocalizedCountry == null) { try { - this.sLocalizedCountry = GetRegionDisplayName(SISO3166CTRYNAME); + _sLocalizedCountry = GetRegionDisplayName(SISO3166CTRYNAME); } catch (Exception) { // do nothing. we'll fallback } - if (this.sLocalizedCountry == null) + if (_sLocalizedCountry == null) { - this.sLocalizedCountry = SNATIVECOUNTRY; + _sLocalizedCountry = SNATIVECOUNTRY; } } - return this.sLocalizedCountry; + return _sLocalizedCountry; } } // english country name (RegionInfo) ie: Germany internal String SENGCOUNTRY { - [System.Security.SecurityCritical] // auto-generated get { - if (this.sEnglishCountry == null) + if (_sEnglishCountry == null) { - this.sEnglishCountry = GetLocaleInfo(LocaleStringData.EnglishCountryName); + _sEnglishCountry = GetLocaleInfo(LocaleStringData.EnglishCountryName); } - return this.sEnglishCountry; + return _sEnglishCountry; } } // native country name (RegionInfo) ie: Deutschland internal String SNATIVECOUNTRY { - [System.Security.SecurityCritical] // auto-generated get { - if (this.sNativeCountry == null) + if (_sNativeCountry == null) { - this.sNativeCountry = GetLocaleInfo(LocaleStringData.NativeCountryName); + _sNativeCountry = GetLocaleInfo(LocaleStringData.NativeCountryName); } - return this.sNativeCountry; + return _sNativeCountry; } } // ISO 3166 Country Name internal String SISO3166CTRYNAME { - [System.Security.SecurityCritical] // auto-generated get { - if (this.sISO3166CountryName == null) + if (_sISO3166CountryName == null) { - this.sISO3166CountryName = GetLocaleInfo(LocaleStringData.Iso3166CountryName); + _sISO3166CountryName = GetLocaleInfo(LocaleStringData.Iso3166CountryName); } - return this.sISO3166CountryName; + return _sISO3166CountryName; } } @@ -1015,11 +1004,11 @@ namespace System.Globalization { get { - if (this.waGrouping == null) + if (_waGrouping == null) { - this.waGrouping = GetLocaleInfo(LocaleGroupingData.Digit); + _waGrouping = GetLocaleInfo(LocaleGroupingData.Digit); } - return this.waGrouping; + return _waGrouping; } } @@ -1032,11 +1021,11 @@ namespace System.Globalization { get { - if (this.sNaN == null) + if (_sNaN == null) { - this.sNaN = GetLocaleInfo(LocaleStringData.NaNSymbol); + _sNaN = GetLocaleInfo(LocaleStringData.NaNSymbol); } - return this.sNaN; + return _sNaN; } } @@ -1045,11 +1034,11 @@ namespace System.Globalization { get { - if (this.sPositiveInfinity == null) + if (_sPositiveInfinity == null) { - this.sPositiveInfinity = GetLocaleInfo(LocaleStringData.PositiveInfinitySymbol); + _sPositiveInfinity = GetLocaleInfo(LocaleStringData.PositiveInfinitySymbol); } - return this.sPositiveInfinity; + return _sPositiveInfinity; } } @@ -1058,11 +1047,11 @@ namespace System.Globalization { get { - if (this.sNegativeInfinity == null) + if (_sNegativeInfinity == null) { - this.sNegativeInfinity = GetLocaleInfo(LocaleStringData.NegativeInfinitySymbol); + _sNegativeInfinity = GetLocaleInfo(LocaleStringData.NegativeInfinitySymbol); } - return this.sNegativeInfinity; + return _sNegativeInfinity; } } @@ -1076,12 +1065,12 @@ namespace System.Globalization { get { - if (this.iNegativePercent == undef) + if (_iNegativePercent == undef) { // Note that <= Windows Vista this is synthesized by native code - this.iNegativePercent = GetLocaleInfo(LocaleNumberData.NegativePercentFormat); + _iNegativePercent = GetLocaleInfo(LocaleNumberData.NegativePercentFormat); } - return this.iNegativePercent; + return _iNegativePercent; } } @@ -1090,12 +1079,12 @@ namespace System.Globalization { get { - if (this.iPositivePercent == undef) + if (_iPositivePercent == undef) { // Note that <= Windows Vista this is synthesized by native code - this.iPositivePercent = GetLocaleInfo(LocaleNumberData.PositivePercentFormat); + _iPositivePercent = GetLocaleInfo(LocaleNumberData.PositivePercentFormat); } - return this.iPositivePercent; + return _iPositivePercent; } } @@ -1104,24 +1093,24 @@ namespace System.Globalization { get { - if (this.sPercent == null) + if (_sPercent == null) { - this.sPercent = GetLocaleInfo(LocaleStringData.PercentSymbol); + _sPercent = GetLocaleInfo(LocaleStringData.PercentSymbol); } - return this.sPercent; + return _sPercent; } } - // PerMille (‰) symbol + // PerMille symbol internal String SPERMILLE { get { - if (this.sPerMille == null) + if (_sPerMille == null) { - this.sPerMille = GetLocaleInfo(LocaleStringData.PerMilleSymbol); + _sPerMille = GetLocaleInfo(LocaleStringData.PerMilleSymbol); } - return this.sPerMille; + return _sPerMille; } } @@ -1132,28 +1121,26 @@ namespace System.Globalization // (user can override) local monetary symbol, eg: $ internal String SCURRENCY { - [System.Security.SecurityCritical] // auto-generated get { - if (this.sCurrency == null) + if (_sCurrency == null) { - this.sCurrency = GetLocaleInfo(LocaleStringData.MonetarySymbol); + _sCurrency = GetLocaleInfo(LocaleStringData.MonetarySymbol); } - return this.sCurrency; + return _sCurrency; } } // international monetary symbol (RegionInfo), eg: USD internal String SINTLSYMBOL { - [System.Security.SecurityCritical] // auto-generated get { - if (this.sIntlMonetarySymbol == null) + if (_sIntlMonetarySymbol == null) { - this.sIntlMonetarySymbol = GetLocaleInfo(LocaleStringData.Iso4217MonetarySymbol); + _sIntlMonetarySymbol = GetLocaleInfo(LocaleStringData.Iso4217MonetarySymbol); } - return this.sIntlMonetarySymbol; + return _sIntlMonetarySymbol; } } @@ -1166,11 +1153,11 @@ namespace System.Globalization { get { - if (this.waMonetaryGrouping == null) + if (_waMonetaryGrouping == null) { - this.waMonetaryGrouping = GetLocaleInfo(LocaleGroupingData.Monetary); + _waMonetaryGrouping = GetLocaleInfo(LocaleGroupingData.Monetary); } - return this.waMonetaryGrouping; + return _waMonetaryGrouping; } } @@ -1179,11 +1166,11 @@ namespace System.Globalization { get { - if (this.iMeasure == undef) + if (_iMeasure == undef) { - this.iMeasure = GetLocaleInfo(LocaleNumberData.MeasurementSystem); + _iMeasure = GetLocaleInfo(LocaleNumberData.MeasurementSystem); } - return this.iMeasure; + return _iMeasure; } } @@ -1192,11 +1179,11 @@ namespace System.Globalization { get { - if (this.sListSeparator == null) + if (_sListSeparator == null) { - this.sListSeparator = GetLocaleInfo(LocaleStringData.ListSeparator); + _sListSeparator = GetLocaleInfo(LocaleStringData.ListSeparator); } - return this.sListSeparator; + return _sListSeparator; } } @@ -1210,11 +1197,11 @@ namespace System.Globalization { get { - if (this.sAM1159 == null) + if (_sAM1159 == null) { - this.sAM1159 = GetLocaleInfo(LocaleStringData.AMDesignator); + _sAM1159 = GetLocaleInfo(LocaleStringData.AMDesignator); } - return this.sAM1159; + return _sAM1159; } } @@ -1223,11 +1210,11 @@ namespace System.Globalization { get { - if (this.sPM2359 == null) + if (_sPM2359 == null) { - this.sPM2359 = GetLocaleInfo(LocaleStringData.PMDesignator); + _sPM2359 = GetLocaleInfo(LocaleStringData.PMDesignator); } - return this.sPM2359; + return _sPM2359; } } @@ -1236,19 +1223,19 @@ namespace System.Globalization { get { - if (this.saLongTimes == null) + if (_saLongTimes == null) { String[] longTimes = GetTimeFormats(); if (longTimes == null || longTimes.Length == 0) { - this.saLongTimes = Invariant.saLongTimes; + _saLongTimes = Invariant._saLongTimes; } else { - this.saLongTimes = longTimes; + _saLongTimes = longTimes; } } - return this.saLongTimes; + return _saLongTimes; } } @@ -1259,7 +1246,7 @@ namespace System.Globalization { get { - if (this.saShortTimes == null) + if (_saShortTimes == null) { // Try to get the short times from the OS/culture.dll String[] shortTimes = null; @@ -1281,9 +1268,9 @@ namespace System.Globalization shortTimes = AdjustShortTimesForMac(shortTimes); // Found short times, use them - this.saShortTimes = shortTimes; + _saShortTimes = shortTimes; } - return this.saShortTimes; + return _saShortTimes; } } @@ -1422,11 +1409,11 @@ namespace System.Globalization { get { - if (this.iFirstDayOfWeek == undef) + if (_iFirstDayOfWeek == undef) { - this.iFirstDayOfWeek = GetFirstDayOfWeek(); + _iFirstDayOfWeek = GetFirstDayOfWeek(); } - return this.iFirstDayOfWeek; + return _iFirstDayOfWeek; } } @@ -1435,11 +1422,11 @@ namespace System.Globalization { get { - if (this.iFirstWeekOfYear == undef) + if (_iFirstWeekOfYear == undef) { - this.iFirstWeekOfYear = GetLocaleInfo(LocaleNumberData.FirstWeekOfYear); + _iFirstWeekOfYear = GetLocaleInfo(LocaleNumberData.FirstWeekOfYear); } - return this.iFirstWeekOfYear; + return _iFirstWeekOfYear; } } @@ -1529,26 +1516,26 @@ namespace System.Globalization { get { - if (this.waCalendars == null) + if (_waCalendars == null) { // We pass in an array of ints, and native side fills it up with count calendars. // We then have to copy that list to a new array of the right size. // Default calendar should be first CalendarId[] calendars = new CalendarId[23]; - Contract.Assert(this.sWindowsName != null, "[CultureData.CalendarIds] Expected this.sWindowsName to be populated by already"); - int count = CalendarData.GetCalendars(this.sWindowsName, this.bUseOverrides, calendars); + Contract.Assert(_sWindowsName != null, "[CultureData.CalendarIds] Expected _sWindowsName to be populated by already"); + int count = CalendarData.GetCalendars(_sWindowsName, _bUseOverrides, calendars); // See if we had a calendar to add. if (count == 0) { // Failed for some reason, just grab Gregorian from Invariant - this.waCalendars = Invariant.waCalendars; + _waCalendars = Invariant._waCalendars; } else { // The OS may not return calendar 4 for zh-TW, but we've always allowed it. - // TODO: Is this necessary long-term? - if (this.sWindowsName == "zh-TW") + // TODO: Is this hack necessary long-term? + if (_sWindowsName == "zh-TW") { bool found = false; @@ -1590,11 +1577,11 @@ namespace System.Globalization } } - this.waCalendars = temp; + _waCalendars = temp; } } - return this.waCalendars; + return _waCalendars; } } @@ -1607,21 +1594,21 @@ namespace System.Globalization int calendarIndex = (int)calendarId - 1; // Have to have calendars - if (calendars == null) + if (_calendars == null) { - calendars = new CalendarData[CalendarData.MAX_CALENDARS]; + _calendars = new CalendarData[CalendarData.MAX_CALENDARS]; } // we need the following local variable to avoid returning null // when another thread creates a new array of CalendarData (above) // right after we insert the newly created CalendarData (below) - CalendarData calendarData = calendars[calendarIndex]; + CalendarData calendarData = _calendars[calendarIndex]; // Make sure that calendar has data if (calendarData == null) { - Contract.Assert(this.sWindowsName != null, "[CultureData.GetCalendar] Expected this.sWindowsName to be populated by already"); - calendarData = new CalendarData(this.sWindowsName, calendarId, this.UseUserOverride); - calendars[calendarIndex] = calendarData; + Contract.Assert(_sWindowsName != null, "[CultureData.GetCalendar] Expected _sWindowsName to be populated by already"); + calendarData = new CalendarData(_sWindowsName, calendarId, this.UseUserOverride); + _calendars[calendarIndex] = calendarData; } return calendarData; @@ -1657,13 +1644,13 @@ namespace System.Globalization { get { - if (this.iReadingLayout == undef) + if (_iReadingLayout == undef) { - Contract.Assert(this.sRealName != null, "[CultureData.IsRightToLeft] Expected this.sRealName to be populated by already"); - this.iReadingLayout = GetLocaleInfo(LocaleNumberData.ReadingLayout); + Contract.Assert(_sRealName != null, "[CultureData.IsRightToLeft] Expected _sRealName to be populated by already"); + _iReadingLayout = GetLocaleInfo(LocaleNumberData.ReadingLayout); } - return (this.iReadingLayout); + return (_iReadingLayout); } } @@ -1680,8 +1667,8 @@ namespace System.Globalization { // Note: Custom cultures might point at another culture's textinfo, however windows knows how // to redirect it to the desired textinfo culture, so this is OK. - Contract.Assert(this.sRealName != null, "[CultureData.STEXTINFO] Expected this.sRealName to be populated by already"); - return (this.sRealName); + Contract.Assert(_sWindowsName != null, "[CultureData.STEXTINFO] Expected _sWindowsName to be populated by already"); + return (_sWindowsName); } } @@ -1690,8 +1677,8 @@ namespace System.Globalization { get { - Contract.Assert(this.sRealName != null, "[CultureData.SCOMPAREINFO] Expected this.sRealName to be populated by already"); - return (this.sRealName); + Contract.Assert(_sWindowsName != null, "[CultureData.SCOMPAREINFO] Expected _sWindowsName to be populated by already"); + return (_sWindowsName); } } @@ -1707,7 +1694,7 @@ namespace System.Globalization { get { - return this.iLanguage; + return _iLanguage; } } @@ -1716,7 +1703,7 @@ namespace System.Globalization get { // InitCultureData told us if we're neutral or not - return this.bNeutral; + return _bNeutral; } } @@ -1733,7 +1720,7 @@ namespace System.Globalization { get { - CalendarId defaultCalId = (CalendarId) GetLocaleInfo(LocaleNumberData.CalendarType); + CalendarId defaultCalId = (CalendarId)GetLocaleInfo(LocaleNumberData.CalendarType); if (defaultCalId == 0) { @@ -1775,7 +1762,7 @@ namespace System.Globalization { get { - if (sTimeSeparator == null) + if (_sTimeSeparator == null) { string longTimeFormat = GetTimeFormatString(); if (String.IsNullOrEmpty(longTimeFormat)) @@ -1784,9 +1771,9 @@ namespace System.Globalization } // Compute STIME from time format - sTimeSeparator = GetTimeSeparator(longTimeFormat); + _sTimeSeparator = GetTimeSeparator(longTimeFormat); } - return sTimeSeparator; + return _sTimeSeparator; } } @@ -1966,24 +1953,26 @@ namespace System.Globalization { if (this.IsInvariantCulture) { - nfi.positiveSign = this.sPositiveSign; - nfi.negativeSign = this.sNegativeSign; + // FUTURE: NumberFormatInfo already has default values for many of these fields. Can we not do this? + // if we do need to do this, then why don't we set nfi.nativeDigits in this case? + nfi.positiveSign = _sPositiveSign; + nfi.negativeSign = _sNegativeSign; - nfi.numberGroupSeparator = this.sThousandSeparator; - nfi.numberDecimalSeparator = this.sDecimalSeparator; - nfi.numberDecimalDigits = this.iDigits; - nfi.numberNegativePattern = this.iNegativeNumber; + nfi.numberGroupSeparator = _sThousandSeparator; + nfi.numberDecimalSeparator = _sDecimalSeparator; + nfi.numberDecimalDigits = _iDigits; + nfi.numberNegativePattern = _iNegativeNumber; - nfi.currencySymbol = this.sCurrency; - nfi.currencyGroupSeparator = this.sMonetaryThousand; - nfi.currencyDecimalSeparator = this.sMonetaryDecimal; - nfi.currencyDecimalDigits = this.iCurrencyDigits; - nfi.currencyNegativePattern = this.iNegativeCurrency; - nfi.currencyPositivePattern = this.iCurrency; + nfi.currencySymbol = _sCurrency; + nfi.currencyGroupSeparator = _sMonetaryThousand; + nfi.currencyDecimalSeparator = _sMonetaryDecimal; + nfi.currencyDecimalDigits = _iCurrencyDigits; + nfi.currencyNegativePattern = _iNegativeCurrency; + nfi.currencyPositivePattern = _iCurrency; } else { - Contract.Assert(this.sWindowsName != null, "[CultureData.GetNFIValues] Expected this.sWindowsName to be populated by already"); + Contract.Assert(_sWindowsName != null, "[CultureData.GetNFIValues] Expected _sWindowsName to be populated by already"); // String values nfi.positiveSign = GetLocaleInfo(LocaleStringData.PositiveSign); nfi.negativeSign = GetLocaleInfo(LocaleStringData.NegativeSign); @@ -2043,7 +2032,7 @@ namespace System.Globalization //Special case for Italian. The currency decimal separator in the control panel is the empty string. When the user //specifies C4 as the currency format, this results in the number apparently getting multiplied by 10000 because the - //decimal point doesn't show up. Our default currency format will never use nfi. + //decimal point doesn't show up. We'll just hack this here because our default currency format will never use nfi. if (nfi.currencyDecimalSeparator == null || nfi.currencyDecimalSeparator.Length == 0) { nfi.currencyDecimalSeparator = nfi.numberDecimalSeparator; diff --git a/src/mscorlib/corefx/System/Globalization/CultureInfo.Windows.cs b/src/mscorlib/corefx/System/Globalization/CultureInfo.Windows.cs index af27840..16c8a06 100644 --- a/src/mscorlib/corefx/System/Globalization/CultureInfo.Windows.cs +++ b/src/mscorlib/corefx/System/Globalization/CultureInfo.Windows.cs @@ -1,6 +1,7 @@ // 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 Internal.Runtime.Augments; namespace System.Globalization @@ -44,7 +45,7 @@ namespace System.Globalization CultureInfo temp = GetCultureByName(strDefault, true); - temp.m_isReadOnly = true; + temp._isReadOnly = true; return temp; } diff --git a/src/mscorlib/corefx/System/Globalization/CultureInfo.cs b/src/mscorlib/corefx/System/Globalization/CultureInfo.cs index 2e7b1c6..5e8e625 100644 --- a/src/mscorlib/corefx/System/Globalization/CultureInfo.cs +++ b/src/mscorlib/corefx/System/Globalization/CultureInfo.cs @@ -4,7 +4,6 @@ //////////////////////////////////////////////////////////////////////////// // -// Class: CultureInfo // // // Purpose: This class represents the software preferences of a particular @@ -13,7 +12,7 @@ // as well as methods for common operations such as printing // dates and sorting strings. // -// Date: March 31, 1999 +// // // !!!! NOTE WHEN CHANGING THIS CLASS !!!! // @@ -652,7 +651,7 @@ namespace System.Globalization } } - static private bool OkayToCacheClassWithCompatibilityBehavior + private static bool OkayToCacheClassWithCompatibilityBehavior { get { @@ -807,7 +806,7 @@ namespace System.Globalization { // Change the calendar of DTFI to the specified calendar of this CultureInfo. DateTimeFormatInfo temp = new DateTimeFormatInfo(this.m_cultureData, this.Calendar); - temp.m_isReadOnly = m_isReadOnly; + temp._isReadOnly = m_isReadOnly; System.Threading.Interlocked.MemoryBarrier(); dateTimeInfo = temp; } diff --git a/src/mscorlib/corefx/System/Globalization/CultureNotFoundException.cs b/src/mscorlib/corefx/System/Globalization/CultureNotFoundException.cs index df0f073..740063e 100644 --- a/src/mscorlib/corefx/System/Globalization/CultureNotFoundException.cs +++ b/src/mscorlib/corefx/System/Globalization/CultureNotFoundException.cs @@ -2,10 +2,6 @@ // 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.Threading; using System.Runtime.Serialization; @@ -16,7 +12,7 @@ namespace System.Globalization [System.Runtime.InteropServices.ComVisible(true)] public partial class CultureNotFoundException : ArgumentException, ISerializable { - private string m_invalidCultureName; // unrecognized culture name + private string _invalidCultureName; // unrecognized culture name public CultureNotFoundException() : base(DefaultMessage) @@ -41,18 +37,18 @@ namespace System.Globalization public CultureNotFoundException(String paramName, string invalidCultureName, String message) : base(message, paramName) { - m_invalidCultureName = invalidCultureName; + _invalidCultureName = invalidCultureName; } public CultureNotFoundException(String message, string invalidCultureName, Exception innerException) : base(message, innerException) { - m_invalidCultureName = invalidCultureName; + _invalidCultureName = invalidCultureName; } protected CultureNotFoundException(SerializationInfo info, StreamingContext context) : base(info, context) { - m_invalidCultureName = (string)info.GetValue("InvalidCultureName", typeof(string)); + _invalidCultureName = (string)info.GetValue("InvalidCultureName", typeof(string)); } [System.Security.SecurityCritical] // auto-generated_required @@ -64,12 +60,12 @@ namespace System.Globalization } base.GetObjectData(info, context); - info.AddValue("InvalidCultureName", m_invalidCultureName, typeof(string)); + info.AddValue("InvalidCultureName", _invalidCultureName, typeof(string)); } public virtual string InvalidCultureName { - get { return m_invalidCultureName; } + get { return _invalidCultureName; } } private static String DefaultMessage @@ -94,7 +90,7 @@ namespace System.Globalization { String s = base.Message; if ( - m_invalidCultureName != null) + _invalidCultureName != null) { String valueMessage = SR.Format(SR.Argument_CultureInvalidIdentifier, FormatedInvalidCultureId); if (s == null) diff --git a/src/mscorlib/corefx/System/Globalization/DateTimeFormatInfo.cs b/src/mscorlib/corefx/System/Globalization/DateTimeFormatInfo.cs index 89570ee..da746ad 100644 --- a/src/mscorlib/corefx/System/Globalization/DateTimeFormatInfo.cs +++ b/src/mscorlib/corefx/System/Globalization/DateTimeFormatInfo.cs @@ -60,86 +60,86 @@ namespace System.Globalization { // cache for the invariant culture. // invariantInfo is constant irrespective of your current culture. - private static volatile DateTimeFormatInfo invariantInfo; + private static volatile DateTimeFormatInfo s_invariantInfo; // an index which points to a record in Culture Data Table. [NonSerialized] - private CultureData m_cultureData; + private CultureData _cultureData; // The culture name used to create this DTFI. [OptionalField(VersionAdded = 2)] - internal String m_name = null; + private String _name = null; // The language name of the culture used to create this DTFI. [NonSerialized] - private String m_langName = null; + private String _langName = null; // CompareInfo usually used by the parser. [NonSerialized] - private CompareInfo m_compareInfo = null; + private CompareInfo _compareInfo = null; // Culture matches current DTFI. mainly used for string comparisons during parsing. [NonSerialized] - private CultureInfo m_cultureInfo = null; + private CultureInfo _cultureInfo = null; // // Caches for various properties. // - internal String amDesignator = null; - internal String pmDesignator = null; + private String amDesignator = null; + private String pmDesignator = null; - internal String dateSeparator = null; // derived from short date (whidbey expects, arrowhead doesn't) + private String dateSeparator = null; // derived from short date (whidbey expects, arrowhead doesn't) - internal String generalShortTimePattern = null; // short date + short time (whidbey expects, arrowhead doesn't) + private String generalShortTimePattern = null; // short date + short time (whidbey expects, arrowhead doesn't) - internal String generalLongTimePattern = null; // short date + long time (whidbey expects, arrowhead doesn't) + private String generalLongTimePattern = null; // short date + long time (whidbey expects, arrowhead doesn't) - internal String timeSeparator = null; // derived from long time (whidbey expects, arrowhead doesn't) - internal String monthDayPattern = null; + private String timeSeparator = null; // derived from long time (whidbey expects, arrowhead doesn't) + private String monthDayPattern = null; // added in .NET Framework Release {2.0SP1/3.0SP1/3.5RTM} - internal String dateTimeOffsetPattern = null; + private String dateTimeOffsetPattern = null; // // The following are constant values. // - internal const String rfc1123Pattern = "ddd, dd MMM yyyy HH':'mm':'ss 'GMT'"; + private const String rfc1123Pattern = "ddd, dd MMM yyyy HH':'mm':'ss 'GMT'"; // The sortable pattern is based on ISO 8601. - internal const String sortableDateTimePattern = "yyyy'-'MM'-'dd'T'HH':'mm':'ss"; - internal const String universalSortableDateTimePattern = "yyyy'-'MM'-'dd HH':'mm':'ss'Z'"; + private const String sortableDateTimePattern = "yyyy'-'MM'-'dd'T'HH':'mm':'ss"; + private const String universalSortableDateTimePattern = "yyyy'-'MM'-'dd HH':'mm':'ss'Z'"; // // The following are affected by calendar settings. // - internal Calendar calendar = null; + private Calendar calendar = null; - internal int firstDayOfWeek = -1; - internal int calendarWeekRule = -1; + private int firstDayOfWeek = -1; + private int calendarWeekRule = -1; - internal String fullDateTimePattern = null; // long date + long time (whidbey expects, arrowhead doesn't) + private String fullDateTimePattern = null; // long date + long time (whidbey expects, arrowhead doesn't) - internal String[] abbreviatedDayNames = null; + private String[] abbreviatedDayNames = null; - internal String[] m_superShortDayNames = null; + private String[] m_superShortDayNames = null; - internal String[] dayNames = null; - internal String[] abbreviatedMonthNames = null; - internal String[] monthNames = null; + private String[] dayNames = null; + private String[] abbreviatedMonthNames = null; + private String[] monthNames = null; // Cache the genitive month names that we retrieve from the data table. - internal String[] genitiveMonthNames = null; + private String[] genitiveMonthNames = null; // Cache the abbreviated genitive month names that we retrieve from the data table. - internal String[] m_genitiveAbbreviatedMonthNames = null; + private String[] m_genitiveAbbreviatedMonthNames = null; // Cache the month names of a leap year that we retrieve from the data table. - internal String[] leapYearMonthNames = null; + private String[] leapYearMonthNames = null; // For our "patterns" arrays we have 2 variables, a string and a string[] // @@ -148,46 +148,46 @@ namespace System.Globalization // When we initially construct our string[], we set the string to string[0] // The "default" Date/time patterns - internal String longDatePattern = null; - internal String shortDatePattern = null; - internal String yearMonthPattern = null; - internal String longTimePattern = null; - internal String shortTimePattern = null; + private String longDatePattern = null; + private String shortDatePattern = null; + private String yearMonthPattern = null; + private String longTimePattern = null; + private String shortTimePattern = null; [OptionalField(VersionAdded = 3)] private String[] allYearMonthPatterns = null; - internal String[] allShortDatePatterns = null; - internal String[] allLongDatePatterns = null; - internal String[] allShortTimePatterns = null; - internal String[] allLongTimePatterns = null; + + private String[] allShortDatePatterns = null; + private String[] allLongDatePatterns = null; + private String[] allShortTimePatterns = null; + private String[] allLongTimePatterns = null; // Cache the era names for this DateTimeFormatInfo instance. - internal String[] m_eraNames = null; - internal String[] m_abbrevEraNames = null; - internal String[] m_abbrevEnglishEraNames = null; + private String[] m_eraNames = null; + private String[] m_abbrevEraNames = null; + private String[] m_abbrevEnglishEraNames = null; - internal CalendarId[] optionalCalendars = null; + private CalendarId[] optionalCalendars = null; private const int DEFAULT_ALL_DATETIMES_SIZE = 132; // CultureInfo updates this - internal bool m_isReadOnly = false; + internal bool _isReadOnly = false; // This flag gives hints about if formatting/parsing should perform special code path for things like // genitive form or leap year month names. - internal DateTimeFormatFlags formatFlags = DateTimeFormatFlags.NotInitialized; + private DateTimeFormatFlags formatFlags = DateTimeFormatFlags.NotInitialized; - // TODO: NLS Arrowhead - Yipe, this is used for scary internal hard coded stuff, language name might be better private String CultureName { get { - if (m_name == null) + if (_name == null) { - m_name = this.m_cultureData.CultureName; + _name = _cultureData.CultureName; } - return (m_name); + return (_name); } } @@ -195,25 +195,24 @@ namespace System.Globalization { get { - if (m_cultureInfo == null) + if (_cultureInfo == null) { - m_cultureInfo = CultureInfo.GetCultureInfo(this.CultureName); + _cultureInfo = CultureInfo.GetCultureInfo(this.CultureName); } - return m_cultureInfo; + return _cultureInfo; } } - // TODO: NLS Arrowhead - This ignores other cultures that might want to do something similar + // TODO: This ignores other cultures that might want to do something similar private String LanguageName { - [System.Security.SecurityCritical] // auto-generated get { - if (m_langName == null) + if (_langName == null) { - m_langName = this.m_cultureData.SISO639LANGNAME; + _langName = _cultureData.SISO639LANGNAME; } - return (m_langName); + return (_langName); } } @@ -228,7 +227,7 @@ namespace System.Globalization if (this.abbreviatedDayNames == null) { // Get the abbreviated day names for our current calendar - this.abbreviatedDayNames = this.m_cultureData.AbbreviatedDayNames(Calendar.ID); + this.abbreviatedDayNames = _cultureData.AbbreviatedDayNames(Calendar.ID); Contract.Assert(this.abbreviatedDayNames.Length == 7, "[DateTimeFormatInfo.GetAbbreviatedDayOfWeekNames] Expected 7 day names in a week"); } return (this.abbreviatedDayNames); @@ -252,7 +251,7 @@ namespace System.Globalization if (this.m_superShortDayNames == null) { // Get the super short day names for our current calendar - this.m_superShortDayNames = this.m_cultureData.SuperShortDayNames(Calendar.ID); + this.m_superShortDayNames = _cultureData.SuperShortDayNames(Calendar.ID); Contract.Assert(this.m_superShortDayNames.Length == 7, "[DateTimeFormatInfo.internalGetSuperShortDayNames] Expected 7 day names in a week"); } return (this.m_superShortDayNames); @@ -269,7 +268,7 @@ namespace System.Globalization if (this.dayNames == null) { // Get the day names for our current calendar - this.dayNames = this.m_cultureData.DayNames(Calendar.ID); + this.dayNames = _cultureData.DayNames(Calendar.ID); Contract.Assert(this.dayNames.Length == 7, "[DateTimeFormatInfo.GetDayOfWeekNames] Expected 7 day names in a week"); } return (this.dayNames); @@ -286,7 +285,7 @@ namespace System.Globalization if (this.abbreviatedMonthNames == null) { // Get the month names for our current calendar - this.abbreviatedMonthNames = this.m_cultureData.AbbreviatedMonthNames(Calendar.ID); + this.abbreviatedMonthNames = _cultureData.AbbreviatedMonthNames(Calendar.ID); Contract.Assert(this.abbreviatedMonthNames.Length == 12 || this.abbreviatedMonthNames.Length == 13, "[DateTimeFormatInfo.GetAbbreviatedMonthNames] Expected 12 or 13 month names in a year"); } @@ -305,7 +304,7 @@ namespace System.Globalization if (this.monthNames == null) { // Get the month names for our current calendar - this.monthNames = this.m_cultureData.MonthNames(Calendar.ID); + this.monthNames = _cultureData.MonthNames(Calendar.ID); Contract.Assert(this.monthNames.Length == 12 || this.monthNames.Length == 13, "[DateTimeFormatInfo.GetMonthNames] Expected 12 or 13 month names in a year"); } @@ -329,12 +328,11 @@ namespace System.Globalization Contract.Requires(cal != null); // Remember our culture - this.m_cultureData = cultureData; + _cultureData = cultureData; this.Calendar = cal; } - [System.Security.SecuritySafeCritical] private void InitializeOverridableProperties(CultureData cultureData, CalendarId calendarId) { Contract.Requires(cultureData != null); @@ -348,10 +346,10 @@ namespace System.Globalization if (this.timeSeparator == null) { this.timeSeparator = cultureData.TimeSeparator; } if (this.dateSeparator == null) { this.dateSeparator = cultureData.DateSeparator(calendarId); } - this.allLongTimePatterns = this.m_cultureData.LongTimes; + this.allLongTimePatterns = _cultureData.LongTimes; Contract.Assert(this.allLongTimePatterns.Length > 0, "[DateTimeFormatInfo.Populate] Expected some long time patterns"); - this.allShortTimePatterns = this.m_cultureData.ShortTimes; + this.allShortTimePatterns = _cultureData.ShortTimes; Contract.Assert(this.allShortTimePatterns.Length > 0, "[DateTimeFormatInfo.Populate] Expected some short time patterns"); this.allLongDatePatterns = cultureData.LongDates(calendarId); @@ -365,7 +363,7 @@ namespace System.Globalization } [OptionalField(VersionAdded = 1)] - private bool m_useUserOverride; + private bool _useUserOverride; // This was synthesized by Whidbey so we knew what words might appear in the middle of a date string // Now we always synthesize so its not helpful @@ -375,8 +373,8 @@ namespace System.Globalization [OnSerializing] private void OnSerializing(StreamingContext ctx) { - m_name = this.CultureName; // make sure the m_name is initialized. - m_useUserOverride = this.m_cultureData.UseUserOverride; + _name = this.CultureName; // make sure the _name is initialized. + _useUserOverride = _cultureData.UseUserOverride; // Important to initialize these fields otherwise we may run into exception when deserializing on Whidbey // because Whidbey try to initialize some of these fields using calendar data which could be null values @@ -397,28 +395,28 @@ namespace System.Globalization [OnDeserialized] private void OnDeserialized(StreamingContext ctx) { - if (m_name != null) + if (_name != null) { - m_cultureData = CultureData.GetCultureData(m_name, m_useUserOverride); - if (m_cultureData == null) + _cultureData = CultureData.GetCultureData(_name, _useUserOverride); + if (_cultureData == null) { - throw new CultureNotFoundException("m_name", m_name, SR.Argument_CultureNotSupported); + throw new CultureNotFoundException("_name", _name, SR.Argument_CultureNotSupported); } } if (calendar == null) { calendar = (Calendar)GregorianCalendar.GetDefaultInstance().Clone(); - calendar.SetReadOnlyState(m_isReadOnly); + calendar.SetReadOnlyState(_isReadOnly); } - InitializeOverridableProperties(m_cultureData, calendar.ID); + InitializeOverridableProperties(_cultureData, calendar.ID); // // turn off read only state till we finish initializing all fields and then store read only state after we are done. // - bool isReadOnly = m_isReadOnly; - m_isReadOnly = false; + bool isReadOnly = _isReadOnly; + _isReadOnly = false; // If we deserialized defaults ala Whidbey, make sure they're still defaults // Whidbey's arrays could get a bit mixed up. @@ -428,7 +426,7 @@ namespace System.Globalization if (longTimePattern != null) this.LongTimePattern = longTimePattern; if (shortTimePattern != null) this.ShortTimePattern = shortTimePattern; - m_isReadOnly = isReadOnly; + _isReadOnly = isReadOnly; } // Returns a default DateTimeFormatInfo that will be universally @@ -441,14 +439,14 @@ namespace System.Globalization get { Contract.Ensures(Contract.Result() != null); - if (invariantInfo == null) + if (s_invariantInfo == null) { DateTimeFormatInfo info = new DateTimeFormatInfo(); info.Calendar.SetReadOnlyState(true); - info.m_isReadOnly = true; - invariantInfo = info; + info._isReadOnly = true; + s_invariantInfo = info; } - return (invariantInfo); + return (s_invariantInfo); } } @@ -515,7 +513,7 @@ namespace System.Globalization // We can use the data member calendar in the setter, instead of the property Calendar, // since the cloned copy should have the same state as the original copy. n.calendar = (Calendar)this.Calendar.Clone(); - n.m_isReadOnly = false; + n._isReadOnly = false; return n; } @@ -523,12 +521,11 @@ namespace System.Globalization public String AMDesignator { // auto-generated - [System.Security.SecuritySafeCritical] // auto-generated get { if (this.amDesignator == null) { - this.amDesignator = this.m_cultureData.SAM1159; + this.amDesignator = _cultureData.SAM1159; } Contract.Assert(this.amDesignator != null, "DateTimeFormatInfo.AMDesignator, amDesignator != null"); return (this.amDesignator); @@ -636,7 +633,7 @@ namespace System.Globalization // Remember the new calendar calendar = value; - InitializeOverridableProperties(m_cultureData, calendar.ID); + InitializeOverridableProperties(_cultureData, calendar.ID); // We succeeded, return return; @@ -654,7 +651,7 @@ namespace System.Globalization { if (this.optionalCalendars == null) { - this.optionalCalendars = this.m_cultureData.CalendarIds; + this.optionalCalendars = _cultureData.CalendarIds; } return (this.optionalCalendars); } @@ -678,6 +675,10 @@ namespace System.Globalization } Contract.EndContractBlock(); + // The Era Name and Abbreviated Era Name + // for Taiwan Calendar on non-Taiwan SKU returns empty string (which + // would be matched below) but we don't want the empty string to give + // us an Era number // confer 85900 DTFI.GetEra("") should fail on all cultures if (eraName.Length == 0) { @@ -728,7 +729,7 @@ namespace System.Globalization { if (this.m_eraNames == null) { - this.m_eraNames = this.m_cultureData.EraNames(Calendar.ID); ; + this.m_eraNames = _cultureData.EraNames(Calendar.ID); ; } return (this.m_eraNames); } @@ -767,7 +768,7 @@ namespace System.Globalization { if (this.m_abbrevEraNames == null) { - this.m_abbrevEraNames = this.m_cultureData.AbbrevEraNames(Calendar.ID); + this.m_abbrevEraNames = _cultureData.AbbrevEraNames(Calendar.ID); } return (this.m_abbrevEraNames); } @@ -800,7 +801,7 @@ namespace System.Globalization if (this.m_abbrevEnglishEraNames == null) { Contract.Assert(Calendar.ID > 0, "[DateTimeFormatInfo.AbbreviatedEnglishEraNames] Expected Calendar.ID > 0"); - this.m_abbrevEnglishEraNames = this.m_cultureData.AbbreviatedEnglishEraNames(Calendar.ID); + this.m_abbrevEnglishEraNames = _cultureData.AbbreviatedEnglishEraNames(Calendar.ID); } return (this.m_abbrevEnglishEraNames); } @@ -815,7 +816,7 @@ namespace System.Globalization { if (this.dateSeparator == null) { - this.dateSeparator = this.m_cultureData.DateSeparator(Calendar.ID); + this.dateSeparator = _cultureData.DateSeparator(Calendar.ID); } Contract.Assert(this.dateSeparator != null, "DateTimeFormatInfo.DateSeparator, dateSeparator != null"); return (this.dateSeparator); @@ -833,7 +834,7 @@ namespace System.Globalization { if (this.firstDayOfWeek == -1) { - this.firstDayOfWeek = this.m_cultureData.IFIRSTDAYOFWEEK; + this.firstDayOfWeek = _cultureData.IFIRSTDAYOFWEEK; } Contract.Assert(this.firstDayOfWeek != -1, "DateTimeFormatInfo.FirstDayOfWeek, firstDayOfWeek != -1"); @@ -863,7 +864,7 @@ namespace System.Globalization { if (this.calendarWeekRule == -1) { - this.calendarWeekRule = this.m_cultureData.IFIRSTWEEKOFYEAR; + this.calendarWeekRule = _cultureData.IFIRSTWEEKOFYEAR; } Contract.Assert(this.calendarWeekRule != -1, "DateTimeFormatInfo.CalendarWeekRule, calendarWeekRule != -1"); return ((CalendarWeekRule)this.calendarWeekRule); @@ -1005,7 +1006,7 @@ namespace System.Globalization if (this.monthDayPattern == null) { Contract.Assert(Calendar.ID > 0, "[DateTimeFormatInfo.MonthDayPattern] Expected calID > 0"); - this.monthDayPattern = this.m_cultureData.MonthDay(Calendar.ID); + this.monthDayPattern = _cultureData.MonthDay(Calendar.ID); } Contract.Assert(this.monthDayPattern != null, "DateTimeFormatInfo.MonthDayPattern, monthDayPattern != null"); return (this.monthDayPattern); @@ -1030,12 +1031,11 @@ namespace System.Globalization public String PMDesignator { // auto-generated - [System.Security.SecuritySafeCritical] // auto-generated get { if (this.pmDesignator == null) { - this.pmDesignator = this.m_cultureData.SPM2359; + this.pmDesignator = _cultureData.SPM2359; } Contract.Assert(this.pmDesignator != null, "DateTimeFormatInfo.PMDesignator, pmDesignator != null"); return (this.pmDesignator); @@ -1215,7 +1215,7 @@ namespace System.Globalization { if (dateTimeOffsetPattern == null) { - dateTimeOffsetPattern = ShortDatePattern + " " + LongTimePattern; + string dateTimePattern = ShortDatePattern + " " + LongTimePattern; /* LongTimePattern might contain a "z" as part of the format string in which case we don't want to append a time zone offset */ @@ -1259,8 +1259,10 @@ namespace System.Globalization if (!foundZ) { - dateTimeOffsetPattern = dateTimeOffsetPattern + " zzz"; + dateTimePattern = dateTimePattern + " zzz"; } + + dateTimeOffsetPattern = dateTimePattern; } return (dateTimeOffsetPattern); } @@ -1268,14 +1270,13 @@ namespace System.Globalization // Note that cultureData derives this from the long time format (unless someone's set this previously) // Note that this property is quite undesirable. - // TODO: Arrowhead - consider deprecating internal String TimeSeparator { get { if (timeSeparator == null) { - timeSeparator = this.m_cultureData.TimeSeparator; + timeSeparator = _cultureData.TimeSeparator; } Contract.Assert(this.timeSeparator != null, "DateTimeFormatInfo.TimeSeparator, timeSeparator != null"); return (timeSeparator); @@ -1336,7 +1337,7 @@ namespace System.Globalization // // Check if a string array contains a null value, and throw ArgumentNullException with parameter name "value" // - static private void CheckNullValue(String[] values, int length) + private static void CheckNullValue(String[] values, int length) { Contract.Requires(values != null, "value != null"); Contract.Requires(values.Length >= length); @@ -1494,7 +1495,7 @@ namespace System.Globalization // Whitespaces that we allow in the month names. // U+00a0 is non-breaking space. - static char[] MonthSpaces = { ' ', '\u00a0' }; + private static readonly char[] s_monthSpaces = { ' ', '\u00a0' }; internal bool HasSpacesInMonthNames { @@ -1569,7 +1570,7 @@ namespace System.Globalization { if (this.m_genitiveAbbreviatedMonthNames == null) { - this.m_genitiveAbbreviatedMonthNames = this.m_cultureData.AbbreviatedGenitiveMonthNames(this.Calendar.ID); + this.m_genitiveAbbreviatedMonthNames = _cultureData.AbbreviatedGenitiveMonthNames(this.Calendar.ID); Contract.Assert(this.m_genitiveAbbreviatedMonthNames.Length == 13, "[DateTimeFormatInfo.GetGenitiveMonthNames] Expected 13 abbreviated genitive month names in a year"); } @@ -1578,7 +1579,7 @@ namespace System.Globalization if (this.genitiveMonthNames == null) { - this.genitiveMonthNames = this.m_cultureData.GenitiveMonthNames(this.Calendar.ID); + this.genitiveMonthNames = _cultureData.GenitiveMonthNames(this.Calendar.ID); Contract.Assert(this.genitiveMonthNames.Length == 13, "[DateTimeFormatInfo.GetGenitiveMonthNames] Expected 13 genitive month names in a year"); } @@ -1597,7 +1598,7 @@ namespace System.Globalization if (this.leapYearMonthNames == null) { Contract.Assert(Calendar.ID > 0, "[DateTimeFormatInfo.internalGetLeapYearMonthNames] Expected Calendar.ID > 0"); - this.leapYearMonthNames = this.m_cultureData.LeapYearMonthNames(Calendar.ID); + this.leapYearMonthNames = _cultureData.LeapYearMonthNames(Calendar.ID); Contract.Assert(this.leapYearMonthNames.Length == 13, "[DateTimeFormatInfo.internalGetLeapYearMonthNames] Expepcted 13 leap year month names"); } @@ -1622,7 +1623,7 @@ namespace System.Globalization } // Get all possible combination of inputs - static private String[] GetCombinedPatterns(String[] patterns1, String[] patterns2, String connectString) + private static String[] GetCombinedPatterns(String[] patterns1, String[] patterns2, String connectString) { Contract.Requires(patterns1 != null); Contract.Requires(patterns2 != null); @@ -1864,7 +1865,7 @@ namespace System.Globalization if (this.allYearMonthPatterns == null) { Contract.Assert(Calendar.ID > 0, "[DateTimeFormatInfo.UnclonedYearMonthPatterns] Expected Calendar.ID > 0"); - this.allYearMonthPatterns = this.m_cultureData.YearMonths(this.Calendar.ID); + this.allYearMonthPatterns = _cultureData.YearMonths(this.Calendar.ID); Contract.Assert(this.allYearMonthPatterns.Length > 0, "[DateTimeFormatInfo.UnclonedYearMonthPatterns] Expected some year month patterns"); } @@ -1883,7 +1884,7 @@ namespace System.Globalization if (allShortDatePatterns == null) { Contract.Assert(Calendar.ID > 0, "[DateTimeFormatInfo.UnclonedShortDatePatterns] Expected Calendar.ID > 0"); - this.allShortDatePatterns = this.m_cultureData.ShortDates(this.Calendar.ID); + this.allShortDatePatterns = _cultureData.ShortDates(this.Calendar.ID); Contract.Assert(this.allShortDatePatterns.Length > 0, "[DateTimeFormatInfo.UnclonedShortDatePatterns] Expected some short date patterns"); } @@ -1901,7 +1902,7 @@ namespace System.Globalization if (allLongDatePatterns == null) { Contract.Assert(Calendar.ID > 0, "[DateTimeFormatInfo.UnclonedLongDatePatterns] Expected Calendar.ID > 0"); - this.allLongDatePatterns = this.m_cultureData.LongDates(this.Calendar.ID); + this.allLongDatePatterns = _cultureData.LongDates(this.Calendar.ID); Contract.Assert(this.allLongDatePatterns.Length > 0, "[DateTimeFormatInfo.UnclonedLongDatePatterns] Expected some long date patterns"); } @@ -1918,7 +1919,7 @@ namespace System.Globalization { if (this.allShortTimePatterns == null) { - this.allShortTimePatterns = this.m_cultureData.ShortTimes; + this.allShortTimePatterns = _cultureData.ShortTimes; Contract.Assert(this.allShortTimePatterns.Length > 0, "[DateTimeFormatInfo.UnclonedShortTimePatterns] Expected some short time patterns"); } @@ -1935,7 +1936,7 @@ namespace System.Globalization { if (this.allLongTimePatterns == null) { - this.allLongTimePatterns = this.m_cultureData.LongTimes; + this.allLongTimePatterns = _cultureData.LongTimes; Contract.Assert(this.allLongTimePatterns.Length > 0, "[DateTimeFormatInfo.UnclonedLongTimePatterns] Expected some long time patterns"); } @@ -1960,7 +1961,7 @@ namespace System.Globalization // We can use the data member calendar in the setter, instead of the property Calendar, // since the cloned copy should have the same state as the original copy. newInfo.calendar = Calendar.ReadOnly(dtfi.Calendar); - newInfo.m_isReadOnly = true; + newInfo._isReadOnly = true; return (newInfo); } @@ -1968,7 +1969,7 @@ namespace System.Globalization { get { - return (m_isReadOnly); + return (_isReadOnly); } } @@ -2032,23 +2033,23 @@ namespace System.Globalization // Positive TimeSpan Pattern // - private string m_fullTimeSpanPositivePattern; + private string _fullTimeSpanPositivePattern; internal String FullTimeSpanPositivePattern { get { - if (m_fullTimeSpanPositivePattern == null) + if (_fullTimeSpanPositivePattern == null) { CultureData cultureDataWithoutUserOverrides; - if (m_cultureData.UseUserOverride) - cultureDataWithoutUserOverrides = CultureData.GetCultureData(m_cultureData.CultureName, false); + if (_cultureData.UseUserOverride) + cultureDataWithoutUserOverrides = CultureData.GetCultureData(_cultureData.CultureName, false); else - cultureDataWithoutUserOverrides = m_cultureData; + cultureDataWithoutUserOverrides = _cultureData; String decimalSeparator = new NumberFormatInfo(cultureDataWithoutUserOverrides).NumberDecimalSeparator; - m_fullTimeSpanPositivePattern = "d':'h':'mm':'ss'" + decimalSeparator + "'FFFFFFF"; + _fullTimeSpanPositivePattern = "d':'h':'mm':'ss'" + decimalSeparator + "'FFFFFFF"; } - return m_fullTimeSpanPositivePattern; + return _fullTimeSpanPositivePattern; } } @@ -2056,14 +2057,14 @@ namespace System.Globalization // Negative TimeSpan Pattern // - private string m_fullTimeSpanNegativePattern; + private string _fullTimeSpanNegativePattern; internal String FullTimeSpanNegativePattern { get { - if (m_fullTimeSpanNegativePattern == null) - m_fullTimeSpanNegativePattern = "'-'" + FullTimeSpanPositivePattern; - return m_fullTimeSpanNegativePattern; + if (_fullTimeSpanNegativePattern == null) + _fullTimeSpanNegativePattern = "'-'" + FullTimeSpanPositivePattern; + return _fullTimeSpanNegativePattern; } } @@ -2074,14 +2075,14 @@ namespace System.Globalization { get { - if (m_compareInfo == null) + if (_compareInfo == null) { // We use the regular GetCompareInfo here to make sure the created CompareInfo object is stored in the - // CompareInfo cache. otherwise we would just create CompareInfo using m_cultureData. - m_compareInfo = CompareInfo.GetCompareInfo(m_cultureData.SCOMPAREINFO); + // CompareInfo cache. otherwise we would just create CompareInfo using _cultureData. + _compareInfo = CompareInfo.GetCompareInfo(_cultureData.SCOMPAREINFO); } - return m_compareInfo; + return _compareInfo; } } @@ -2138,7 +2139,7 @@ namespace System.Globalization { switch (calendar.ID) { - // Add a special case for Japanese and Taiwan. + // Handle Japanese and Taiwan cases. // If is y/yy, do not get (year % 100). "y" will print // year without leading zero. "yy" will print year with two-digit in leading zero. // If pattern is yyy/yyyy/..., print year value with two-digit in leading zero. @@ -2212,7 +2213,7 @@ namespace System.Globalization // DateTimeFormatInfo tokenizer. This is used by DateTime.Parse() to break input string into tokens. // - TokenHashValue[] m_dtfiTokenHash; + private TokenHashValue[] _dtfiTokenHash; private const int TOKEN_HASH_SIZE = 199; private const int SECOND_PRIME = 197; @@ -2277,7 +2278,6 @@ namespace System.Globalization return (temp); } - // // Create a Taiwan DTFI which uses TaiwanCalendar. This is used to parse // date string with era name correctly even when the supplied DTFI // does not use Taiwan calendar. @@ -2298,14 +2298,13 @@ namespace System.Globalization // DTFI properties should call this when the setter are called. private void ClearTokenHashTable() { - m_dtfiTokenHash = null; + _dtfiTokenHash = null; formatFlags = DateTimeFormatFlags.NotInitialized; } - [System.Security.SecurityCritical] // auto-generated internal TokenHashValue[] CreateTokenHashTable() { - TokenHashValue[] temp = m_dtfiTokenHash; + TokenHashValue[] temp = _dtfiTokenHash; if (temp == null) { temp = new TokenHashValue[TOKEN_HASH_SIZE]; @@ -2330,7 +2329,7 @@ namespace System.Globalization InsertHash(temp, this.AMDesignator, TokenType.SEP_Am | TokenType.Am, 0); InsertHash(temp, this.PMDesignator, TokenType.SEP_Pm | TokenType.Pm, 1); - // TODO: NLS Arrowhead - Yipe, this ignores similar custom cultures + // TODO: This ignores similar custom cultures if (LanguageName.Equals("sq")) { // Albanian allows time formats like "12:00.PD" @@ -2351,7 +2350,7 @@ namespace System.Globalization InsertHash(temp, CJKMinuteSuff, TokenType.SEP_MinuteSuff, 0); InsertHash(temp, CJKSecondSuff, TokenType.SEP_SecondSuff, 0); - // TODO: NLS Arrowhead -This ignores other custom cultures that might want to do something similar + // TODO: This ignores other custom cultures that might want to do something similar if (koreanLanguage) { // Korean suffix @@ -2411,7 +2410,7 @@ namespace System.Globalization break; default: InsertHash(temp, dateWords[i], TokenType.DateWordToken, 0); - // TODO: NLS Arrowhead -Yipe, this ignores similar custom cultures + // TODO: This ignores similar custom cultures if (LanguageName.Equals("eu")) { // Basque has date words with leading dots @@ -2475,7 +2474,7 @@ namespace System.Globalization InsertHash(temp, GetAbbreviatedEraName(i), TokenType.EraToken, i); } - // TODO: NLS Arrowhead -This ignores other cultures that might want to do something similar + // TODO: This ignores other cultures that might want to do something similar if (LanguageName.Equals(JapaneseLangName)) { // Japanese allows day of week forms like: "(Tue)" @@ -2498,7 +2497,7 @@ namespace System.Globalization } } } - // TODO: NLS Arrowhead -This isn't good, it prohibits similar custom cultures, but we hard coded the name + // TODO: This prohibits similar custom cultures, but we hard coded the name else if (CultureName.Equals("zh-TW")) { DateTimeFormatInfo twDtfi = GetTaiwanCalendarDTFI(); @@ -2550,7 +2549,7 @@ namespace System.Globalization InsertHash(temp, invariantDateSeparator, TokenType.SEP_Date, 0); InsertHash(temp, invariantTimeSeparator, TokenType.SEP_Time, 0); - m_dtfiTokenHash = temp; + _dtfiTokenHash = temp; } return (temp); } @@ -2654,7 +2653,6 @@ namespace System.Globalization return (ch >= '\x0590' && ch <= '\x05ff'); } - [System.Security.SecurityCritical] // auto-generated internal bool Tokenize(TokenType TokenMask, out TokenType tokenType, out int tokenValue, #if INSIDE_CLR ref __DTString str) @@ -2698,7 +2696,7 @@ namespace System.Globalization int remaining = str.len - str.Index; int i = 0; - TokenHashValue[] hashTable = m_dtfiTokenHash; + TokenHashValue[] hashTable = _dtfiTokenHash; if (hashTable == null) { hashTable = CreateTokenHashTable(); @@ -2760,7 +2758,7 @@ namespace System.Globalization return (false); } - void InsertAtCurrentHashNode(TokenHashValue[] hashTable, String str, char ch, TokenType tokenType, int tokenValue, int pos, int hashcode, int hashProbe) + private void InsertAtCurrentHashNode(TokenHashValue[] hashTable, String str, char ch, TokenType tokenType, int tokenValue, int pos, int hashcode, int hashProbe) { // Remember the current slot. TokenHashValue previousNode = hashTable[hashcode]; @@ -2793,7 +2791,7 @@ namespace System.Globalization Contract.Assert(false, "The hashtable is full. This should not happen."); } - void InsertHash(TokenHashValue[] hashTable, String str, TokenType tokenType, int tokenValue) + private void InsertHash(TokenHashValue[] hashTable, String str, TokenType tokenType, int tokenValue) { // The month of the 13th month is allowed to be null, so make sure that we ignore null value here. if (str == null || str.Length == 0) diff --git a/src/mscorlib/corefx/System/Globalization/DateTimeFormatInfoScanner.cs b/src/mscorlib/corefx/System/Globalization/DateTimeFormatInfoScanner.cs index 442444a..9cbc19f 100644 --- a/src/mscorlib/corefx/System/Globalization/DateTimeFormatInfoScanner.cs +++ b/src/mscorlib/corefx/System/Globalization/DateTimeFormatInfoScanner.cs @@ -1,6 +1,7 @@ // 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. + //////////////////////////////////////////////////////////////////////////// // // DateTimeFormatInfoScanner @@ -385,7 +386,7 @@ namespace System.Globalization // Create the date word array. m_dateWords = new StringList(); } - // Add the ingorable symbol into the ArrayList. + // Add the ignorable symbol into the ArrayList. String temp = IgnorableSymbolChar + text; if (!m_dateWords.Contains(temp)) { @@ -397,7 +398,7 @@ namespace System.Globalization // // Flag used to trace the date patterns (yy/yyyyy/M/MM/MMM/MMM/d/dd) that we have seen. // - enum FoundDatePattern + private enum FoundDatePattern { None = 0x0000, FoundYearPatternFlag = 0x0001, @@ -407,7 +408,7 @@ namespace System.Globalization } // Check if we have found all of the year/month/day pattern. - FoundDatePattern m_ymdFlags = FoundDatePattern.None; + private FoundDatePattern _ymdFlags = FoundDatePattern.None; //////////////////////////////////////////////////////////////////////////// @@ -435,7 +436,7 @@ namespace System.Globalization internal void ScanDateWord(String pattern) { // Check if we have found all of the year/month/day pattern. - m_ymdFlags = FoundDatePattern.None; + _ymdFlags = FoundDatePattern.None; int i = 0; while (i < pattern.Length) @@ -458,11 +459,11 @@ namespace System.Globalization i = AddDateWords(pattern, i + 1, "MMMM"); } } - m_ymdFlags |= FoundDatePattern.FoundMonthPatternFlag; + _ymdFlags |= FoundDatePattern.FoundMonthPatternFlag; break; case 'y': i = ScanRepeatChar(pattern, 'y', i, out chCount); - m_ymdFlags |= FoundDatePattern.FoundYearPatternFlag; + _ymdFlags |= FoundDatePattern.FoundYearPatternFlag; break; case 'd': i = ScanRepeatChar(pattern, 'd', i, out chCount); @@ -470,7 +471,7 @@ namespace System.Globalization { // Only count "d" & "dd". // ddd, dddd are day names. Do not count them. - m_ymdFlags |= FoundDatePattern.FoundDayPatternFlag; + _ymdFlags |= FoundDatePattern.FoundDayPatternFlag; } break; case '\\': @@ -479,21 +480,21 @@ namespace System.Globalization i += 2; break; case '.': - if (m_ymdFlags == FoundDatePattern.FoundYMDPatternFlag) + if (_ymdFlags == FoundDatePattern.FoundYMDPatternFlag) { // If we find a dot immediately after the we have seen all of the y, m, d pattern. // treat it as a ignroable symbol. Check for comments in AddIgnorableSymbols for // more details. AddIgnorableSymbols("."); - m_ymdFlags = FoundDatePattern.None; + _ymdFlags = FoundDatePattern.None; } i++; break; default: - if (m_ymdFlags == FoundDatePattern.FoundYMDPatternFlag && !Char.IsWhiteSpace(ch)) + if (_ymdFlags == FoundDatePattern.FoundYMDPatternFlag && !Char.IsWhiteSpace(ch)) { // We are not seeing "." after YMD. Clear the flag. - m_ymdFlags = FoundDatePattern.None; + _ymdFlags = FoundDatePattern.None; } // We are not in quote. Skip the current character. i++; @@ -508,8 +509,6 @@ namespace System.Globalization // //////////////////////////////////////////////////////////////////////////// - // auto-generated - [System.Security.SecurityCritical] // auto-generated internal String[] GetDateWordsOfDTFI(DateTimeFormatInfo dtfi) { // Enumarate all LongDatePatterns, and get the DateWords and scan for month postfix. diff --git a/src/mscorlib/corefx/System/Globalization/EastAsianLunisolarCalendar.cs b/src/mscorlib/corefx/System/Globalization/EastAsianLunisolarCalendar.cs index 660299a..8f2bbbc 100644 --- a/src/mscorlib/corefx/System/Globalization/EastAsianLunisolarCalendar.cs +++ b/src/mscorlib/corefx/System/Globalization/EastAsianLunisolarCalendar.cs @@ -165,8 +165,6 @@ namespace System.Globalization throw new ArgumentOutOfRangeException("era", SR.ArgumentOutOfRange_InvalidEraValue); } - // Construct an instance of EastAsianLunisolar calendar. - internal EastAsianLunisolarCalendar() { } @@ -253,7 +251,7 @@ namespace System.Globalization return InternalGetDaysInMonth(year, month); } - static int GregorianIsLeapYear(int y) + private static int GregorianIsLeapYear(int y) { return ((((y) % 4) != 0) ? 0 : ((((y) % 100) != 0) ? 1 : ((((y) % 400) != 0) ? 0 : 1))); } diff --git a/src/mscorlib/corefx/System/Globalization/GregorianCalendarHelper.cs b/src/mscorlib/corefx/System/Globalization/GregorianCalendarHelper.cs index 165272b..f595e72 100644 --- a/src/mscorlib/corefx/System/Globalization/GregorianCalendarHelper.cs +++ b/src/mscorlib/corefx/System/Globalization/GregorianCalendarHelper.cs @@ -536,12 +536,12 @@ namespace System.Globalization long ticks = time.Ticks; for (int i = 0; i < m_EraInfo.Length; i++) { - // while calculating dates with JapaneseLuniSolarCalendar, we can run into cases right after the start of the era - // and still belong to the month which is started in previous era. Calculating equivalent calendar date will cause - // using the new era info which will have the year offset equal to the year we are calculating year = m_EraInfo[i].yearOffset + // while calculating dates with JapaneseLuniSolarCalendar, we can run into cases right after the start of the era + // and still belong to the month which is started in previous era. Calculating equivalent calendar date will cause + // using the new era info which will have the year offset equal to the year we are calculating year = m_EraInfo[i].yearOffset // which will end up with zero as calendar year. // We should use the previous era info instead to get the right year number. Example of such date is Feb 2nd 1989 - if (ticks >= m_EraInfo[i].ticks && year > m_EraInfo[i].yearOffset) + if (ticks >= m_EraInfo[i].ticks && year > m_EraInfo[i].yearOffset) { return (year - m_EraInfo[i].yearOffset); } diff --git a/src/mscorlib/corefx/System/Globalization/HebrewCalendar.cs b/src/mscorlib/corefx/System/Globalization/HebrewCalendar.cs index 8ec204e..5fbf2e0 100644 --- a/src/mscorlib/corefx/System/Globalization/HebrewCalendar.cs +++ b/src/mscorlib/corefx/System/Globalization/HebrewCalendar.cs @@ -2,10 +2,6 @@ // 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.Text; using System.Diagnostics.Contracts; @@ -144,7 +140,7 @@ namespace System.Globalization private const int MinHebrewYear = HebrewYearOf1AD + FirstGregorianTableYear; // == 5343 private const int MaxHebrewYear = HebrewYearOf1AD + LastGregorianTableYear; // == 5999 - private static readonly byte[] HebrewTable = { + private static readonly byte[] s_hebrewTable = { 7,3,17,3, // 1583-1584 (Hebrew year: 5343 - 5344) 0,4,11,2,21,6,1,3,13,2, // 1585-1589 25,4,5,3,16,2,27,6,9,1, // 1590-1594 @@ -280,13 +276,13 @@ namespace System.Globalization 6,1 // 2240 (Hebrew year: 6000) }; - const int MaxMonthPlusOne = 14; + private const int MaxMonthPlusOne = 14; // // The lunar calendar has 6 different variations of month lengths // within a year. // - private static readonly byte[] LunarMonthLen = { + private static readonly byte[] s_lunarMonthLen = { 0,00,00,00,00,00,00,00,00,00,00,00,00,0, 0,30,29,29,29,30,29,30,29,30,29,30,29,0, // 3 common year variations 0,30,29,30,29,30,29,30,29,30,29,30,29,0, @@ -296,8 +292,6 @@ namespace System.Globalization 0,30,30,30,29,30,30,29,30,29,30,29,30,29 }; - //internal static Calendar m_defaultInstance; - internal static readonly DateTime calendarMinValue = new DateTime(1583, 1, 1); // Gregorian 2239/9/29 = Hebrew 5999/13/29 (last day in Hebrew year 5999). // We can only format/parse Hebrew numbers up to 999, so we limit the max range to Hebrew year 5999. @@ -323,26 +317,6 @@ namespace System.Globalization } } - /*=================================GetDefaultInstance========================== - **Action: Internal method to provide a default intance of HebrewCalendar. Used by NLS+ implementation - ** and other calendars. - **Returns: - **Arguments: - **Exceptions: - ============================================================================*/ - - /* - internal static Calendar GetDefaultInstance() { - if (m_defaultInstance == null) { - m_defaultInstance = new HebrewCalendar(); - } - return (m_defaultInstance); - } - */ - - - // Construct an instance of gregorian calendar. - public HebrewCalendar() { } @@ -366,7 +340,7 @@ namespace System.Globalization ** We use a table for the Hebrew calendar calculation, so the year supported is limited. ============================================================================*/ - static private void CheckHebrewYearValue(int y, int era, String varName) + private static void CheckHebrewYearValue(int y, int era, String varName) { CheckEraRange(era); if (y > MaxHebrewYear || y < MinHebrewYear) @@ -432,7 +406,7 @@ namespace System.Globalization } } - static internal void CheckEraRange(int era) + internal static void CheckEraRange(int era) { if (era != CurrentEra && era != HebrewEra) { @@ -440,7 +414,7 @@ namespace System.Globalization } } - static private void CheckTicksRange(long ticks) + private static void CheckTicksRange(long ticks) { if (ticks < calendarMinValue.Ticks || ticks > calendarMaxValue.Ticks) { @@ -455,7 +429,7 @@ namespace System.Globalization } } - static internal int GetResult(__DateBuffer result, int part) + internal static int GetResult(__DateBuffer result, int part) { switch (part) { @@ -487,7 +461,7 @@ namespace System.Globalization **Exceptions: ============================================================================*/ - static internal int GetLunarMonthDay(int gregorianYear, __DateBuffer lunarDate) + internal static int GetLunarMonthDay(int gregorianYear, __DateBuffer lunarDate) { // // Get the offset into the LunarMonthLen array and the lunar day @@ -500,10 +474,10 @@ namespace System.Globalization } index *= 2; - lunarDate.day = HebrewTable[index]; + lunarDate.day = s_hebrewTable[index]; // Get the type of the year. The value is from 1 to 6 - int LunarYearType = HebrewTable[index + 1]; + int LunarYearType = s_hebrewTable[index + 1]; // // Get the Lunar Month. @@ -601,7 +575,7 @@ namespace System.Globalization // If the requested date is within the current lunar month, then // we're done. // - if ((NumDays + (long)lunarDate.day) <= (long)(LunarMonthLen[hebrewYearType * MaxMonthPlusOne + lunarDate.month])) + if ((NumDays + (long)lunarDate.day) <= (long)(s_lunarMonthLen[hebrewYearType * MaxMonthPlusOne + lunarDate.month])) { result.day += (int)NumDays; return (GetResult(result, part)); @@ -620,7 +594,7 @@ namespace System.Globalization // Assumes Jan 1 can never translate to the last Lunar month, which // is true. // - NumDays -= (long)(LunarMonthLen[hebrewYearType * MaxMonthPlusOne + lunarDate.month] - lunarDate.day); + NumDays -= (long)(s_lunarMonthLen[hebrewYearType * MaxMonthPlusOne + lunarDate.month] - lunarDate.day); Contract.Assert(NumDays >= 1, "NumDays >= 1"); // If NumDays is 1, then we are done. Otherwise, find the correct Hebrew month @@ -630,24 +604,24 @@ namespace System.Globalization // // See if we're on the correct Lunar month. // - while (NumDays > (long)(LunarMonthLen[hebrewYearType * MaxMonthPlusOne + result.month])) + while (NumDays > (long)(s_lunarMonthLen[hebrewYearType * MaxMonthPlusOne + result.month])) { // // Adjust the number of days and move to the next month. // - NumDays -= (long)(LunarMonthLen[hebrewYearType * MaxMonthPlusOne + result.month++]); + NumDays -= (long)(s_lunarMonthLen[hebrewYearType * MaxMonthPlusOne + result.month++]); // // See if we need to adjust the Year. // Must handle both 12 and 13 month years. // - if ((result.month > 13) || (LunarMonthLen[hebrewYearType * MaxMonthPlusOne + result.month] == 0)) + if ((result.month > 13) || (s_lunarMonthLen[hebrewYearType * MaxMonthPlusOne + result.month] == 0)) { // // Adjust the Year. // result.year++; - hebrewYearType = HebrewTable[(gregorianYear + 1 - FirstGregorianTableYear) * 2 + 1]; + hebrewYearType = s_hebrewTable[(gregorianYear + 1 - FirstGregorianTableYear) * 2 + 1]; // // Adjust the Month. @@ -795,12 +769,12 @@ namespace System.Globalization return ((DayOfWeek)((int)(time.Ticks / TicksPerDay + 1) % 7)); } - static internal int GetHebrewYearType(int year, int era) + internal static int GetHebrewYearType(int year, int era) { CheckHebrewYearValue(year, era, "year"); // The HebrewTable is indexed by Gregorian year and starts from FirstGregorianYear. // So we need to convert year (Hebrew year value) to Gregorian Year below. - return (HebrewTable[(year - HebrewYearOf1AD - FirstGregorianTableYear) * 2 + 1]); + return (s_hebrewTable[(year - HebrewYearOf1AD - FirstGregorianTableYear) * 2 + 1]); } // Returns the day-of-year part of the specified DateTime. The returned value @@ -847,7 +821,7 @@ namespace System.Globalization Contract.Assert(hebrewYearType >= 1 && hebrewYearType <= 6, "hebrewYearType should be from 1 to 6, but now hebrewYearType = " + hebrewYearType + " for hebrew year " + year); - int monthDays = LunarMonthLen[hebrewYearType * MaxMonthPlusOne + month]; + int monthDays = s_lunarMonthLen[hebrewYearType * MaxMonthPlusOne + month]; if (monthDays == 0) { throw new ArgumentOutOfRangeException("month", SR.ArgumentOutOfRange_Month); @@ -987,7 +961,7 @@ namespace System.Globalization } // (month1, day1) - (month2, day2) - static int GetDayDifference(int lunarYearType, int month1, int day1, int month2, int day2) + private static int GetDayDifference(int lunarYearType, int month1, int day1, int month2, int day2) { if (month1 == month2) { @@ -1007,7 +981,7 @@ namespace System.Globalization } // Get the number of days from (month1,day1) to (month1, end of month1) - int days = LunarMonthLen[lunarYearType * MaxMonthPlusOne + month1] - day1; + int days = s_lunarMonthLen[lunarYearType * MaxMonthPlusOne + month1] - day1; // Move to next month. month1++; @@ -1015,7 +989,7 @@ namespace System.Globalization // Add up the days. while (month1 < month2) { - days += LunarMonthLen[lunarYearType * MaxMonthPlusOne + month1++]; + days += s_lunarMonthLen[lunarYearType * MaxMonthPlusOne + month1++]; } days += day2; @@ -1047,7 +1021,7 @@ namespace System.Globalization ============================================================================*/ - static DateTime HebrewToGregorian(int hebrewYear, int hebrewMonth, int hebrewDay, int hour, int minute, int second, int millisecond) + private static DateTime HebrewToGregorian(int hebrewYear, int hebrewMonth, int hebrewDay, int hour, int minute, int second, int millisecond) { // Get the rough Gregorian year for the specified hebrewYear. // diff --git a/src/mscorlib/corefx/System/Globalization/HebrewNumber.cs b/src/mscorlib/corefx/System/Globalization/HebrewNumber.cs index 7ffba2c..8fc264b 100644 --- a/src/mscorlib/corefx/System/Globalization/HebrewNumber.cs +++ b/src/mscorlib/corefx/System/Globalization/HebrewNumber.cs @@ -232,7 +232,7 @@ namespace System.Globalization // //////////////////////////////////////////////////////////////////////////// - enum HebrewToken : short + private enum HebrewToken : short { Invalid = -1, Digit400 = 0, @@ -253,7 +253,7 @@ namespace System.Globalization // //////////////////////////////////////////////////////////////////////////// - struct HebrewValue + private struct HebrewValue { internal HebrewToken token; internal short value; @@ -268,7 +268,7 @@ namespace System.Globalization // Map a Hebrew character from U+05D0 ~ U+05EA to its digit value. // The value is -1 if the Hebrew character does not have a associated value. // - static readonly HebrewValue[] HebrewValues = { + private static readonly HebrewValue[] s_hebrewValues = { new HebrewValue(HebrewToken.Digit1, 1) , // '\x05d0 new HebrewValue(HebrewToken.Digit1, 2) , // '\x05d1 new HebrewValue(HebrewToken.Digit1, 3) , // '\x05d2 @@ -298,8 +298,8 @@ namespace System.Globalization new HebrewValue(HebrewToken.Digit400, 400) , // '\x05ea; }; - const int minHebrewNumberCh = 0x05d0; - static char maxHebrewNumberCh = (char)(minHebrewNumberCh + HebrewValues.Length - 1); + private const int minHebrewNumberCh = 0x05d0; + private static char s_maxHebrewNumberCh = (char)(minHebrewNumberCh + s_hebrewValues.Length - 1); //////////////////////////////////////////////////////////////////////////// // @@ -335,7 +335,7 @@ namespace System.Globalization // // The state machine for Hebrew number pasing. // - readonly static HS[] NumberPasingState = + private readonly static HS[] s_numberPasingState = { // 400 300/200 100 90~10 8~1 6, 7, 9, ' " /* 0 */ @@ -375,7 +375,7 @@ namespace System.Globalization }; // Count of valid HebrewToken, column count in the NumberPasingState array - const int HebrewTokenCount = 10; + private const int HebrewTokenCount = 10; //////////////////////////////////////////////////////////////////////// @@ -398,7 +398,7 @@ namespace System.Globalization internal static HebrewNumberParsingState ParseByChar(char ch, ref HebrewNumberParsingContext context) { - Debug.Assert(NumberPasingState.Length == HebrewTokenCount * ((int)HS.S9_DQ + 1)); + Debug.Assert(s_numberPasingState.Length == HebrewTokenCount * ((int)HS.S9_DQ + 1)); HebrewToken token; if (ch == '\'') @@ -412,14 +412,14 @@ namespace System.Globalization else { int index = (int)ch - minHebrewNumberCh; - if (index >= 0 && index < HebrewValues.Length) + if (index >= 0 && index < s_hebrewValues.Length) { - token = HebrewValues[index].token; + token = s_hebrewValues[index].token; if (token == HebrewToken.Invalid) { return (HebrewNumberParsingState.NotHebrewDigit); } - context.result += HebrewValues[index].value; + context.result += s_hebrewValues[index].value; } else { @@ -427,7 +427,7 @@ namespace System.Globalization return (HebrewNumberParsingState.NotHebrewDigit); } } - context.state = NumberPasingState[(int)context.state * (int)HebrewTokenCount + (int)token]; + context.state = s_numberPasingState[(int)context.state * (int)HebrewTokenCount + (int)token]; if (context.state == HS._err) { // Invalid Hebrew state. This indicates an incorrect Hebrew number. @@ -455,9 +455,9 @@ namespace System.Globalization internal static bool IsDigit(char ch) { - if (ch >= minHebrewNumberCh && ch <= maxHebrewNumberCh) + if (ch >= minHebrewNumberCh && ch <= s_maxHebrewNumberCh) { - return (HebrewValues[ch - minHebrewNumberCh].value >= 0); + return (s_hebrewValues[ch - minHebrewNumberCh].value >= 0); } return (ch == '\'' || ch == '\"'); } diff --git a/src/mscorlib/corefx/System/Globalization/HijriCalendar.cs b/src/mscorlib/corefx/System/Globalization/HijriCalendar.cs index 892116d..72d9ab3 100644 --- a/src/mscorlib/corefx/System/Globalization/HijriCalendar.cs +++ b/src/mscorlib/corefx/System/Globalization/HijriCalendar.cs @@ -60,9 +60,7 @@ namespace System.Globalization internal static readonly int[] HijriMonthDays = { 0, 30, 59, 89, 118, 148, 177, 207, 236, 266, 295, 325, 355 }; - //internal static Calendar m_defaultInstance; - - private int m_HijriAdvance = Int32.MinValue; + private int _hijriAdvance = Int32.MinValue; // DateTime.MaxValue = Hijri calendar (year:9666, month: 4, day: 3). internal const int MaxCalendarYear = 9666; @@ -93,24 +91,6 @@ namespace System.Globalization } } - /*=================================GetDefaultInstance========================== - **Action: Internal method to provide a default intance of HijriCalendar. Used by NLS+ implementation - ** and other calendars. - **Returns: - **Arguments: - **Exceptions: - ============================================================================*/ - /* - internal static Calendar GetDefaultInstance() { - if (m_defaultInstance == null) { - m_defaultInstance = new HijriCalendar(); - } - return (m_defaultInstance); - } - */ - - // Construct an instance of Hijri calendar. - public HijriCalendar() { } @@ -143,7 +123,7 @@ namespace System.Globalization **Exceptions: ============================================================================*/ - long GetAbsoluteDateHijri(int y, int m, int d) + private long GetAbsoluteDateHijri(int y, int m, int d) { return (long)(DaysUpToHijriYear(y) + HijriMonthDays[m - 1] + d - 1 - HijriAdjustment); } @@ -157,7 +137,7 @@ namespace System.Globalization **Notes: ============================================================================*/ - long DaysUpToHijriYear(int HijriYear) + private long DaysUpToHijriYear(int HijriYear) { long NumDays; // number of absolute days int NumYear30; // number of years up to current 30 year cycle @@ -193,15 +173,14 @@ namespace System.Globalization public int HijriAdjustment { - [System.Security.SecuritySafeCritical] // auto-generated get { - if (m_HijriAdvance == Int32.MinValue) + if (_hijriAdvance == Int32.MinValue) { // Never been set before. Use the system value from registry. - m_HijriAdvance = GetHijriDateAdjustment(); + _hijriAdvance = GetHijriDateAdjustment(); } - return (m_HijriAdvance); + return (_hijriAdvance); } set @@ -220,11 +199,11 @@ namespace System.Globalization Contract.EndContractBlock(); VerifyWritable(); - m_HijriAdvance = value; + _hijriAdvance = value; } } - static internal void CheckTicksRange(long ticks) + internal static void CheckTicksRange(long ticks) { if (ticks < calendarMinValue.Ticks || ticks > calendarMaxValue.Ticks) { @@ -238,7 +217,7 @@ namespace System.Globalization } } - static internal void CheckEraRange(int era) + internal static void CheckEraRange(int era) { if (era != CurrentEra && era != HijriEra) { @@ -246,7 +225,7 @@ namespace System.Globalization } } - static internal void CheckYearRange(int year, int era) + internal static void CheckYearRange(int year, int era) { CheckEraRange(era); if (year < 1 || year > MaxCalendarYear) @@ -261,7 +240,7 @@ namespace System.Globalization } } - static internal void CheckYearMonthRange(int year, int month, int era) + internal static void CheckYearMonthRange(int year, int month, int era) { CheckYearRange(year, era); if (year == MaxCalendarYear) diff --git a/src/mscorlib/corefx/System/Globalization/JapaneseCalendar.cs b/src/mscorlib/corefx/System/Globalization/JapaneseCalendar.cs index 5dee4f1..4130801 100644 --- a/src/mscorlib/corefx/System/Globalization/JapaneseCalendar.cs +++ b/src/mscorlib/corefx/System/Globalization/JapaneseCalendar.cs @@ -71,7 +71,7 @@ namespace System.Globalization // // Using a field initializer rather than a static constructor so that the whole class can be lazy // init. - static internal volatile EraInfo[] japaneseEraInfo; + internal static volatile EraInfo[] japaneseEraInfo; // // Read our era info diff --git a/src/mscorlib/corefx/System/Globalization/JapaneseLunisolarCalendar.cs b/src/mscorlib/corefx/System/Globalization/JapaneseLunisolarCalendar.cs index ee30e07..ecdaced 100644 --- a/src/mscorlib/corefx/System/Globalization/JapaneseLunisolarCalendar.cs +++ b/src/mscorlib/corefx/System/Globalization/JapaneseLunisolarCalendar.cs @@ -70,7 +70,7 @@ namespace System.Globalization } } - static readonly int[,] yinfo = + private static readonly int[,] s_yinfo = { /*Y LM Lmon Lday DaysPerMonth D1 D2 D3 D4 D5 D6 D7 D8 D9 D10 D11 D12 D13 #Days 1960 */ @@ -220,7 +220,7 @@ namespace System.Globalization } Contract.EndContractBlock(); - return yinfo[LunarYear - MIN_LUNISOLAR_YEAR, Index]; + return s_yinfo[LunarYear - MIN_LUNISOLAR_YEAR, Index]; } internal override int GetYear(int year, DateTime time) diff --git a/src/mscorlib/corefx/System/Globalization/JulianCalendar.cs b/src/mscorlib/corefx/System/Globalization/JulianCalendar.cs index a74a80c..6721899 100644 --- a/src/mscorlib/corefx/System/Globalization/JulianCalendar.cs +++ b/src/mscorlib/corefx/System/Globalization/JulianCalendar.cs @@ -34,14 +34,12 @@ namespace System.Globalization // Number of days in 4 years private const int JulianDaysPer4Years = JulianDaysPerYear * 4 + 1; - //internal static Calendar m_defaultInstance; - - private static readonly int[] DaysToMonth365 = + private static readonly int[] s_daysToMonth365 = { 0, 31, 59, 90, 120, 151, 181, 212, 243, 273, 304, 334, 365 }; - private static readonly int[] DaysToMonth366 = + private static readonly int[] s_daysToMonth366 = { 0, 31, 60, 91, 121, 152, 182, 213, 244, 274, 305, 335, 366 }; @@ -81,24 +79,6 @@ namespace System.Globalization // } //} - /*=================================GetDefaultInstance========================== - **Action: Internal method to provide a default intance of JulianCalendar. Used by NLS+ implementation - ** and other calendars. - **Returns: - **Arguments: - **Exceptions: - ============================================================================*/ - /* - internal static Calendar GetDefaultInstance() { - if (m_defaultInstance == null) { - m_defaultInstance = new JulianCalendar(); - } - return (m_defaultInstance); - } - */ - - // Construct an instance of gregorian calendar. - public JulianCalendar() { // There is no system setting of TwoDigitYear max, so set the value here. @@ -113,7 +93,7 @@ namespace System.Globalization } } - static internal void CheckEraRange(int era) + internal static void CheckEraRange(int era) { if (era != CurrentEra && era != JulianEra) { @@ -136,7 +116,7 @@ namespace System.Globalization } } - static internal void CheckMonthRange(int month) + internal static void CheckMonthRange(int month) { if (month < 1 || month > 12) { @@ -144,7 +124,7 @@ namespace System.Globalization } } - /*=================================GetDefaultInstance========================== + /*===================================CheckDayRange============================ **Action: Check for if the day value is valid. **Returns: **Arguments: @@ -154,7 +134,7 @@ namespace System.Globalization ** sure year/month values are correct. ============================================================================*/ - static internal void CheckDayRange(int year, int month, int day) + internal static void CheckDayRange(int year, int month, int day) { if (year == 1 && month == 1) { @@ -166,7 +146,7 @@ namespace System.Globalization } } bool isLeapYear = (year % 4) == 0; - int[] days = isLeapYear ? DaysToMonth366 : DaysToMonth365; + int[] days = isLeapYear ? s_daysToMonth366 : s_daysToMonth365; int monthDays = days[month] - days[month - 1]; if (day < 1 || day > monthDays) { @@ -183,7 +163,7 @@ namespace System.Globalization // Returns a given date part of this DateTime. This method is used // to compute the year, day-of-year, month, or day part. - static internal int GetDatePart(long ticks, int part) + internal static int GetDatePart(long ticks, int part) { // Gregorian 1/1/0001 is Julian 1/3/0001. Remember DateTime(0) is refered to Gregorian 1/1/0001. // The following line convert Gregorian ticks to Julian ticks. @@ -213,7 +193,7 @@ namespace System.Globalization // Leap year calculation looks different from IsLeapYear since y1, y4, // and y100 are relative to year 1, not year 0 bool leapYear = (y1 == 3); - int[] days = leapYear ? DaysToMonth366 : DaysToMonth365; + int[] days = leapYear ? s_daysToMonth366 : s_daysToMonth365; // All months have less than 32 days, so n >> 5 is a good conservative // estimate for the month int m = n >> 5 + 1; @@ -226,9 +206,9 @@ namespace System.Globalization } // Returns the tick count corresponding to the given year, month, and day. - static internal long DateToTicks(int year, int month, int day) + internal static long DateToTicks(int year, int month, int day) { - int[] days = (year % 4 == 0) ? DaysToMonth366 : DaysToMonth365; + int[] days = (year % 4 == 0) ? s_daysToMonth366 : s_daysToMonth365; int y = year - 1; int n = y * 365 + y / 4 + days[month - 1] + day - 1; // Gregorian 1/1/0001 is Julian 1/3/0001. n * TicksPerDay is the ticks in JulianCalendar. @@ -265,7 +245,7 @@ namespace System.Globalization m = 12 + (i + 1) % 12; y = y + (i - 11) / 12; } - int[] daysArray = (y % 4 == 0 && (y % 100 != 0 || y % 400 == 0)) ? DaysToMonth366 : DaysToMonth365; + int[] daysArray = (y % 4 == 0 && (y % 100 != 0 || y % 400 == 0)) ? s_daysToMonth366 : s_daysToMonth365; int days = (daysArray[m] - daysArray[m - 1]); if (d > days) @@ -306,7 +286,7 @@ namespace System.Globalization { CheckYearEraRange(year, era); CheckMonthRange(month); - int[] days = (year % 4 == 0) ? DaysToMonth366 : DaysToMonth365; + int[] days = (year % 4 == 0) ? s_daysToMonth366 : s_daysToMonth365; return (days[month] - days[month - 1]); } diff --git a/src/mscorlib/corefx/System/Globalization/KoreanCalendar.cs b/src/mscorlib/corefx/System/Globalization/KoreanCalendar.cs index 63f67ab..38a0b41 100644 --- a/src/mscorlib/corefx/System/Globalization/KoreanCalendar.cs +++ b/src/mscorlib/corefx/System/Globalization/KoreanCalendar.cs @@ -44,7 +44,7 @@ namespace System.Globalization //m_EraInfo[0] = new EraInfo(1, new DateTime(1, 1, 1).Ticks, -2333, 2334, GregorianCalendar.MaxYear + 2333); // Initialize our era info. - static internal EraInfo[] koreanEraInfo = new EraInfo[] { + internal static EraInfo[] koreanEraInfo = new EraInfo[] { new EraInfo( 1, 1, 1, 1, -2333, 2334, GregorianCalendar.MaxYear + 2333) // era #, start year/month/day, yearOffset, minEraYear }; @@ -69,23 +69,6 @@ namespace System.Globalization } } - /*=================================GetDefaultInstance========================== - **Action: Internal method to provide a default intance of KoreanCalendar. Used by NLS+ implementation - ** and other calendars. - **Returns: - **Arguments: - **Exceptions: - ============================================================================*/ - /* - internal static Calendar GetDefaultInstance() { - if (m_defaultInstance == null) { - m_defaultInstance = new KoreanCalendar(); - } - return (m_defaultInstance); - } - */ - - public KoreanCalendar() { try diff --git a/src/mscorlib/corefx/System/Globalization/KoreanLunisolarCalendar.cs b/src/mscorlib/corefx/System/Globalization/KoreanLunisolarCalendar.cs index bbc03ee..68c4fab 100644 --- a/src/mscorlib/corefx/System/Globalization/KoreanLunisolarCalendar.cs +++ b/src/mscorlib/corefx/System/Globalization/KoreanLunisolarCalendar.cs @@ -29,8 +29,6 @@ namespace System.Globalization public const int GregorianEra = 1; - //internal static Calendar m_defaultInstance; - internal const int MIN_LUNISOLAR_YEAR = 918; internal const int MAX_LUNISOLAR_YEAR = 2050; @@ -73,7 +71,7 @@ namespace System.Globalization } } - static readonly int[,] yinfo = + private static readonly int[,] s_yinfo = { /*Y LM Lmon Lday DaysPerMonth D1 D2 D3 D4 D5 D6 D7 D8 D9 D10 D11 D12 D13 #Days 918 */ @@ -1266,7 +1264,7 @@ namespace System.Globalization MAX_LUNISOLAR_YEAR)); } Contract.EndContractBlock(); - return yinfo[LunarYear - MIN_LUNISOLAR_YEAR, Index]; + return s_yinfo[LunarYear - MIN_LUNISOLAR_YEAR, Index]; } internal override int GetYear(int year, DateTime time) @@ -1292,31 +1290,10 @@ namespace System.Globalization return year; } - /*=================================GetDefaultInstance========================== - **Action: Internal method to provide a default intance of KoreanLunisolarCalendar. Used by NLS+ implementation - ** and other calendars. - **Returns: - **Arguments: - **Exceptions: - ============================================================================*/ - /* - internal static Calendar GetDefaultInstance() - { - if (m_defaultInstance == null) { - m_defaultInstance = new KoreanLunisolarCalendar(); - } - return (m_defaultInstance); - } - */ - - // Construct an instance of KoreanLunisolar calendar. - public KoreanLunisolarCalendar() { } - - public override int GetEra(DateTime time) { CheckTicksRange(time.Ticks); diff --git a/src/mscorlib/corefx/System/Globalization/NumberFormatInfo.cs b/src/mscorlib/corefx/System/Globalization/NumberFormatInfo.cs index 77287f5..6a25eb2 100644 --- a/src/mscorlib/corefx/System/Globalization/NumberFormatInfo.cs +++ b/src/mscorlib/corefx/System/Globalization/NumberFormatInfo.cs @@ -46,7 +46,7 @@ namespace System.Globalization sealed public partial class NumberFormatInfo : IFormatProvider, ICloneable { // invariantInfo is constant irrespective of your current culture. - private static volatile NumberFormatInfo invariantInfo; + private static volatile NumberFormatInfo s_invariantInfo; // READTHIS READTHIS READTHIS // This class has an exact mapping onto a native structure defined in COMNumber.cpp @@ -105,7 +105,7 @@ namespace System.Globalization [OnDeserialized] private void OnDeserialized(StreamingContext ctx) { } - static private void VerifyDecimalSeparator(String decSep, String propertyName) + private static void VerifyDecimalSeparator(String decSep, String propertyName) { if (decSep == null) { @@ -120,7 +120,7 @@ namespace System.Globalization Contract.EndContractBlock(); } - static private void VerifyGroupSeparator(String groupSep, String propertyName) + private static void VerifyGroupSeparator(String groupSep, String propertyName) { if (groupSep == null) { @@ -131,7 +131,6 @@ namespace System.Globalization } - [System.Security.SecuritySafeCritical] // auto-generated internal NumberFormatInfo(CultureData cultureData) { if (cultureData != null) @@ -167,19 +166,18 @@ namespace System.Globalization { get { - if (invariantInfo == null) + if (s_invariantInfo == null) { // Lazy create the invariant info. This cannot be done in a .cctor because exceptions can // be thrown out of a .cctor stack that will need this. NumberFormatInfo nfi = new NumberFormatInfo(); nfi.m_isInvariant = true; - invariantInfo = ReadOnly(nfi); + s_invariantInfo = ReadOnly(nfi); } - return invariantInfo; + return s_invariantInfo; } } - public static NumberFormatInfo GetInstance(IFormatProvider formatProvider) { // Fast case for a regular CultureInfo @@ -272,7 +270,7 @@ namespace System.Globalization // Every element in the groupSize array should be between 1 and 9 // excpet the last element could be zero. // - static internal void CheckGroupSize(String propName, int[] groupSize) + internal static void CheckGroupSize(String propName, int[] groupSize) { for (int i = 0; i < groupSize.Length; i++) { diff --git a/src/mscorlib/corefx/System/Globalization/PersianCalendar.cs b/src/mscorlib/corefx/System/Globalization/PersianCalendar.cs index 6e34f90..57bef7e 100644 --- a/src/mscorlib/corefx/System/Globalization/PersianCalendar.cs +++ b/src/mscorlib/corefx/System/Globalization/PersianCalendar.cs @@ -30,7 +30,7 @@ namespace System.Globalization public static readonly int PersianEra = 1; internal static long PersianEpoch = new DateTime(622, 3, 22).Ticks / GregorianCalendar.TicksPerDay; - const int ApproximateHalfYear = 180; + private const int ApproximateHalfYear = 180; internal const int DatePartYear = 0; internal const int DatePartDayOfYear = 1; @@ -49,24 +49,6 @@ namespace System.Globalization internal static DateTime minDate = new DateTime(622, 3, 22); internal static DateTime maxDate = DateTime.MaxValue; - /*=================================GetDefaultInstance========================== - **Action: Internal method to provide a default intance of PersianCalendar. Used by NLS+ implementation - ** and other calendars. - **Returns: - **Arguments: - **Exceptions: - ============================================================================*/ - /* - internal static Calendar GetDefaultInstance() { - if (m_defaultInstance == null) { - m_defaultInstance = new PersianCalendar(); - } - return (m_defaultInstance); - } - */ - - - public override DateTime MinSupportedDateTime { get @@ -75,7 +57,6 @@ namespace System.Globalization } } - public override DateTime MaxSupportedDateTime { get @@ -126,7 +107,7 @@ namespace System.Globalization **Exceptions: ============================================================================*/ - long GetAbsoluteDatePersian(int year, int month, int day) + private long GetAbsoluteDatePersian(int year, int month, int day) { if (year >= 1 && year <= MaxCalendarYear && month >= 1 && month <= 12) { @@ -139,8 +120,10 @@ namespace System.Globalization throw new ArgumentOutOfRangeException(null, SR.ArgumentOutOfRange_BadYearMonthDay); } - static internal void CheckTicksRange(long ticks) { - if (ticks < minDate.Ticks || ticks > maxDate.Ticks) { + internal static void CheckTicksRange(long ticks) + { + if (ticks < minDate.Ticks || ticks > maxDate.Ticks) + { throw new ArgumentOutOfRangeException( "time", String.Format( @@ -151,7 +134,7 @@ namespace System.Globalization } } - static internal void CheckEraRange(int era) + internal static void CheckEraRange(int era) { if (era != CurrentEra && era != PersianEra) { @@ -159,7 +142,7 @@ namespace System.Globalization } } - static internal void CheckYearRange(int year, int era) + internal static void CheckYearRange(int year, int era) { CheckEraRange(era); if (year < 1 || year > MaxCalendarYear) @@ -174,7 +157,7 @@ namespace System.Globalization } } - static internal void CheckYearMonthRange(int year, int month, int era) + internal static void CheckYearMonthRange(int year, int month, int era) { CheckYearRange(year, era); if (year == MaxCalendarYear) @@ -197,7 +180,7 @@ namespace System.Globalization } } - static int MonthFromOrdinalDay(int ordinalDay) + private static int MonthFromOrdinalDay(int ordinalDay) { Contract.Assert(ordinalDay <= 366); int index = 0; @@ -207,7 +190,7 @@ namespace System.Globalization return index; } - static int DaysInPreviousMonths(int month) + private static int DaysInPreviousMonths(int month) { Contract.Assert(1 <= month && month <= 12); --month; // months are one based but for calculations use 0 based @@ -222,7 +205,7 @@ namespace System.Globalization **Exceptions: ArgumentException if part is incorrect. ============================================================================*/ - internal int GetDatePart(long ticks, int part) + internal int GetDatePart(long ticks, int part) { long NumDays; // The calculation buffer in number of days. @@ -413,7 +396,7 @@ namespace System.Globalization // Returns the number of days in the year given by the year argument for the current era. // - public override int GetDaysInYear(int year, int era) + public override int GetDaysInYear(int year, int era) { CheckYearRange(year, era); if (year == MaxCalendarYear) @@ -524,7 +507,7 @@ namespace System.Globalization // year is a leap year, or false if not. // - public override bool IsLeapYear(int year, int era) + public override bool IsLeapYear(int year, int era) { CheckYearRange(year, era); @@ -544,7 +527,7 @@ namespace System.Globalization { // The year/month/era checking is done in GetDaysInMonth(). int daysInMonth = GetDaysInMonth(year, month, era); - if (day < 1 || day > daysInMonth) + if (day < 1 || day > daysInMonth) { // BCLDebug.Log("year = " + year + ", month = " + month + ", day = " + day); throw new ArgumentOutOfRangeException( @@ -570,11 +553,11 @@ namespace System.Globalization private const int DEFAULT_TWO_DIGIT_YEAR_MAX = 1410; - public override int TwoDigitYearMax + public override int TwoDigitYearMax { - get + get { - if (twoDigitYearMax == -1) + if (twoDigitYearMax == -1) { twoDigitYearMax = GetSystemTwoDigitYearSetting(ID, DEFAULT_TWO_DIGIT_YEAR_MAX); } diff --git a/src/mscorlib/corefx/System/Globalization/RegionInfo.cs b/src/mscorlib/corefx/System/Globalization/RegionInfo.cs index 2945543..0669349 100644 --- a/src/mscorlib/corefx/System/Globalization/RegionInfo.cs +++ b/src/mscorlib/corefx/System/Globalization/RegionInfo.cs @@ -2,10 +2,8 @@ // The .NET Foundation licenses this file to you under the MIT license. // See the LICENSE file in the project root for more information. - //////////////////////////////////////////////////////////////////////////// // -// Class: RegionInfo // // Purpose: This class represents settings specified by de jure or // de facto standards for a particular country/region. In @@ -13,7 +11,6 @@ // preferences of the user and does not depend on the user's // language or culture. // -// Date: March 31, 1999 // //////////////////////////////////////////////////////////////////////////// @@ -38,12 +35,12 @@ namespace System.Globalization // // Name of this region (ie: es-US): serialized, the field used for deserialization // - internal String m_name; + internal String _name; // // The CultureData instance that we are going to read data from. // - internal CultureData m_cultureData; + internal CultureData _cultureData; // // The RegionInfo for our current region @@ -61,7 +58,6 @@ namespace System.Globalization // In Silverlight we enforce that RegionInfos must be created with a full culture name // //////////////////////////////////////////////////////////////////////// - [System.Security.SecuritySafeCritical] // auto-generated public RegionInfo(String name) { if (name == null) @@ -77,8 +73,8 @@ namespace System.Globalization // // For CoreCLR we only want the region names that are full culture names // - this.m_cultureData = CultureData.GetCultureDataForRegion(name, true); - if (this.m_cultureData == null) + _cultureData = CultureData.GetCultureDataForRegion(name, true); + if (_cultureData == null) throw new ArgumentException( String.Format( CultureInfo.CurrentCulture, @@ -86,24 +82,22 @@ namespace System.Globalization // Not supposed to be neutral - if (this.m_cultureData.IsNeutralCulture) + if (_cultureData.IsNeutralCulture) throw new ArgumentException(SR.Format(SR.Argument_InvalidNeutralRegionName, name), "name"); SetName(name); } - [System.Security.SecuritySafeCritical] // auto-generated internal RegionInfo(CultureData cultureData) { - this.m_cultureData = cultureData; - this.m_name = this.m_cultureData.SREGIONNAME; + _cultureData = cultureData; + _name = _cultureData.SREGIONNAME; } - [System.Security.SecurityCritical] // auto-generated private void SetName(string name) { // Use the name of the region we found - this.m_name = this.m_cultureData.SREGIONNAME; + _name = _cultureData.SREGIONNAME; } [OnSerializing] @@ -113,16 +107,16 @@ namespace System.Globalization [OnDeserialized] private void OnDeserialized(StreamingContext ctx) { - m_cultureData = CultureData.GetCultureData(m_name, true); + _cultureData = CultureData.GetCultureData(_name, true); - if (m_cultureData == null) + if (_cultureData == null) { throw new ArgumentException( - String.Format(CultureInfo.CurrentCulture, SR.Argument_InvalidCultureName, m_name), - "m_name"); + String.Format(CultureInfo.CurrentCulture, SR.Argument_InvalidCultureName, _name), + "_name"); } - m_name = this.m_cultureData.SREGIONNAME; + _name = _cultureData.SREGIONNAME; } //////////////////////////////////////////////////////////////////////// @@ -136,7 +130,6 @@ namespace System.Globalization //////////////////////////////////////////////////////////////////////// public static RegionInfo CurrentRegion { - [System.Security.SecuritySafeCritical] // auto-generated get { RegionInfo temp = s_currentRegionInfo; @@ -145,7 +138,7 @@ namespace System.Globalization temp = new RegionInfo(CultureInfo.CurrentCulture.m_cultureData); // Need full name for custom cultures - temp.m_name = temp.m_cultureData.SREGIONNAME; + temp._name = temp._cultureData.SREGIONNAME; s_currentRegionInfo = temp; } return temp; @@ -163,8 +156,8 @@ namespace System.Globalization { get { - Contract.Assert(m_name != null, "Expected RegionInfo.m_name to be populated already"); - return (m_name); + Contract.Assert(_name != null, "Expected RegionInfo._name to be populated already"); + return (_name); } } @@ -177,10 +170,9 @@ namespace System.Globalization //////////////////////////////////////////////////////////////////////// public virtual String EnglishName { - [System.Security.SecuritySafeCritical] // auto-generated get { - return (this.m_cultureData.SENGCOUNTRY); + return (_cultureData.SENGCOUNTRY); } } @@ -195,10 +187,9 @@ namespace System.Globalization //////////////////////////////////////////////////////////////////////// public virtual String DisplayName { - [System.Security.SecuritySafeCritical] // auto-generated get { - return (this.m_cultureData.SLOCALIZEDCOUNTRY); + return (_cultureData.SLOCALIZEDCOUNTRY); } } @@ -214,10 +205,9 @@ namespace System.Globalization [System.Runtime.InteropServices.ComVisible(false)] public virtual String NativeName { - [System.Security.SecuritySafeCritical] // auto-generated get { - return (this.m_cultureData.SNATIVECOUNTRY); + return (_cultureData.SNATIVECOUNTRY); } } @@ -230,10 +220,9 @@ namespace System.Globalization //////////////////////////////////////////////////////////////////////// public virtual String TwoLetterISORegionName { - [System.Security.SecuritySafeCritical] // auto-generated get { - return (this.m_cultureData.SISO3166CTRYNAME); + return (_cultureData.SISO3166CTRYNAME); } } @@ -248,7 +237,7 @@ namespace System.Globalization { get { - int value = this.m_cultureData.IMEASURE; + int value = _cultureData.IMEASURE; return (value == 0); } } @@ -262,10 +251,9 @@ namespace System.Globalization //////////////////////////////////////////////////////////////////////// public virtual String CurrencySymbol { - [System.Security.SecuritySafeCritical] // auto-generated get { - return (this.m_cultureData.SCURRENCY); + return (_cultureData.SCURRENCY); } } @@ -278,10 +266,9 @@ namespace System.Globalization //////////////////////////////////////////////////////////////////////// public virtual String ISOCurrencySymbol { - [System.Security.SecuritySafeCritical] // auto-generated get { - return (this.m_cultureData.SINTLSYMBOL); + return (_cultureData.SINTLSYMBOL); } } diff --git a/src/mscorlib/corefx/System/Globalization/StringInfo.cs b/src/mscorlib/corefx/System/Globalization/StringInfo.cs index 1b94426..102f703 100644 --- a/src/mscorlib/corefx/System/Globalization/StringInfo.cs +++ b/src/mscorlib/corefx/System/Globalization/StringInfo.cs @@ -2,19 +2,13 @@ // The .NET Foundation licenses this file to you under the MIT license. // See the LICENSE file in the project root for more information. -// - -// - //////////////////////////////////////////////////////////////////////////// // -// Class: StringInfo // // Purpose: This class defines behaviors specific to a writing system. // A writing system is the collection of scripts and // orthographic rules required to represent a language as text. // -// Date: March 31, 1999 // //////////////////////////////////////////////////////////////////////////// @@ -29,10 +23,10 @@ namespace System.Globalization public partial class StringInfo { [OptionalField(VersionAdded = 2)] - private String m_str; + private String _str; [NonSerialized] - private int[] m_indexes; + private int[] _indexes; // Legacy constructor public StringInfo() : this("") { } @@ -46,15 +40,15 @@ namespace System.Globalization [OnDeserializing] private void OnDeserializing(StreamingContext ctx) { - m_str = String.Empty; + _str = String.Empty; } [OnDeserialized] private void OnDeserialized(StreamingContext ctx) { - if (m_str.Length == 0) + if (_str.Length == 0) { - m_indexes = null; + _indexes = null; } } @@ -64,7 +58,7 @@ namespace System.Globalization StringInfo that = value as StringInfo; if (that != null) { - return (this.m_str.Equals(that.m_str)); + return (_str.Equals(that._str)); } return (false); } @@ -72,7 +66,7 @@ namespace System.Globalization [System.Runtime.InteropServices.ComVisible(false)] public override int GetHashCode() { - return this.m_str.GetHashCode(); + return _str.GetHashCode(); } @@ -82,12 +76,12 @@ namespace System.Globalization { get { - if ((null == this.m_indexes) && (0 < this.String.Length)) + if ((null == _indexes) && (0 < this.String.Length)) { - this.m_indexes = StringInfo.ParseCombiningCharacters(this.String); + _indexes = StringInfo.ParseCombiningCharacters(this.String); } - return (this.m_indexes); + return (_indexes); } } @@ -95,7 +89,7 @@ namespace System.Globalization { get { - return (this.m_str); + return (_str); } set { @@ -106,8 +100,8 @@ namespace System.Globalization } Contract.EndContractBlock(); - this.m_str = value; - this.m_indexes = null; + _str = value; + _indexes = null; } } diff --git a/src/mscorlib/corefx/System/Globalization/TaiwanCalendar.cs b/src/mscorlib/corefx/System/Globalization/TaiwanCalendar.cs index e7f44df..89b2e4a 100644 --- a/src/mscorlib/corefx/System/Globalization/TaiwanCalendar.cs +++ b/src/mscorlib/corefx/System/Globalization/TaiwanCalendar.cs @@ -37,7 +37,7 @@ namespace System.Globalization //m_EraInfo[0] = new EraInfo(1, new DateTime(1912, 1, 1).Ticks, 1911, 1, GregorianCalendar.MaxYear - 1911); // Initialize our era info. - static internal EraInfo[] taiwanEraInfo = new EraInfo[] { + internal static EraInfo[] taiwanEraInfo = new EraInfo[] { new EraInfo( 1, 1912, 1, 1, 1911, 1, GregorianCalendar.MaxYear - 1911) // era #, start year/month/day, yearOffset, minEraYear }; diff --git a/src/mscorlib/corefx/System/Globalization/TaiwanLunisolarCalendar.cs b/src/mscorlib/corefx/System/Globalization/TaiwanLunisolarCalendar.cs index ebe601a..42b7f24 100644 --- a/src/mscorlib/corefx/System/Globalization/TaiwanLunisolarCalendar.cs +++ b/src/mscorlib/corefx/System/Globalization/TaiwanLunisolarCalendar.cs @@ -31,7 +31,7 @@ namespace System.Globalization //m_EraInfo[0] = new EraInfo(1, new DateTime(1912, 1, 1).Ticks, 1911, 1, GregorianCalendar.MaxYear - 1911); // Initialize our era info. - static internal EraInfo[] taiwanLunisolarEraInfo = new EraInfo[] { + internal static EraInfo[] taiwanLunisolarEraInfo = new EraInfo[] { new EraInfo( 1, 1912, 1, 1, 1911, 1, GregorianCalendar.MaxYear - 1911) // era #, start year/month/day, yearOffset, minEraYear }; @@ -78,7 +78,7 @@ namespace System.Globalization } } - static readonly int[,] yinfo = + private static readonly int[,] s_yinfo = { /*Y LM Lmon Lday DaysPerMonth D1 D2 D3 D4 D5 D6 D7 D8 D9 D10 D11 D12 D13 #Days 1912 */ @@ -278,7 +278,7 @@ namespace System.Globalization } Contract.EndContractBlock(); - return yinfo[LunarYear - MIN_LUNISOLAR_YEAR, Index]; + return s_yinfo[LunarYear - MIN_LUNISOLAR_YEAR, Index]; } internal override int GetYear(int year, DateTime time) @@ -291,32 +291,11 @@ namespace System.Globalization return helper.GetGregorianYear(year, era); } - /*=================================GetDefaultInstance========================== - **Action: Internal method to provide a default intance of TaiwanLunisolarCalendar. Used by NLS+ implementation - ** and other calendars. - **Returns: - **Arguments: - **Exceptions: - ============================================================================*/ - /* - internal static Calendar GetDefaultInstance() - { - if (m_defaultInstance == null) { - m_defaultInstance = new TaiwanLunisolarCalendar(); - } - return (m_defaultInstance); - } - */ - - // Construct an instance of TaiwanLunisolar calendar. - public TaiwanLunisolarCalendar() { helper = new GregorianCalendarHelper(this, taiwanLunisolarEraInfo); } - - public override int GetEra(DateTime time) { return (helper.GetEra(time)); diff --git a/src/mscorlib/corefx/System/Globalization/TextElementEnumerator.cs b/src/mscorlib/corefx/System/Globalization/TextElementEnumerator.cs index 996aed9..487ef11 100644 --- a/src/mscorlib/corefx/System/Globalization/TextElementEnumerator.cs +++ b/src/mscorlib/corefx/System/Globalization/TextElementEnumerator.cs @@ -2,17 +2,11 @@ // The .NET Foundation licenses this file to you under the MIT license. // See the LICENSE file in the project root for more information. -// - -// - //////////////////////////////////////////////////////////////////////////// // -// Class: TextElementEnumerator // // Purpose: // -// Date: March 31, 1999 // //////////////////////////////////////////////////////////////////////////// @@ -30,73 +24,73 @@ namespace System.Globalization [System.Runtime.InteropServices.ComVisible(true)] public class TextElementEnumerator : IEnumerator { - private String str; - private int index; - private int startIndex; + private String _str; + private int _index; + private int _startIndex; [NonSerialized] - private int strLen; // This is the length of the total string, counting from the beginning of string. + private int _strLen; // This is the length of the total string, counting from the beginning of string. [NonSerialized] - private int currTextElementLen; // The current text element lenght after MoveNext() is called. + private int _currTextElementLen; // The current text element lenght after MoveNext() is called. [OptionalField(VersionAdded = 2)] - private UnicodeCategory uc; + private UnicodeCategory _uc; [OptionalField(VersionAdded = 2)] - private int charLen; // The next abstract char to look at after MoveNext() is called. It could be 1 or 2, depending on if it is a surrogate or not. + private int _charLen; // The next abstract char to look at after MoveNext() is called. It could be 1 or 2, depending on if it is a surrogate or not. internal TextElementEnumerator(String str, int startIndex, int strLen) { Contract.Assert(str != null, "TextElementEnumerator(): str != null"); Contract.Assert(startIndex >= 0 && strLen >= 0, "TextElementEnumerator(): startIndex >= 0 && strLen >= 0"); Contract.Assert(strLen >= startIndex, "TextElementEnumerator(): strLen >= startIndex"); - this.str = str; - this.startIndex = startIndex; - this.strLen = strLen; + _str = str; + _startIndex = startIndex; + _strLen = strLen; Reset(); } // the following fields is defined to keep the compatibility with Everett. // don't change/remove the names/types of these fields. - private int endIndex; - private int nextTextElementLen; + private int _endIndex; + private int _nextTextElementLen; [OnDeserializing] private void OnDeserializing(StreamingContext ctx) { - charLen = -1; + _charLen = -1; } [OnDeserialized] private void OnDeserialized(StreamingContext ctx) { - strLen = endIndex + 1; - currTextElementLen = nextTextElementLen; + _strLen = _endIndex + 1; + _currTextElementLen = _nextTextElementLen; - if (charLen == -1) + if (_charLen == -1) { - uc = CharUnicodeInfo.InternalGetUnicodeCategory(str, index, out charLen); + _uc = CharUnicodeInfo.InternalGetUnicodeCategory(_str, _index, out _charLen); } } [OnSerializing] private void OnSerializing(StreamingContext ctx) { - endIndex = strLen - 1; - nextTextElementLen = currTextElementLen; + _endIndex = _strLen - 1; + _nextTextElementLen = _currTextElementLen; } public bool MoveNext() { - if (index >= strLen) + if (_index >= _strLen) { - // Make the index to be greater than strLen so that we can throw exception if GetTextElement() is called. - index = strLen + 1; + // Make the _index to be greater than _strLen so that we can throw exception if GetTextElement() is called. + _index = _strLen + 1; return (false); } - currTextElementLen = StringInfo.GetCurrentTextElementLen(str, index, strLen, ref uc, ref charLen); - index += currTextElementLen; + _currTextElementLen = StringInfo.GetCurrentTextElementLen(_str, _index, _strLen, ref _uc, ref _charLen); + _index += _currTextElementLen; return (true); } @@ -118,42 +112,42 @@ namespace System.Globalization public String GetTextElement() { - if (index == startIndex) + if (_index == _startIndex) { throw new InvalidOperationException(SR.InvalidOperation_EnumNotStarted); } - if (index > strLen) + if (_index > _strLen) { throw new InvalidOperationException(SR.InvalidOperation_EnumEnded); } - return (str.Substring(index - currTextElementLen, currTextElementLen)); + return (_str.Substring(_index - _currTextElementLen, _currTextElementLen)); } // - // Get the starting index of the current text element. + // Get the starting _index of the current text element. // public int ElementIndex { get { - if (index == startIndex) + if (_index == _startIndex) { throw new InvalidOperationException(SR.InvalidOperation_EnumNotStarted); } - return (index - currTextElementLen); + return (_index - _currTextElementLen); } } public void Reset() { - index = startIndex; - if (index < strLen) + _index = _startIndex; + if (_index < _strLen) { // If we have more than 1 character, get the category of the current char. - uc = CharUnicodeInfo.InternalGetUnicodeCategory(str, index, out charLen); + _uc = CharUnicodeInfo.InternalGetUnicodeCategory(_str, _index, out _charLen); } } } diff --git a/src/mscorlib/corefx/System/Globalization/TextInfo.Unix.cs b/src/mscorlib/corefx/System/Globalization/TextInfo.Unix.cs index 03a28b3..bededed 100644 --- a/src/mscorlib/corefx/System/Globalization/TextInfo.Unix.cs +++ b/src/mscorlib/corefx/System/Globalization/TextInfo.Unix.cs @@ -16,7 +16,9 @@ namespace System.Globalization NotNeeded, Needed } - private TurkishCasing m_needsTurkishCasing; + + [NonSerialized] + private TurkishCasing _needsTurkishCasing = TurkishCasing.NotInitialized; ////////////////////////////////////////////////////////////////////////// //// @@ -27,15 +29,14 @@ namespace System.Globalization ////////////////////////////////////////////////////////////////////////// internal unsafe TextInfo(CultureData cultureData) { - m_cultureData = cultureData; - m_cultureName = m_cultureData.CultureName; - m_textInfoName = m_cultureData.STEXTINFO; - FinishInitialization(m_textInfoName); + _cultureData = cultureData; + _cultureName = _cultureData.CultureName; + _textInfoName = _cultureData.STEXTINFO; + FinishInitialization(_textInfoName); } private void FinishInitialization(string textInfoName) { - m_needsTurkishCasing = TurkishCasing.NotInitialized; } [SecuritySafeCritical] @@ -104,9 +105,8 @@ namespace System.Globalization return CultureInfo.GetCultureInfo(localeName).CompareInfo.Compare("\u0131", "I", CompareOptions.IgnoreCase) == 0; } - private bool IsInvariant { get { return m_cultureName.Length == 0; } } + private bool IsInvariant { get { return _cultureName.Length == 0; } } - [SecurityCritical] internal unsafe void ChangeCase(char* src, int srcLen, char* dstBuffer, int dstBufferCapacity, bool bToUpper) { if (IsInvariant) @@ -115,11 +115,11 @@ namespace System.Globalization } else { - if (m_needsTurkishCasing == TurkishCasing.NotInitialized) + if (_needsTurkishCasing == TurkishCasing.NotInitialized) { - m_needsTurkishCasing = NeedsTurkishCasing(m_textInfoName) ? TurkishCasing.Needed : TurkishCasing.NotNeeded; + _needsTurkishCasing = NeedsTurkishCasing(_textInfoName) ? TurkishCasing.Needed : TurkishCasing.NotNeeded; } - if ( m_needsTurkishCasing == TurkishCasing.Needed) + if ( _needsTurkishCasing == TurkishCasing.Needed) { Interop.GlobalizationInterop.ChangeCaseTurkish(src, srcLen, dstBuffer, dstBufferCapacity, bToUpper); } diff --git a/src/mscorlib/corefx/System/Globalization/TextInfo.Windows.cs b/src/mscorlib/corefx/System/Globalization/TextInfo.Windows.cs index bdaa35b..0dce392 100644 --- a/src/mscorlib/corefx/System/Globalization/TextInfo.Windows.cs +++ b/src/mscorlib/corefx/System/Globalization/TextInfo.Windows.cs @@ -1,6 +1,7 @@ // 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.Diagnostics.Contracts; namespace System.Globalization @@ -17,10 +18,10 @@ namespace System.Globalization internal unsafe TextInfo(CultureData cultureData) { // This is our primary data source, we don't need most of the rest of this - this.m_cultureData = cultureData; - this.m_cultureName = this.m_cultureData.CultureName; - this.m_textInfoName = this.m_cultureData.STEXTINFO; - FinishInitialization(this.m_textInfoName); + _cultureData = cultureData; + _cultureName = _cultureData.CultureName; + _textInfoName = _cultureData.STEXTINFO; + FinishInitialization(_textInfoName); } private void FinishInitialization(string textInfoName) @@ -28,14 +29,13 @@ namespace System.Globalization const uint LCMAP_SORTHANDLE = 0x20000000; long handle; - int ret = Interop.mincore.LCMapStringEx(textInfoName, LCMAP_SORTHANDLE, null, 0, (IntPtr)(&handle), IntPtr.Size, IntPtr.Zero, IntPtr.Zero, IntPtr.Zero); - + int ret = Interop.mincore.LCMapStringEx(_textInfoName, LCMAP_SORTHANDLE, null, 0, &handle, IntPtr.Size, null, null, IntPtr.Zero); _sortHandle = ret > 0 ? (IntPtr)handle : IntPtr.Zero; } private unsafe string ChangeCase(string s, bool toUpper) { - Contract.Assert(s != null); + Contract.Assert(s != null); // // Get the length of the string. @@ -54,7 +54,7 @@ namespace System.Globalization int result; // Check for Invariant to avoid A/V in LCMapStringEx - uint linguisticCasing = IsInvariantLocale(m_textInfoName) ? 0 : LCMAP_LINGUISTIC_CASING; + uint linguisticCasing = IsInvariantLocale(_textInfoName) ? 0 : LCMAP_LINGUISTIC_CASING; // // Create the result string. @@ -62,14 +62,14 @@ namespace System.Globalization char[] buffer = new char[nLengthInput]; fixed (char* pBuffer = buffer) { - result = Interop.mincore.LCMapStringEx(_sortHandle != IntPtr.Zero ? null : m_textInfoName, + result = Interop.mincore.LCMapStringEx(_sortHandle != IntPtr.Zero ? null : _textInfoName, toUpper ? LCMAP_UPPERCASE | linguisticCasing : LCMAP_LOWERCASE | linguisticCasing, s, nLengthInput, - (IntPtr)pBuffer, + pBuffer, nLengthInput, - IntPtr.Zero, - IntPtr.Zero, + null, + null, _sortHandle); } @@ -88,16 +88,16 @@ namespace System.Globalization char retVal = '\0'; // Check for Invariant to avoid A/V in LCMapStringEx - uint linguisticCasing = IsInvariantLocale(m_textInfoName) ? 0 : LCMAP_LINGUISTIC_CASING; + uint linguisticCasing = IsInvariantLocale(_textInfoName) ? 0 : LCMAP_LINGUISTIC_CASING; - Interop.mincore.LCMapStringEx(_sortHandle != IntPtr.Zero ? null : m_textInfoName, + Interop.mincore.LCMapStringEx(_sortHandle != IntPtr.Zero ? null : _textInfoName, toUpper ? LCMAP_UPPERCASE | linguisticCasing : LCMAP_LOWERCASE | linguisticCasing, new string(c, 1), 1, - (IntPtr)(&retVal), + &retVal, 1, - IntPtr.Zero, - IntPtr.Zero, + null, + null, _sortHandle); return retVal; diff --git a/src/mscorlib/corefx/System/Globalization/TextInfo.cs b/src/mscorlib/corefx/System/Globalization/TextInfo.cs index da5ba51..40fff9f 100644 --- a/src/mscorlib/corefx/System/Globalization/TextInfo.cs +++ b/src/mscorlib/corefx/System/Globalization/TextInfo.cs @@ -4,13 +4,11 @@ //////////////////////////////////////////////////////////////////////////// // -// Class: TextInfo // // Purpose: This Class defines behaviors specific to a writing system. // A writing system is the collection of scripts and // orthographic rules required to represent a language as text. // -// Date: March 31, 1999 // //////////////////////////////////////////////////////////////////////////// @@ -38,38 +36,28 @@ namespace System.Globalization //// [OptionalField(VersionAdded = 2)] - private String m_listSeparator; + private String _listSeparator; [OptionalField(VersionAdded = 2)] - private bool m_isReadOnly = false; + private bool _isReadOnly = false; - //// - //// In Whidbey we had several names: - //// m_win32LangID is the name of the culture, but only used for (de)serialization. - //// customCultureName is the name of the creating custom culture (if custom) In combination with m_win32LangID - //// this is authoratative, ie when deserializing. - //// m_cultureTableRecord was the data record of the creating culture. (could have different name if custom) - //// m_textInfoID is the LCID of the textinfo itself (no longer used) - //// m_name is the culture name (from cultureinfo.name) - //// - //// In Silverlight/Arrowhead this is slightly different: - //// m_cultureName is the name of the creating culture. Note that we consider this authoratative, + //// _cultureName is the name of the creating culture. Note that we consider this authoratative, //// if the culture's textinfo changes when deserializing, then behavior may change. //// (ala Whidbey behavior). This is the only string Arrowhead needs to serialize. - //// m_cultureData is the data that backs this class. - //// m_textInfoName is the actual name of the textInfo (from cultureData.STEXTINFO) - //// this can be the same as m_cultureName on Silverlight since the OS knows + //// _cultureData is the data that backs this class. + //// _textInfoName is the actual name of the textInfo (from cultureData.STEXTINFO) + //// this can be the same as _cultureName on Silverlight since the OS knows //// how to do the sorting. However in the desktop, when we call the sorting dll, it doesn't //// know how to resolve custom locle names to sort ids so we have to have alredy resolved this. //// [OptionalField(VersionAdded = 3)] - private String m_cultureName; // Name of the culture that created this text info + private String _cultureName; // Name of the culture that created this text info [NonSerialized] - private CultureData m_cultureData; // Data record for the culture that made us, not for this textinfo + private CultureData _cultureData; // Data record for the culture that made us, not for this textinfo [NonSerialized] - private String m_textInfoName; // Name of the text info we're using (ie: m_cultureData.STEXTINFO) + private String _textInfoName; // Name of the text info we're using (ie: _cultureData.STEXTINFO) [NonSerialized] - private bool? m_IsAsciiCasingSameAsInvariant; + private bool? _isAsciiCasingSameAsInvariant; // Invariant text info internal static TextInfo Invariant @@ -90,8 +78,8 @@ namespace System.Globalization private void OnDeserializing(StreamingContext ctx) { // Clear these so we can check if we've fixed them yet - this.m_cultureData = null; - this.m_cultureName = null; + _cultureData = null; + _cultureName = null; } [OnDeserialized] @@ -108,12 +96,12 @@ namespace System.Globalization private void OnDeserialized() { // this method will be called twice because of the support of IDeserializationCallback - if (this.m_cultureData == null) + if (_cultureData == null) { // Get the text info name belonging to that culture - this.m_cultureData = CultureInfo.GetCultureInfo(m_cultureName).m_cultureData; - this.m_textInfoName = this.m_cultureData.STEXTINFO; - FinishInitialization(this.m_textInfoName); + _cultureData = CultureInfo.GetCultureInfo(_cultureName).m_cultureData; + _textInfoName = _cultureData.STEXTINFO; + FinishInitialization(_textInfoName); } } @@ -129,7 +117,6 @@ namespace System.Globalization } // Currently we don't have native functions to do this, so we do it the hard way - [SecuritySafeCritical] internal static int IndexOfStringOrdinalIgnoreCase(String source, String value, int startIndex, int count) { if (count > source.Length || count < 0 || startIndex < 0 || startIndex >= source.Length || startIndex + count > source.Length) @@ -141,7 +128,6 @@ namespace System.Globalization } // Currently we don't have native functions to do this, so we do it the hard way - [SecuritySafeCritical] internal static int LastIndexOfStringOrdinalIgnoreCase(String source, String value, int startIndex, int count) { if (count > source.Length || count < 0 || startIndex < 0 || startIndex > source.Length - 1 || (startIndex - count + 1 < 0)) @@ -163,7 +149,7 @@ namespace System.Globalization { get { - return m_textInfoName; + return _textInfoName; } } @@ -177,7 +163,7 @@ namespace System.Globalization [System.Runtime.InteropServices.ComVisible(false)] public bool IsReadOnly { - get { return (m_isReadOnly); } + get { return (_isReadOnly); } } ////////////////////////////////////////////////////////////////////////// @@ -217,7 +203,7 @@ namespace System.Globalization private void VerifyWritable() { - if (m_isReadOnly) + if (_isReadOnly) { throw new InvalidOperationException(SR.InvalidOperation_ReadOnly); } @@ -225,7 +211,7 @@ namespace System.Globalization internal void SetReadOnlyState(bool readOnly) { - m_isReadOnly = readOnly; + _isReadOnly = readOnly; } @@ -240,11 +226,11 @@ namespace System.Globalization { get { - if (m_listSeparator == null) + if (_listSeparator == null) { - m_listSeparator = this.m_cultureData.SLIST; + _listSeparator = _cultureData.SLIST; } - return (m_listSeparator); + return (_listSeparator); } set @@ -254,7 +240,7 @@ namespace System.Globalization throw new ArgumentNullException("value", SR.ArgumentNull_String); } VerifyWritable(); - m_listSeparator = value; + _listSeparator = value; } } @@ -369,13 +355,13 @@ namespace System.Globalization { get { - if (m_IsAsciiCasingSameAsInvariant == null) + if (_isAsciiCasingSameAsInvariant == null) { - m_IsAsciiCasingSameAsInvariant = CultureInfo.GetCultureInfo(m_textInfoName).CompareInfo.Compare("abcdefghijklmnopqrstuvwxyz", + _isAsciiCasingSameAsInvariant = CultureInfo.GetCultureInfo(_textInfoName).CompareInfo.Compare("abcdefghijklmnopqrstuvwxyz", "ABCDEFGHIJKLMNOPQRSTUVWXYZ", CompareOptions.IgnoreCase) == 0; } - return (bool)m_IsAsciiCasingSameAsInvariant; + return (bool)_isAsciiCasingSameAsInvariant; } } @@ -387,7 +373,7 @@ namespace System.Globalization { get { - return this.m_cultureData.IsRightToLeft; + return _cultureData.IsRightToLeft; } } @@ -435,7 +421,7 @@ namespace System.Globalization //////////////////////////////////////////////////////////////////////// public override String ToString() { - return ("TextInfo - " + this.m_cultureData.CultureName); + return ("TextInfo - " + _cultureData.CultureName); } // @@ -477,7 +463,6 @@ namespace System.Globalization } return (int)hash; - } private unsafe int GetCaseInsensitiveHashCodeSlow(String str) diff --git a/src/mscorlib/corefx/System/Globalization/ThaiBuddhistCalendar.cs b/src/mscorlib/corefx/System/Globalization/ThaiBuddhistCalendar.cs index 026adfc..b42af30 100644 --- a/src/mscorlib/corefx/System/Globalization/ThaiBuddhistCalendar.cs +++ b/src/mscorlib/corefx/System/Globalization/ThaiBuddhistCalendar.cs @@ -25,7 +25,7 @@ namespace System.Globalization public class ThaiBuddhistCalendar : Calendar { // Initialize our era info. - static internal EraInfo[] thaiBuddhistEraInfo = new EraInfo[] { + internal static EraInfo[] thaiBuddhistEraInfo = new EraInfo[] { new EraInfo( 1, 1, 1, 1, -543, 544, GregorianCalendar.MaxYear + 543) // era #, start year/month/day, yearOffset, minEraYear }; @@ -35,8 +35,6 @@ namespace System.Globalization public const int ThaiBuddhistEra = 1; - //internal static Calendar m_defaultInstance; - internal GregorianCalendarHelper helper; diff --git a/src/mscorlib/corefx/System/Globalization/TimeSpanStyles.cs b/src/mscorlib/corefx/System/Globalization/TimeSpanStyles.cs index c14fd69..68a47bc 100644 --- a/src/mscorlib/corefx/System/Globalization/TimeSpanStyles.cs +++ b/src/mscorlib/corefx/System/Globalization/TimeSpanStyles.cs @@ -1,6 +1,7 @@ // 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. + namespace System.Globalization { [Flags] diff --git a/src/mscorlib/corefx/System/Globalization/UmAlQuraCalendar.cs b/src/mscorlib/corefx/System/Globalization/UmAlQuraCalendar.cs index cc89c55..1116722 100644 --- a/src/mscorlib/corefx/System/Globalization/UmAlQuraCalendar.cs +++ b/src/mscorlib/corefx/System/Globalization/UmAlQuraCalendar.cs @@ -37,11 +37,12 @@ namespace System.Globalization internal DateTime GregorianDate; } - static readonly DateMapping[] HijriYearInfo = InitDateMapping(); + private static readonly DateMapping[] s_hijriYearInfo = InitDateMapping(); - static DateMapping[] InitDateMapping() + private static DateMapping[] InitDateMapping() { - short[] rawData = new short[] { + short[] rawData = new short[] + { //These data is taken from Tables/Excel/UmAlQura.xls please make sure that the two places are in sync /* DaysPerM GY GM GD D1 D2 D3 D4 D5 D6 D7 D8 D9 D10 D11 D12 1318*/0x02EA, 1900, 4, 30,/* 0 1 0 1 0 1 1 1 0 1 0 0 4/30/1900 @@ -248,31 +249,11 @@ namespace System.Globalization internal const int DatePartMonth = 2; internal const int DatePartDay = 3; - //internal static Calendar m_defaultInstance; - // This is the minimal Gregorian date that we support in the UmAlQuraCalendar. internal static DateTime minDate = new DateTime(1900, 4, 30); internal static DateTime maxDate = new DateTime((new DateTime(2077, 11, 16, 23, 59, 59, 999)).Ticks + 9999); - /*=================================GetDefaultInstance========================== - **Action: Internal method to provide a default intance of UmAlQuraCalendar. Used by NLS+ implementation - ** and other calendars. - **Returns: - **Arguments: - **Exceptions: - ============================================================================*/ - /* - internal static Calendar GetDefaultInstance() { - if (m_defaultInstance == null) { - m_defaultInstance = new UmAlQuraCalendar(); - } - return (m_defaultInstance); - } - */ - - - public override DateTime MinSupportedDateTime { get @@ -281,7 +262,6 @@ namespace System.Globalization } } - public override DateTime MaxSupportedDateTime { get @@ -290,9 +270,6 @@ namespace System.Globalization } } - - // Construct an instance of UmAlQura calendar. - public UmAlQuraCalendar() { } @@ -330,7 +307,7 @@ namespace System.Globalization ** Output: Gregorian date: year:yg, month:mg, day:dg , day of week:dayweek ** and returns flag found:1 not found:0 =========================ConvertHijriToGregorian============================*/ - static void ConvertHijriToGregorian(int HijriYear, int HijriMonth, int HijriDay, ref int yg, ref int mg, ref int dg) + private static void ConvertHijriToGregorian(int HijriYear, int HijriMonth, int HijriDay, ref int yg, ref int mg, ref int dg) { Contract.Assert((HijriYear >= MinCalendarYear) && (HijriYear <= MaxCalendarYear), "Hijri year is out of range."); Contract.Assert(HijriMonth >= 1, "Hijri month is out of range."); @@ -340,10 +317,10 @@ namespace System.Globalization index = HijriYear - MinCalendarYear; - dt = HijriYearInfo[index].GregorianDate; + dt = s_hijriYearInfo[index].GregorianDate; - b = HijriYearInfo[index].HijriMonthsLengthFlags; + b = s_hijriYearInfo[index].HijriMonthsLengthFlags; for (int m = 1; m < HijriMonth; m++) { @@ -364,7 +341,7 @@ namespace System.Globalization **Arguments: **Exceptions: ============================================================================*/ - static long GetAbsoluteDateUmAlQura(int year, int month, int day) + private static long GetAbsoluteDateUmAlQura(int year, int month, int day) { //Caller should check the validaty of year, month and day. @@ -373,7 +350,7 @@ namespace System.Globalization return GregorianCalendar.GetAbsoluteDate(yg, mg, dg); } - static internal void CheckTicksRange(long ticks) + internal static void CheckTicksRange(long ticks) { if (ticks < minDate.Ticks || ticks > maxDate.Ticks) { @@ -387,7 +364,7 @@ namespace System.Globalization } } - static internal void CheckEraRange(int era) + internal static void CheckEraRange(int era) { if (era != CurrentEra && era != UmAlQuraEra) { @@ -395,7 +372,7 @@ namespace System.Globalization } } - static internal void CheckYearRange(int year, int era) + internal static void CheckYearRange(int year, int era) { CheckEraRange(era); if (year < MinCalendarYear || year > MaxCalendarYear) @@ -410,7 +387,7 @@ namespace System.Globalization } } - static internal void CheckYearMonthRange(int year, int month, int era) + internal static void CheckYearMonthRange(int year, int month, int era) { CheckYearRange(year, era); if (month < 1 || month > 12) @@ -425,7 +402,7 @@ namespace System.Globalization ** Input: DateTime ** Output: Hijrah date: year:yh, month:mh, day:dh ============================================================================*/ - static void ConvertGregorianToHijri(DateTime time, ref int HijriYear, ref int HijriMonth, ref int HijriDay) + private static void ConvertGregorianToHijri(DateTime time, ref int HijriYear, ref int HijriMonth, ref int HijriDay) { int index, b, DaysPerThisMonth; double nDays; @@ -440,20 +417,20 @@ namespace System.Globalization index = (int)((time.Ticks - minDate.Ticks) / Calendar.TicksPerDay) / 355; do { - } while (time.CompareTo(HijriYearInfo[++index].GregorianDate) > 0); //while greater + } while (time.CompareTo(s_hijriYearInfo[++index].GregorianDate) > 0); //while greater - if (time.CompareTo(HijriYearInfo[index].GregorianDate) != 0) + if (time.CompareTo(s_hijriYearInfo[index].GregorianDate) != 0) { index--; } - ts = time.Subtract(HijriYearInfo[index].GregorianDate); + ts = time.Subtract(s_hijriYearInfo[index].GregorianDate); yh1 = index + MinCalendarYear; mh1 = 1; dh1 = 1; nDays = ts.TotalDays; - b = HijriYearInfo[index].HijriMonthsLengthFlags; + b = s_hijriYearInfo[index].HijriMonthsLengthFlags; DaysPerThisMonth = 29 + (b & 1); while (nDays >= DaysPerThisMonth) @@ -635,19 +612,19 @@ namespace System.Globalization { CheckYearMonthRange(year, month, era); - if ((HijriYearInfo[year - MinCalendarYear].HijriMonthsLengthFlags & (1 << month - 1)) == 0) + if ((s_hijriYearInfo[year - MinCalendarYear].HijriMonthsLengthFlags & (1 << month - 1)) == 0) return 29; else return 30; } - static internal int RealGetDaysInYear(int year) + internal static int RealGetDaysInYear(int year) { int days = 0, b; Contract.Assert((year >= MinCalendarYear) && (year <= MaxCalendarYear), "Hijri year is out of range."); - b = HijriYearInfo[year - MinCalendarYear].HijriMonthsLengthFlags; + b = s_hijriYearInfo[year - MinCalendarYear].HijriMonthsLengthFlags; for (int m = 1; m <= 12; m++) { diff --git a/src/mscorlib/corefx/System/Globalization/UnicodeCategory.cs b/src/mscorlib/corefx/System/Globalization/UnicodeCategory.cs index 952f4f3..1c5e6bc 100644 --- a/src/mscorlib/corefx/System/Globalization/UnicodeCategory.cs +++ b/src/mscorlib/corefx/System/Globalization/UnicodeCategory.cs @@ -2,20 +2,6 @@ // The .NET Foundation licenses this file to you under the MIT license. // See the LICENSE file in the project root for more information. -// - -// - -/*============================================================ -** -** Class: UnicodeCategory -** -** -** Purpose: -** -** -============================================================*/ - namespace System.Globalization { [Serializable] -- 2.7.4