Skip to content
This repository was archived by the owner on Jan 23, 2023. It is now read-only.

Commit 3d4806e

Browse files
authored
Fix nullability annotations for static (#25914)
The compiler is now analyzing statics. Get compliant.
1 parent ca3c39c commit 3d4806e

File tree

21 files changed

+30
-29
lines changed

21 files changed

+30
-29
lines changed

src/System.Private.CoreLib/shared/System/Diagnostics/Tracing/EventSource.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3956,7 +3956,7 @@ private bool SelfDescribingEvents
39563956
// Rather than depending on initialized statics, use lazy initialization to ensure that the statics are initialized exactly when they are needed.
39573957

39583958
// used for generating GUID from eventsource name
3959-
private static byte[] namespaceBytes;
3959+
private static byte[]? namespaceBytes;
39603960

39613961
#endregion
39623962
}

src/System.Private.CoreLib/shared/System/Environment.Win32.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -404,7 +404,7 @@ private static string GetKnownFolderPath(string folderGuid, SpecialFolderOption
404404
#if FEATURE_APPX
405405
private static class WinRTFolderPaths
406406
{
407-
private static Func<SpecialFolder, SpecialFolderOption, string> s_winRTFolderPathsGetFolderPath;
407+
private static Func<SpecialFolder, SpecialFolderOption, string>? s_winRTFolderPathsGetFolderPath;
408408

409409
public static string GetFolderPath(SpecialFolder folder, SpecialFolderOption option)
410410
{

src/System.Private.CoreLib/shared/System/Globalization/CultureInfo.Windows.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ public partial class CultureInfo : IFormatProvider
1313
{
1414
#if FEATURE_APPX
1515
// When running under AppX, we use this to get some information about the language list
16-
private static volatile WindowsRuntimeResourceManagerBase s_WindowsRuntimeResourceManager;
16+
private static volatile WindowsRuntimeResourceManagerBase? s_WindowsRuntimeResourceManager;
1717

1818
[ThreadStatic]
1919
private static bool ts_IsDoingAppXCultureInfoLookup;

src/System.Private.CoreLib/shared/System/Globalization/DateTimeFormatInfo.cs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ public sealed class DateTimeFormatInfo : IFormatProvider, ICloneable
5151
{
5252
// cache for the invariant culture.
5353
// invariantInfo is constant irrespective of your current culture.
54-
private static volatile DateTimeFormatInfo s_invariantInfo;
54+
private static volatile DateTimeFormatInfo? s_invariantInfo;
5555

5656
// an index which points to a record in Culture Data Table.
5757
private CultureData _cultureData;
@@ -2135,8 +2135,8 @@ internal bool YearMonthAdjustment(ref int year, ref int month, bool parsedMonthN
21352135
internal const string JapaneseLangName = "ja";
21362136
internal const string EnglishLangName = "en";
21372137

2138-
private static volatile DateTimeFormatInfo s_jajpDTFI;
2139-
private static volatile DateTimeFormatInfo s_zhtwDTFI;
2138+
private static volatile DateTimeFormatInfo? s_jajpDTFI;
2139+
private static volatile DateTimeFormatInfo? s_zhtwDTFI;
21402140

21412141
/// <summary>
21422142
/// Create a Japanese DTFI which uses JapaneseCalendar. This is used to parse
@@ -2146,7 +2146,7 @@ internal bool YearMonthAdjustment(ref int year, ref int month, bool parsedMonthN
21462146
/// </summary>
21472147
internal static DateTimeFormatInfo GetJapaneseCalendarDTFI()
21482148
{
2149-
DateTimeFormatInfo temp = s_jajpDTFI;
2149+
DateTimeFormatInfo? temp = s_jajpDTFI;
21502150
if (temp == null)
21512151
{
21522152
temp = new CultureInfo("ja-JP", false).DateTimeFormat;
@@ -2164,7 +2164,7 @@ internal static DateTimeFormatInfo GetJapaneseCalendarDTFI()
21642164
/// </summary>
21652165
internal static DateTimeFormatInfo GetTaiwanCalendarDTFI()
21662166
{
2167-
DateTimeFormatInfo temp = s_zhtwDTFI;
2167+
DateTimeFormatInfo? temp = s_zhtwDTFI;
21682168
if (temp == null)
21692169
{
21702170
temp = new CultureInfo("zh-TW", false).DateTimeFormat;

src/System.Private.CoreLib/shared/System/Globalization/DateTimeFormatInfoScanner.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -115,7 +115,7 @@ internal class DateTimeFormatInfoScanner
115115
// The collection fo date words & postfix.
116116
internal List<string> m_dateWords = new List<string>();
117117
// Hashtable for the known words.
118-
private static volatile Dictionary<string, string> s_knownWords;
118+
private static volatile Dictionary<string, string>? s_knownWords;
119119

120120
static Dictionary<string, string> KnownWords
121121
{
@@ -147,7 +147,7 @@ static Dictionary<string, string> KnownWords
147147

148148
s_knownWords = temp;
149149
}
150-
return (s_knownWords);
150+
return s_knownWords;
151151
}
152152
}
153153

src/System.Private.CoreLib/shared/System/Globalization/GregorianCalendar.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ public class GregorianCalendar : Calendar
2727

2828
private static readonly int[] DaysToMonth366 = { 0, 31, 60, 91, 121, 152, 182, 213, 244, 274, 305, 335, 366 };
2929

30-
private static volatile Calendar s_defaultInstance;
30+
private static volatile Calendar? s_defaultInstance;
3131

3232
public override DateTime MinSupportedDateTime => DateTime.MinValue;
3333

src/System.Private.CoreLib/shared/System/Globalization/JapaneseCalendar.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -81,7 +81,7 @@ internal static EraInfo[] GetEraInfo()
8181
});
8282
}
8383

84-
internal static volatile Calendar s_defaultInstance;
84+
internal static volatile Calendar? s_defaultInstance;
8585
internal GregorianCalendarHelper _helper;
8686

8787
internal static Calendar GetDefaultInstance()

src/System.Private.CoreLib/shared/System/Globalization/NumberFormatInfo.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ namespace System.Globalization
3535
/// </remarks>
3636
public sealed class NumberFormatInfo : IFormatProvider, ICloneable
3737
{
38-
private static volatile NumberFormatInfo s_invariantInfo;
38+
private static volatile NumberFormatInfo? s_invariantInfo;
3939

4040
internal int[] _numberGroupSizes = new int[] { 3 };
4141
internal int[] _currencyGroupSizes = new int[] { 3 };

src/System.Private.CoreLib/shared/System/Globalization/TaiwanCalendar.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ public class TaiwanCalendar : Calendar
3030
new EraInfo( 1, 1912, 1, 1, 1911, 1, GregorianCalendar.MaxYear - 1911) // era #, start year/month/day, yearOffset, minEraYear
3131
};
3232

33-
private static volatile Calendar s_defaultInstance;
33+
private static volatile Calendar? s_defaultInstance;
3434

3535
private readonly GregorianCalendarHelper _helper;
3636

src/System.Private.CoreLib/shared/System/IO/FileStreamCompletionSource.Win32.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ private unsafe class FileStreamCompletionSource : TaskCompletionSource<int>
2424
private const long CompletedCallback = (long)8 << 32;
2525
private const ulong ResultMask = ((ulong)uint.MaxValue) << 32;
2626

27-
private static Action<object?> s_cancelCallback;
27+
private static Action<object?>? s_cancelCallback;
2828

2929
private readonly FileStream _stream;
3030
private readonly int _numBufferedBytes;

0 commit comments

Comments
 (0)