diff options
Diffstat (limited to 'src/mscorlib/src/System/Globalization/HebrewCalendar.cs')
-rw-r--r-- | src/mscorlib/src/System/Globalization/HebrewCalendar.cs | 31 |
1 files changed, 16 insertions, 15 deletions
diff --git a/src/mscorlib/src/System/Globalization/HebrewCalendar.cs b/src/mscorlib/src/System/Globalization/HebrewCalendar.cs index 3a17494001..44cbdb8bde 100644 --- a/src/mscorlib/src/System/Globalization/HebrewCalendar.cs +++ b/src/mscorlib/src/System/Globalization/HebrewCalendar.cs @@ -5,6 +5,7 @@ namespace System.Globalization { using System; using System.Text; + using System.Diagnostics; using System.Diagnostics.Contracts; //////////////////////////////////////////////////////////////////////////// @@ -397,7 +398,7 @@ namespace System.Globalization { int monthsInYear = GetMonthsInYear(year, era); if (month < 1 || month > monthsInYear) { throw new ArgumentOutOfRangeException( - "month", + nameof(month), String.Format( CultureInfo.CurrentCulture, Environment.GetResourceString("ArgumentOutOfRange_Range"), @@ -421,7 +422,7 @@ namespace System.Globalization { int daysInMonth = GetDaysInMonth(year, month, era); if (day < 1 || day > daysInMonth) { throw new ArgumentOutOfRangeException( - "day", + nameof(day), String.Format( CultureInfo.CurrentCulture, Environment.GetResourceString("ArgumentOutOfRange_Range"), @@ -432,7 +433,7 @@ namespace System.Globalization { static internal void CheckEraRange(int era) { if (era != CurrentEra && era != HebrewEra) { - throw new ArgumentOutOfRangeException("era", Environment.GetResourceString("ArgumentOutOfRange_InvalidEraValue")); + throw new ArgumentOutOfRangeException(nameof(era), Environment.GetResourceString("ArgumentOutOfRange_InvalidEraValue")); } } @@ -486,7 +487,7 @@ namespace System.Globalization { // int index = gregorianYear - FirstGregorianTableYear; if (index < 0 || index > TABLESIZE) { - throw new ArgumentOutOfRangeException("gregorianYear"); + throw new ArgumentOutOfRangeException(nameof(gregorianYear)); } index *= 2; @@ -607,7 +608,7 @@ namespace System.Globalization { // is true. // NumDays -= (long)(LunarMonthLen[hebrewYearType, lunarDate.month] - lunarDate.day); - Contract.Assert(NumDays >= 1, "NumDays >= 1"); + Debug.Assert(NumDays >= 1, "NumDays >= 1"); // If NumDays is 1, then we are done. Otherwise, find the correct Hebrew month // and day. @@ -705,7 +706,7 @@ namespace System.Globalization { catch (ArgumentException) { throw new ArgumentOutOfRangeException( - "months", + nameof(months), String.Format( CultureInfo.CurrentCulture, Environment.GetResourceString("ArgumentOutOfRange_AddValue"))); @@ -727,7 +728,7 @@ namespace System.Globalization { int d = GetDatePart(time.Ticks, DatePartDay); y += years; - CheckHebrewYearValue(y, Calendar.CurrentEra, "years"); + CheckHebrewYearValue(y, Calendar.CurrentEra, nameof(years)); int months = GetMonthsInYear(y, CurrentEra); if (m > months) { @@ -765,7 +766,7 @@ namespace System.Globalization { } static internal int GetHebrewYearType(int year, int era) { - CheckHebrewYearValue(year, era, "year"); + CheckHebrewYearValue(year, era, nameof(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]); @@ -811,11 +812,11 @@ namespace System.Globalization { int hebrewYearType = GetHebrewYearType(year, era); CheckHebrewMonthValue(year, month, era); - Contract.Assert(hebrewYearType>= 1 && hebrewYearType <= 6, + Debug.Assert(hebrewYearType>= 1 && hebrewYearType <= 6, "hebrewYearType should be from 1 to 6, but now hebrewYearType = " + hebrewYearType + " for hebrew year " + year); int monthDays = LunarMonthLen[hebrewYearType, month]; if (monthDays == 0) { - throw new ArgumentOutOfRangeException("month", Environment.GetResourceString("ArgumentOutOfRange_Month")); + throw new ArgumentOutOfRangeException(nameof(month), Environment.GetResourceString("ArgumentOutOfRange_Month")); } return (monthDays); } @@ -931,7 +932,7 @@ namespace System.Globalization { // public override bool IsLeapYear(int year, int era) { - CheckHebrewYearValue(year, era, "year"); + CheckHebrewYearValue(year, era, nameof(year)); return (((7 * (long)year + 1) % 19) < 7); } @@ -1015,7 +1016,7 @@ namespace System.Globalization { // public override DateTime ToDateTime(int year, int month, int day, int hour, int minute, int second, int millisecond, int era) { - CheckHebrewYearValue(year, era, "year"); + CheckHebrewYearValue(year, era, nameof(year)); CheckHebrewMonthValue(year, month, era); CheckHebrewDayValue(year, month, day, era); DateTime dt = HebrewToGregorian(year, month, day, hour, minute, second, millisecond); @@ -1042,7 +1043,7 @@ namespace System.Globalization { } else { - CheckHebrewYearValue(value, HebrewEra, "value"); + CheckHebrewYearValue(value, HebrewEra, nameof(value)); } twoDigitYearMax = value; } @@ -1051,7 +1052,7 @@ namespace System.Globalization { public override int ToFourDigitYear(int year) { if (year < 0) { - throw new ArgumentOutOfRangeException("year", + throw new ArgumentOutOfRangeException(nameof(year), Environment.GetResourceString("ArgumentOutOfRange_NeedNonNegNum")); } Contract.EndContractBlock(); @@ -1062,7 +1063,7 @@ namespace System.Globalization { if (year > MaxHebrewYear || year < MinHebrewYear) { throw new ArgumentOutOfRangeException( - "year", + nameof(year), String.Format( CultureInfo.CurrentCulture, Environment.GetResourceString("ArgumentOutOfRange_Range"), |