From 90f5615e349a002fc00288c147e82b965ecfa1b0 Mon Sep 17 00:00:00 2001 From: Krzysztof Wicher Date: Wed, 27 Mar 2019 11:25:12 -0700 Subject: [PATCH] Nullable: all calendars (#23469) * calendar * nullable: all calendars * fix likely corert error --- .../shared/System/Globalization/Calendar.cs | 3 ++- .../Globalization/CalendricalCalculationsHelper.cs | 1 + .../shared/System/Globalization/CharUnicodeInfo.cs | 1 + .../System/Globalization/CharUnicodeInfoData.cs | 1 + .../Globalization/ChineseLunisolarCalendar.cs | 5 ++-- .../Globalization/EastAsianLunisolarCalendar.cs | 7 +++--- .../System/Globalization/GregorianCalendar.cs | 3 ++- .../shared/System/Globalization/HebrewCalendar.cs | 3 ++- .../System/Globalization/HijriCalendar.Unix.cs | 1 + .../System/Globalization/HijriCalendar.Win32.cs | 1 + .../System/Globalization/HijriCalendar.WinRT.cs | 1 + .../shared/System/Globalization/HijriCalendar.cs | 3 ++- .../System/Globalization/JapaneseCalendar.Unix.cs | 3 ++- .../System/Globalization/JapaneseCalendar.Win32.cs | 9 ++++--- .../System/Globalization/JapaneseCalendar.WinRT.cs | 13 +++++----- .../System/Globalization/JapaneseCalendar.cs | 29 ++++++++-------------- .../Globalization/JapaneseLunisolarCalendar.cs | 5 ++-- .../shared/System/Globalization/JulianCalendar.cs | 3 ++- .../shared/System/Globalization/KoreanCalendar.cs | 6 ++--- .../Globalization/KoreanLunisolarCalendar.cs | 5 ++-- .../shared/System/Globalization/PersianCalendar.cs | 3 ++- .../shared/System/Globalization/TaiwanCalendar.cs | 3 ++- .../Globalization/TaiwanLunisolarCalendar.cs | 5 ++-- .../System/Globalization/ThaiBuddhistCalendar.cs | 3 ++- .../System/Globalization/UmAlQuraCalendar.cs | 3 ++- 25 files changed, 67 insertions(+), 53 deletions(-) diff --git a/src/System.Private.CoreLib/shared/System/Globalization/Calendar.cs b/src/System.Private.CoreLib/shared/System/Globalization/Calendar.cs index b863cf5..c54e558 100644 --- a/src/System.Private.CoreLib/shared/System/Globalization/Calendar.cs +++ b/src/System.Private.CoreLib/shared/System/Globalization/Calendar.cs @@ -2,6 +2,7 @@ // The .NET Foundation licenses this file to you under the MIT license. // See the LICENSE file in the project root for more information. +#nullable enable using System.Diagnostics; using System.Runtime.Serialization; @@ -322,7 +323,7 @@ namespace System.Globalization /// Get the list of era values. /// /// The int array of the era names supported in this calendar or null if era is not used. - public abstract int[] Eras { get; } + public abstract int[]? Eras { get; } // Returns the hour part of the specified DateTime. The returned value is an // integer between 0 and 23. diff --git a/src/System.Private.CoreLib/shared/System/Globalization/CalendricalCalculationsHelper.cs b/src/System.Private.CoreLib/shared/System/Globalization/CalendricalCalculationsHelper.cs index 241019a..a0fb759 100644 --- a/src/System.Private.CoreLib/shared/System/Globalization/CalendricalCalculationsHelper.cs +++ b/src/System.Private.CoreLib/shared/System/Globalization/CalendricalCalculationsHelper.cs @@ -2,6 +2,7 @@ // The .NET Foundation licenses this file to you under the MIT license. // See the LICENSE file in the project root for more information. +#nullable enable using System.Diagnostics; namespace System.Globalization diff --git a/src/System.Private.CoreLib/shared/System/Globalization/CharUnicodeInfo.cs b/src/System.Private.CoreLib/shared/System/Globalization/CharUnicodeInfo.cs index e627cc7..a78965b 100644 --- a/src/System.Private.CoreLib/shared/System/Globalization/CharUnicodeInfo.cs +++ b/src/System.Private.CoreLib/shared/System/Globalization/CharUnicodeInfo.cs @@ -2,6 +2,7 @@ // The .NET Foundation licenses this file to you under the MIT license. // See the LICENSE file in the project root for more information. +#nullable enable using System.Buffers.Binary; using System.Diagnostics; using System.Text; diff --git a/src/System.Private.CoreLib/shared/System/Globalization/CharUnicodeInfoData.cs b/src/System.Private.CoreLib/shared/System/Globalization/CharUnicodeInfoData.cs index 95aac2f..1af4cfe 100644 --- a/src/System.Private.CoreLib/shared/System/Globalization/CharUnicodeInfoData.cs +++ b/src/System.Private.CoreLib/shared/System/Globalization/CharUnicodeInfoData.cs @@ -2,6 +2,7 @@ // The .NET Foundation licenses this file to you under the MIT license. // See the LICENSE file in the project root for more information. +#nullable enable namespace System.Globalization { public static partial class CharUnicodeInfo diff --git a/src/System.Private.CoreLib/shared/System/Globalization/ChineseLunisolarCalendar.cs b/src/System.Private.CoreLib/shared/System/Globalization/ChineseLunisolarCalendar.cs index 56ce995..ef68ce2 100644 --- a/src/System.Private.CoreLib/shared/System/Globalization/ChineseLunisolarCalendar.cs +++ b/src/System.Private.CoreLib/shared/System/Globalization/ChineseLunisolarCalendar.cs @@ -2,6 +2,7 @@ // The .NET Foundation licenses this file to you under the MIT license. // See the LICENSE file in the project root for more information. +#nullable enable namespace System.Globalization { /// @@ -255,7 +256,7 @@ namespace System.Globalization internal override DateTime MaxDate => s_maxDate; - internal override EraInfo[] CalEraInfo => null; + internal override EraInfo[]? CalEraInfo => null; internal override int GetYearInfo(int lunarYear, int index) { @@ -307,6 +308,6 @@ namespace System.Globalization } } - public override int[] Eras => new int[] { ChineseEra }; + public override int[]? Eras => new int[] { ChineseEra }; } } diff --git a/src/System.Private.CoreLib/shared/System/Globalization/EastAsianLunisolarCalendar.cs b/src/System.Private.CoreLib/shared/System/Globalization/EastAsianLunisolarCalendar.cs index d1ca0f8..aa7d1fb 100644 --- a/src/System.Private.CoreLib/shared/System/Globalization/EastAsianLunisolarCalendar.cs +++ b/src/System.Private.CoreLib/shared/System/Globalization/EastAsianLunisolarCalendar.cs @@ -2,6 +2,7 @@ // The .NET Foundation licenses this file to you under the MIT license. // See the LICENSE file in the project root for more information. +#nullable enable namespace System.Globalization { public abstract class EastAsianLunisolarCalendar : Calendar @@ -69,7 +70,7 @@ namespace System.Globalization internal abstract int MinCalendarYear { get; } internal abstract int MaxCalendarYear { get; } - internal abstract EraInfo[] CalEraInfo { get; } + internal abstract EraInfo[]? CalEraInfo { get; } internal abstract DateTime MinDate { get; } internal abstract DateTime MaxDate { get; } @@ -78,7 +79,7 @@ namespace System.Globalization internal int MinEraCalendarYear(int era) { - EraInfo[] eraInfo = CalEraInfo; + EraInfo[]? eraInfo = CalEraInfo; if (eraInfo == null) { return MinCalendarYear; @@ -108,7 +109,7 @@ namespace System.Globalization internal int MaxEraCalendarYear(int era) { - EraInfo[] eraInfo = CalEraInfo; + EraInfo[]? eraInfo = CalEraInfo; if (eraInfo == null) { return MaxCalendarYear; diff --git a/src/System.Private.CoreLib/shared/System/Globalization/GregorianCalendar.cs b/src/System.Private.CoreLib/shared/System/Globalization/GregorianCalendar.cs index ebc5a54..28bf46e 100644 --- a/src/System.Private.CoreLib/shared/System/Globalization/GregorianCalendar.cs +++ b/src/System.Private.CoreLib/shared/System/Globalization/GregorianCalendar.cs @@ -2,6 +2,7 @@ // The .NET Foundation licenses this file to you under the MIT license. // See the LICENSE file in the project root for more information. +#nullable enable namespace System.Globalization { /// @@ -267,7 +268,7 @@ namespace System.Globalization public override int GetEra(DateTime time) => ADEra; - public override int[] Eras => new int[] { ADEra }; + public override int[]? Eras => new int[] { ADEra }; /// /// Returns the month part of the specified DateTime. diff --git a/src/System.Private.CoreLib/shared/System/Globalization/HebrewCalendar.cs b/src/System.Private.CoreLib/shared/System/Globalization/HebrewCalendar.cs index 67b3966..4975366 100644 --- a/src/System.Private.CoreLib/shared/System/Globalization/HebrewCalendar.cs +++ b/src/System.Private.CoreLib/shared/System/Globalization/HebrewCalendar.cs @@ -2,6 +2,7 @@ // The .NET Foundation licenses this file to you under the MIT license. // See the LICENSE file in the project root for more information. +#nullable enable using System.Diagnostics; namespace System.Globalization @@ -695,7 +696,7 @@ namespace System.Globalization public override int GetEra(DateTime time) => HebrewEra; - public override int[] Eras => new int[] { HebrewEra }; + public override int[]? Eras => new int[] { HebrewEra }; public override int GetMonth(DateTime time) { diff --git a/src/System.Private.CoreLib/shared/System/Globalization/HijriCalendar.Unix.cs b/src/System.Private.CoreLib/shared/System/Globalization/HijriCalendar.Unix.cs index a6e8f73..2b7b35f 100644 --- a/src/System.Private.CoreLib/shared/System/Globalization/HijriCalendar.Unix.cs +++ b/src/System.Private.CoreLib/shared/System/Globalization/HijriCalendar.Unix.cs @@ -2,6 +2,7 @@ // The .NET Foundation licenses this file to you under the MIT license. // See the LICENSE file in the project root for more information. +#nullable enable namespace System.Globalization { public partial class HijriCalendar : Calendar diff --git a/src/System.Private.CoreLib/shared/System/Globalization/HijriCalendar.Win32.cs b/src/System.Private.CoreLib/shared/System/Globalization/HijriCalendar.Win32.cs index 671a882..d0b645e 100644 --- a/src/System.Private.CoreLib/shared/System/Globalization/HijriCalendar.Win32.cs +++ b/src/System.Private.CoreLib/shared/System/Globalization/HijriCalendar.Win32.cs @@ -2,6 +2,7 @@ // The .NET Foundation licenses this file to you under the MIT license. // See the LICENSE file in the project root for more information. +#nullable enable using Internal.Win32; namespace System.Globalization diff --git a/src/System.Private.CoreLib/shared/System/Globalization/HijriCalendar.WinRT.cs b/src/System.Private.CoreLib/shared/System/Globalization/HijriCalendar.WinRT.cs index fb91c27..85b9afe 100644 --- a/src/System.Private.CoreLib/shared/System/Globalization/HijriCalendar.WinRT.cs +++ b/src/System.Private.CoreLib/shared/System/Globalization/HijriCalendar.WinRT.cs @@ -2,6 +2,7 @@ // The .NET Foundation licenses this file to you under the MIT license. // See the LICENSE file in the project root for more information. +#nullable enable using Internal.Runtime.Augments; namespace System.Globalization diff --git a/src/System.Private.CoreLib/shared/System/Globalization/HijriCalendar.cs b/src/System.Private.CoreLib/shared/System/Globalization/HijriCalendar.cs index 71cdb34..f2a8aff 100644 --- a/src/System.Private.CoreLib/shared/System/Globalization/HijriCalendar.cs +++ b/src/System.Private.CoreLib/shared/System/Globalization/HijriCalendar.cs @@ -2,6 +2,7 @@ // The .NET Foundation licenses this file to you under the MIT license. // See the LICENSE file in the project root for more information. +#nullable enable namespace System.Globalization { /// @@ -353,7 +354,7 @@ namespace System.Globalization return HijriEra; } - public override int[] Eras => new int[] { HijriEra }; + public override int[]? Eras => new int[] { HijriEra }; public override int GetMonth(DateTime time) { diff --git a/src/System.Private.CoreLib/shared/System/Globalization/JapaneseCalendar.Unix.cs b/src/System.Private.CoreLib/shared/System/Globalization/JapaneseCalendar.Unix.cs index ef78166..84bcedb 100644 --- a/src/System.Private.CoreLib/shared/System/Globalization/JapaneseCalendar.Unix.cs +++ b/src/System.Private.CoreLib/shared/System/Globalization/JapaneseCalendar.Unix.cs @@ -2,6 +2,7 @@ // The .NET Foundation licenses this file to you under the MIT license. // See the LICENSE file in the project root for more information. +#nullable enable using System.Collections.Generic; using System.Diagnostics; @@ -9,7 +10,7 @@ namespace System.Globalization { public partial class JapaneseCalendar : Calendar { - private static EraInfo[] GetJapaneseEras() + private static EraInfo[]? GetJapaneseEras() { if (GlobalizationMode.Invariant) { diff --git a/src/System.Private.CoreLib/shared/System/Globalization/JapaneseCalendar.Win32.cs b/src/System.Private.CoreLib/shared/System/Globalization/JapaneseCalendar.Win32.cs index 1a8ba7c..55c2c67 100644 --- a/src/System.Private.CoreLib/shared/System/Globalization/JapaneseCalendar.Win32.cs +++ b/src/System.Private.CoreLib/shared/System/Globalization/JapaneseCalendar.Win32.cs @@ -2,6 +2,7 @@ // The .NET Foundation licenses this file to you under the MIT license. // See the LICENSE file in the project root for more information. +#nullable enable using System.Diagnostics; using Internal.Win32; @@ -27,11 +28,11 @@ namespace System.Globalization // . is a delimiter, but the value of . doesn't matter. // '_' marks the space between the japanese era name, japanese abbreviated era name // english name, and abbreviated english names. - private static EraInfo[] GetJapaneseEras() + private static EraInfo[]? GetJapaneseEras() { // Look in the registry key and see if we can find any ranges int iFoundEras = 0; - EraInfo[] registryEraRanges = null; + EraInfo[]? registryEraRanges = null; try { @@ -51,7 +52,7 @@ namespace System.Globalization for (int i = 0; i < valueNames.Length; i++) { // See if the era is a valid date - EraInfo era = GetEraFromValue(valueNames[i], key.GetValue(valueNames[i]).ToString()); + EraInfo? era = GetEraFromValue(valueNames[i], key.GetValue(valueNames[i]).ToString()); // continue if not valid if (era == null) continue; @@ -143,7 +144,7 @@ namespace System.Globalization // . is a delimiter, but the value of . doesn't matter. // '_' marks the space between the japanese era name, japanese abbreviated era name // english name, and abbreviated english names. - private static EraInfo GetEraFromValue(string value, string data) + private static EraInfo? GetEraFromValue(string? value, string? data) { // Need inputs if (value == null || data == null) return null; diff --git a/src/System.Private.CoreLib/shared/System/Globalization/JapaneseCalendar.WinRT.cs b/src/System.Private.CoreLib/shared/System/Globalization/JapaneseCalendar.WinRT.cs index 633baa4..993a5cd 100644 --- a/src/System.Private.CoreLib/shared/System/Globalization/JapaneseCalendar.WinRT.cs +++ b/src/System.Private.CoreLib/shared/System/Globalization/JapaneseCalendar.WinRT.cs @@ -2,6 +2,7 @@ // The .NET Foundation licenses this file to you under the MIT license. // See the LICENSE file in the project root for more information. +#nullable enable using System.Diagnostics; using Internal.Runtime.Augments; @@ -10,7 +11,7 @@ namespace System.Globalization { public partial class JapaneseCalendar : Calendar { - private static EraInfo[] GetJapaneseEras() + private static EraInfo[]? GetJapaneseEras() { int erasCount = WinRTInterop.Callbacks.GetJapaneseEraCount(); if (erasCount < 4) @@ -25,8 +26,8 @@ namespace System.Globalization { DateTimeOffset dateOffset; - string eraName; - string abbreviatedEraName; + string? eraName; + string? abbreviatedEraName; if (!GetJapaneseEraInfo(i, out dateOffset, out eraName, out abbreviatedEraName)) { @@ -36,7 +37,7 @@ namespace System.Globalization DateTime dt = new DateTime(dateOffset.Ticks); eras[erasCount - i] = new EraInfo(i, dt.Year, dt.Month, dt.Day, dt.Year - 1, 1, lastMaxYear - dt.Year + 1, - eraName, abbreviatedEraName, GetJapaneseEnglishEraName(i)); // era #4 start year/month/day, yearOffset, minEraYear + eraName!, abbreviatedEraName!, GetJapaneseEnglishEraName(i)); // era #4 start year/month/day, yearOffset, minEraYear lastMaxYear = dt.Year; } @@ -54,9 +55,9 @@ namespace System.Globalization return era <= s_JapaneseErasEnglishNames.Length ? s_JapaneseErasEnglishNames[era - 1] : " "; } - private static bool GetJapaneseEraInfo(int era, out DateTimeOffset dateOffset, out string eraName, out string abbreviatedEraName) + private static bool GetJapaneseEraInfo(int era, out DateTimeOffset dateOffset, out string? eraName, out string? abbreviatedEraName) { - return WinRTInterop.Callbacks.GetJapaneseEraInfo(era, out dateOffset, out eraName, out abbreviatedEraName); + return WinRTInterop.Callbacks.GetJapaneseEraInfo(era, out dateOffset, out eraName, out abbreviatedEraName); } } } diff --git a/src/System.Private.CoreLib/shared/System/Globalization/JapaneseCalendar.cs b/src/System.Private.CoreLib/shared/System/Globalization/JapaneseCalendar.cs index bcddd19..090d095 100644 --- a/src/System.Private.CoreLib/shared/System/Globalization/JapaneseCalendar.cs +++ b/src/System.Private.CoreLib/shared/System/Globalization/JapaneseCalendar.cs @@ -2,6 +2,7 @@ // The .NET Foundation licenses this file to you under the MIT license. // See the LICENSE file in the project root for more information. +#nullable enable namespace System.Globalization { /// @@ -43,7 +44,7 @@ namespace System.Globalization // Using a field initializer rather than a static constructor so that the whole class can be lazy // init. - private static volatile EraInfo[] s_japaneseEraInfo; + private static volatile EraInfo[]? s_japaneseEraInfo; // m_EraInfo must be listed in reverse chronological order. The most recent era // should be the first element. @@ -68,24 +69,16 @@ namespace System.Globalization internal static EraInfo[] GetEraInfo() { // See if we need to build it - if (s_japaneseEraInfo == null) - { - s_japaneseEraInfo = GetJapaneseEras(); - + return s_japaneseEraInfo ?? + (s_japaneseEraInfo = GetJapaneseEras()) ?? // See if we have to use the built-in eras - if (s_japaneseEraInfo == null) + (s_japaneseEraInfo = new EraInfo[] { - s_japaneseEraInfo = new EraInfo[] - { - new EraInfo(4, 1989, 1, 8, 1988, 1, GregorianCalendar.MaxYear - 1988, "\x5e73\x6210", "\x5e73", "H"), - new EraInfo(3, 1926, 12, 25, 1925, 1, 1989 - 1925, "\x662d\x548c", "\x662d", "S"), - new EraInfo(2, 1912, 7, 30, 1911, 1, 1926 - 1911, "\x5927\x6b63", "\x5927", "T"), - new EraInfo(1, 1868, 1, 1, 1867, 1, 1912 - 1867, "\x660e\x6cbb", "\x660e", "M") - }; - } - } - - return s_japaneseEraInfo; + new EraInfo(4, 1989, 1, 8, 1988, 1, GregorianCalendar.MaxYear - 1988, "\x5e73\x6210", "\x5e73", "H"), + new EraInfo(3, 1926, 12, 25, 1925, 1, 1989 - 1925, "\x662d\x548c", "\x662d", "S"), + new EraInfo(2, 1912, 7, 30, 1911, 1, 1926 - 1911, "\x5927\x6b63", "\x5927", "T"), + new EraInfo(1, 1868, 1, 1, 1867, 1, 1912 - 1867, "\x660e\x6cbb", "\x660e", "M") + }); } internal static volatile Calendar s_defaultInstance; @@ -220,7 +213,7 @@ namespace System.Globalization } - public override int[] Eras => _helper.Eras; + public override int[]? Eras => _helper.Eras; /// /// Return the various era strings diff --git a/src/System.Private.CoreLib/shared/System/Globalization/JapaneseLunisolarCalendar.cs b/src/System.Private.CoreLib/shared/System/Globalization/JapaneseLunisolarCalendar.cs index cd69cb8..db1fd4f 100644 --- a/src/System.Private.CoreLib/shared/System/Globalization/JapaneseLunisolarCalendar.cs +++ b/src/System.Private.CoreLib/shared/System/Globalization/JapaneseLunisolarCalendar.cs @@ -2,6 +2,7 @@ // The .NET Foundation licenses this file to you under the MIT license. // See the LICENSE file in the project root for more information. +#nullable enable namespace System.Globalization { /// @@ -142,7 +143,7 @@ namespace System.Globalization internal override DateTime MaxDate => s_maxDate; - internal override EraInfo[] CalEraInfo => JapaneseCalendar.GetEraInfo(); + internal override EraInfo[]? CalEraInfo => JapaneseCalendar.GetEraInfo(); internal override int GetYearInfo(int lunarYear, int index) { @@ -216,6 +217,6 @@ namespace System.Globalization internal override CalendarId ID => CalendarId.JAPANESELUNISOLAR; - public override int[] Eras => _helper.Eras; + public override int[]? Eras => _helper.Eras; } } diff --git a/src/System.Private.CoreLib/shared/System/Globalization/JulianCalendar.cs b/src/System.Private.CoreLib/shared/System/Globalization/JulianCalendar.cs index bba7f07..79a0625 100644 --- a/src/System.Private.CoreLib/shared/System/Globalization/JulianCalendar.cs +++ b/src/System.Private.CoreLib/shared/System/Globalization/JulianCalendar.cs @@ -2,6 +2,7 @@ // The .NET Foundation licenses this file to you under the MIT license. // See the LICENSE file in the project root for more information. +#nullable enable namespace System.Globalization { /// @@ -266,7 +267,7 @@ namespace System.Globalization return GetDatePart(time.Ticks, DatePartMonth); } - public override int[] Eras => new int[] { JulianEra }; + public override int[]? Eras => new int[] { JulianEra }; public override int GetMonthsInYear(int year, int era) { diff --git a/src/System.Private.CoreLib/shared/System/Globalization/KoreanCalendar.cs b/src/System.Private.CoreLib/shared/System/Globalization/KoreanCalendar.cs index 63c372e..4fbaa9f 100644 --- a/src/System.Private.CoreLib/shared/System/Globalization/KoreanCalendar.cs +++ b/src/System.Private.CoreLib/shared/System/Globalization/KoreanCalendar.cs @@ -2,6 +2,7 @@ // The .NET Foundation licenses this file to you under the MIT license. // See the LICENSE file in the project root for more information. +#nullable enable namespace System.Globalization { /// @@ -63,7 +64,6 @@ namespace System.Globalization return _helper.AddMonths(time, months); } - public override DateTime AddYears(DateTime time, int years) { return _helper.AddYears(time, years); @@ -139,14 +139,12 @@ namespace System.Globalization return _helper.IsLeapMonth(year, month, era); } - public override DateTime ToDateTime(int year, int month, int day, int hour, int minute, int second, int millisecond, int era) { return _helper.ToDateTime(year, month, day, hour, minute, second, millisecond, era); } - - public override int[] Eras => _helper.Eras; + public override int[]? Eras => _helper.Eras; private const int DefaultTwoDigitYearMax = 4362; diff --git a/src/System.Private.CoreLib/shared/System/Globalization/KoreanLunisolarCalendar.cs b/src/System.Private.CoreLib/shared/System/Globalization/KoreanLunisolarCalendar.cs index aa90a83..b7feb1a 100644 --- a/src/System.Private.CoreLib/shared/System/Globalization/KoreanLunisolarCalendar.cs +++ b/src/System.Private.CoreLib/shared/System/Globalization/KoreanLunisolarCalendar.cs @@ -2,6 +2,7 @@ // The .NET Foundation licenses this file to you under the MIT license. // See the LICENSE file in the project root for more information. +#nullable enable namespace System.Globalization { /// @@ -1184,7 +1185,7 @@ namespace System.Globalization internal override DateTime MaxDate => s_maxDate; - internal override EraInfo[] CalEraInfo => null; + internal override EraInfo[]? CalEraInfo => null; internal override int GetYearInfo(int lunarYear, int index) { @@ -1235,6 +1236,6 @@ namespace System.Globalization internal override CalendarId ID => CalendarId.KOREANLUNISOLAR; - public override int[] Eras => new int[] { GregorianEra }; + public override int[]? Eras => new int[] { GregorianEra }; } } diff --git a/src/System.Private.CoreLib/shared/System/Globalization/PersianCalendar.cs b/src/System.Private.CoreLib/shared/System/Globalization/PersianCalendar.cs index 40f9c9c..0858379 100644 --- a/src/System.Private.CoreLib/shared/System/Globalization/PersianCalendar.cs +++ b/src/System.Private.CoreLib/shared/System/Globalization/PersianCalendar.cs @@ -2,6 +2,7 @@ // The .NET Foundation licenses this file to you under the MIT license. // See the LICENSE file in the project root for more information. +#nullable enable using System.Diagnostics; namespace System.Globalization @@ -281,7 +282,7 @@ namespace System.Globalization return PersianEra; } - public override int[] Eras => new int[] { PersianEra }; + public override int[]? Eras => new int[] { PersianEra }; public override int GetMonth(DateTime time) { diff --git a/src/System.Private.CoreLib/shared/System/Globalization/TaiwanCalendar.cs b/src/System.Private.CoreLib/shared/System/Globalization/TaiwanCalendar.cs index f3414d3..6d7fb41 100644 --- a/src/System.Private.CoreLib/shared/System/Globalization/TaiwanCalendar.cs +++ b/src/System.Private.CoreLib/shared/System/Globalization/TaiwanCalendar.cs @@ -2,6 +2,7 @@ // The .NET Foundation licenses this file to you under the MIT license. // See the LICENSE file in the project root for more information. +#nullable enable using System.Diagnostics.CodeAnalysis; namespace System.Globalization @@ -148,7 +149,7 @@ namespace System.Globalization return _helper.ToDateTime(year, month, day, hour, minute, second, millisecond, era); } - public override int[] Eras => _helper.Eras; + public override int[]? Eras => _helper.Eras; private const int DefaultTwoDigitYearMax = 99; diff --git a/src/System.Private.CoreLib/shared/System/Globalization/TaiwanLunisolarCalendar.cs b/src/System.Private.CoreLib/shared/System/Globalization/TaiwanLunisolarCalendar.cs index 4898e59..826f0f3 100644 --- a/src/System.Private.CoreLib/shared/System/Globalization/TaiwanLunisolarCalendar.cs +++ b/src/System.Private.CoreLib/shared/System/Globalization/TaiwanLunisolarCalendar.cs @@ -2,6 +2,7 @@ // The .NET Foundation licenses this file to you under the MIT license. // See the LICENSE file in the project root for more information. +#nullable enable namespace System.Globalization { /// @@ -198,7 +199,7 @@ namespace System.Globalization internal override DateTime MaxDate => s_maxDate; - internal override EraInfo[] CalEraInfo => s_taiwanLunisolarEraInfo; + internal override EraInfo[]? CalEraInfo => s_taiwanLunisolarEraInfo; internal override int GetYearInfo(int lunarYear, int index) { @@ -234,6 +235,6 @@ namespace System.Globalization internal override CalendarId ID => CalendarId.TAIWANLUNISOLAR; - public override int[] Eras => _helper.Eras; + public override int[]? Eras => _helper.Eras; } } diff --git a/src/System.Private.CoreLib/shared/System/Globalization/ThaiBuddhistCalendar.cs b/src/System.Private.CoreLib/shared/System/Globalization/ThaiBuddhistCalendar.cs index 8bc48db..1b39c7b 100644 --- a/src/System.Private.CoreLib/shared/System/Globalization/ThaiBuddhistCalendar.cs +++ b/src/System.Private.CoreLib/shared/System/Globalization/ThaiBuddhistCalendar.cs @@ -2,6 +2,7 @@ // The .NET Foundation licenses this file to you under the MIT license. // See the LICENSE file in the project root for more information. +#nullable enable namespace System.Globalization { /// @@ -124,7 +125,7 @@ namespace System.Globalization return _helper.ToDateTime(year, month, day, hour, minute, second, millisecond, era); } - public override int[] Eras => _helper.Eras; + public override int[]? Eras => _helper.Eras; private const int DefaultTwoDigitYearMax = 2572; diff --git a/src/System.Private.CoreLib/shared/System/Globalization/UmAlQuraCalendar.cs b/src/System.Private.CoreLib/shared/System/Globalization/UmAlQuraCalendar.cs index 7b52e83..8af839f 100644 --- a/src/System.Private.CoreLib/shared/System/Globalization/UmAlQuraCalendar.cs +++ b/src/System.Private.CoreLib/shared/System/Globalization/UmAlQuraCalendar.cs @@ -2,6 +2,7 @@ // The .NET Foundation licenses this file to you under the MIT license. // See the LICENSE file in the project root for more information. +#nullable enable using System.Diagnostics; namespace System.Globalization @@ -519,7 +520,7 @@ namespace System.Globalization return UmAlQuraEra; } - public override int[] Eras => new int[] { UmAlQuraEra }; + public override int[]? Eras => new int[] { UmAlQuraEra }; public override int GetMonth(DateTime time) { -- 2.7.4