summaryrefslogtreecommitdiff
path: root/src/System.Private.CoreLib
diff options
context:
space:
mode:
authorStephen Toub <stoub@microsoft.com>2019-07-28 20:14:40 -0400
committerGitHub <noreply@github.com>2019-07-28 20:14:40 -0400
commit3d4806e5bfc512128ed710e287ec7df141ce702b (patch)
tree5ffadcfdc4ce593285eecf2d21d2efca1a00e70f /src/System.Private.CoreLib
parentca3c39c977349c3a5d1a992253976aa9f615a2c0 (diff)
downloadcoreclr-3d4806e5bfc512128ed710e287ec7df141ce702b.tar.gz
coreclr-3d4806e5bfc512128ed710e287ec7df141ce702b.tar.bz2
coreclr-3d4806e5bfc512128ed710e287ec7df141ce702b.zip
Fix nullability annotations for static (#25914)
The compiler is now analyzing statics. Get compliant.
Diffstat (limited to 'src/System.Private.CoreLib')
-rw-r--r--src/System.Private.CoreLib/shared/System/Diagnostics/Tracing/EventSource.cs2
-rw-r--r--src/System.Private.CoreLib/shared/System/Environment.Win32.cs2
-rw-r--r--src/System.Private.CoreLib/shared/System/Globalization/CultureInfo.Windows.cs2
-rw-r--r--src/System.Private.CoreLib/shared/System/Globalization/DateTimeFormatInfo.cs10
-rw-r--r--src/System.Private.CoreLib/shared/System/Globalization/DateTimeFormatInfoScanner.cs4
-rw-r--r--src/System.Private.CoreLib/shared/System/Globalization/GregorianCalendar.cs2
-rw-r--r--src/System.Private.CoreLib/shared/System/Globalization/JapaneseCalendar.cs2
-rw-r--r--src/System.Private.CoreLib/shared/System/Globalization/NumberFormatInfo.cs2
-rw-r--r--src/System.Private.CoreLib/shared/System/Globalization/TaiwanCalendar.cs2
-rw-r--r--src/System.Private.CoreLib/shared/System/IO/FileStreamCompletionSource.Win32.cs2
-rw-r--r--src/System.Private.CoreLib/shared/System/IO/Stream.cs2
-rw-r--r--src/System.Private.CoreLib/shared/System/Random.cs4
-rw-r--r--src/System.Private.CoreLib/shared/System/Runtime/Serialization/SerializationInfo.cs2
-rw-r--r--src/System.Private.CoreLib/shared/System/Threading/ThreadPool.cs6
-rw-r--r--src/System.Private.CoreLib/src/System/Diagnostics/Eventing/RuntimeEventSource.cs2
-rw-r--r--src/System.Private.CoreLib/src/System/Reflection/Emit/DynamicMethod.cs2
-rw-r--r--src/System.Private.CoreLib/src/System/Runtime/InteropServices/WindowsRuntime/CLRIPropertyValueImpl.cs2
-rw-r--r--src/System.Private.CoreLib/src/System/Runtime/InteropServices/WindowsRuntime/WindowsRuntimeMetadata.cs2
-rw-r--r--src/System.Private.CoreLib/src/System/RuntimeType.CoreCLR.cs2
-rw-r--r--src/System.Private.CoreLib/src/System/String.CoreCLR.cs2
-rw-r--r--src/System.Private.CoreLib/src/System/Threading/Tasks/AsyncCausalityTracer.cs3
21 files changed, 30 insertions, 29 deletions
diff --git a/src/System.Private.CoreLib/shared/System/Diagnostics/Tracing/EventSource.cs b/src/System.Private.CoreLib/shared/System/Diagnostics/Tracing/EventSource.cs
index 93687a6de0..b03011c10e 100644
--- a/src/System.Private.CoreLib/shared/System/Diagnostics/Tracing/EventSource.cs
+++ b/src/System.Private.CoreLib/shared/System/Diagnostics/Tracing/EventSource.cs
@@ -3956,7 +3956,7 @@ namespace System.Diagnostics.Tracing
// Rather than depending on initialized statics, use lazy initialization to ensure that the statics are initialized exactly when they are needed.
// used for generating GUID from eventsource name
- private static byte[] namespaceBytes;
+ private static byte[]? namespaceBytes;
#endregion
}
diff --git a/src/System.Private.CoreLib/shared/System/Environment.Win32.cs b/src/System.Private.CoreLib/shared/System/Environment.Win32.cs
index 78d49b1bcc..37213f0d76 100644
--- a/src/System.Private.CoreLib/shared/System/Environment.Win32.cs
+++ b/src/System.Private.CoreLib/shared/System/Environment.Win32.cs
@@ -404,7 +404,7 @@ namespace System
#if FEATURE_APPX
private static class WinRTFolderPaths
{
- private static Func<SpecialFolder, SpecialFolderOption, string> s_winRTFolderPathsGetFolderPath;
+ private static Func<SpecialFolder, SpecialFolderOption, string>? s_winRTFolderPathsGetFolderPath;
public static string GetFolderPath(SpecialFolder folder, SpecialFolderOption option)
{
diff --git a/src/System.Private.CoreLib/shared/System/Globalization/CultureInfo.Windows.cs b/src/System.Private.CoreLib/shared/System/Globalization/CultureInfo.Windows.cs
index d746659fd2..775ee4ee9d 100644
--- a/src/System.Private.CoreLib/shared/System/Globalization/CultureInfo.Windows.cs
+++ b/src/System.Private.CoreLib/shared/System/Globalization/CultureInfo.Windows.cs
@@ -13,7 +13,7 @@ namespace System.Globalization
{
#if FEATURE_APPX
// When running under AppX, we use this to get some information about the language list
- private static volatile WindowsRuntimeResourceManagerBase s_WindowsRuntimeResourceManager;
+ private static volatile WindowsRuntimeResourceManagerBase? s_WindowsRuntimeResourceManager;
[ThreadStatic]
private static bool ts_IsDoingAppXCultureInfoLookup;
diff --git a/src/System.Private.CoreLib/shared/System/Globalization/DateTimeFormatInfo.cs b/src/System.Private.CoreLib/shared/System/Globalization/DateTimeFormatInfo.cs
index b8167d90a2..db64442035 100644
--- a/src/System.Private.CoreLib/shared/System/Globalization/DateTimeFormatInfo.cs
+++ b/src/System.Private.CoreLib/shared/System/Globalization/DateTimeFormatInfo.cs
@@ -51,7 +51,7 @@ namespace System.Globalization
{
// cache for the invariant culture.
// invariantInfo is constant irrespective of your current culture.
- private static volatile DateTimeFormatInfo s_invariantInfo;
+ private static volatile DateTimeFormatInfo? s_invariantInfo;
// an index which points to a record in Culture Data Table.
private CultureData _cultureData;
@@ -2135,8 +2135,8 @@ namespace System.Globalization
internal const string JapaneseLangName = "ja";
internal const string EnglishLangName = "en";
- private static volatile DateTimeFormatInfo s_jajpDTFI;
- private static volatile DateTimeFormatInfo s_zhtwDTFI;
+ private static volatile DateTimeFormatInfo? s_jajpDTFI;
+ private static volatile DateTimeFormatInfo? s_zhtwDTFI;
/// <summary>
/// Create a Japanese DTFI which uses JapaneseCalendar. This is used to parse
@@ -2146,7 +2146,7 @@ namespace System.Globalization
/// </summary>
internal static DateTimeFormatInfo GetJapaneseCalendarDTFI()
{
- DateTimeFormatInfo temp = s_jajpDTFI;
+ DateTimeFormatInfo? temp = s_jajpDTFI;
if (temp == null)
{
temp = new CultureInfo("ja-JP", false).DateTimeFormat;
@@ -2164,7 +2164,7 @@ namespace System.Globalization
/// </summary>
internal static DateTimeFormatInfo GetTaiwanCalendarDTFI()
{
- DateTimeFormatInfo temp = s_zhtwDTFI;
+ DateTimeFormatInfo? temp = s_zhtwDTFI;
if (temp == null)
{
temp = new CultureInfo("zh-TW", false).DateTimeFormat;
diff --git a/src/System.Private.CoreLib/shared/System/Globalization/DateTimeFormatInfoScanner.cs b/src/System.Private.CoreLib/shared/System/Globalization/DateTimeFormatInfoScanner.cs
index 7b5ae00b69..accc5b9b63 100644
--- a/src/System.Private.CoreLib/shared/System/Globalization/DateTimeFormatInfoScanner.cs
+++ b/src/System.Private.CoreLib/shared/System/Globalization/DateTimeFormatInfoScanner.cs
@@ -115,7 +115,7 @@ namespace System.Globalization
// The collection fo date words & postfix.
internal List<string> m_dateWords = new List<string>();
// Hashtable for the known words.
- private static volatile Dictionary<string, string> s_knownWords;
+ private static volatile Dictionary<string, string>? s_knownWords;
static Dictionary<string, string> KnownWords
{
@@ -147,7 +147,7 @@ namespace System.Globalization
s_knownWords = temp;
}
- return (s_knownWords);
+ return s_knownWords;
}
}
diff --git a/src/System.Private.CoreLib/shared/System/Globalization/GregorianCalendar.cs b/src/System.Private.CoreLib/shared/System/Globalization/GregorianCalendar.cs
index ebc5a54f40..2be5a220cd 100644
--- a/src/System.Private.CoreLib/shared/System/Globalization/GregorianCalendar.cs
+++ b/src/System.Private.CoreLib/shared/System/Globalization/GregorianCalendar.cs
@@ -27,7 +27,7 @@ namespace System.Globalization
private static readonly int[] DaysToMonth366 = { 0, 31, 60, 91, 121, 152, 182, 213, 244, 274, 305, 335, 366 };
- private static volatile Calendar s_defaultInstance;
+ private static volatile Calendar? s_defaultInstance;
public override DateTime MinSupportedDateTime => DateTime.MinValue;
diff --git a/src/System.Private.CoreLib/shared/System/Globalization/JapaneseCalendar.cs b/src/System.Private.CoreLib/shared/System/Globalization/JapaneseCalendar.cs
index b0428db0a5..fcc2302fcd 100644
--- a/src/System.Private.CoreLib/shared/System/Globalization/JapaneseCalendar.cs
+++ b/src/System.Private.CoreLib/shared/System/Globalization/JapaneseCalendar.cs
@@ -81,7 +81,7 @@ namespace System.Globalization
});
}
- internal static volatile Calendar s_defaultInstance;
+ internal static volatile Calendar? s_defaultInstance;
internal GregorianCalendarHelper _helper;
internal static Calendar GetDefaultInstance()
diff --git a/src/System.Private.CoreLib/shared/System/Globalization/NumberFormatInfo.cs b/src/System.Private.CoreLib/shared/System/Globalization/NumberFormatInfo.cs
index 3078c8e576..7af038162f 100644
--- a/src/System.Private.CoreLib/shared/System/Globalization/NumberFormatInfo.cs
+++ b/src/System.Private.CoreLib/shared/System/Globalization/NumberFormatInfo.cs
@@ -35,7 +35,7 @@ namespace System.Globalization
/// </remarks>
public sealed class NumberFormatInfo : IFormatProvider, ICloneable
{
- private static volatile NumberFormatInfo s_invariantInfo;
+ private static volatile NumberFormatInfo? s_invariantInfo;
internal int[] _numberGroupSizes = new int[] { 3 };
internal int[] _currencyGroupSizes = new int[] { 3 };
diff --git a/src/System.Private.CoreLib/shared/System/Globalization/TaiwanCalendar.cs b/src/System.Private.CoreLib/shared/System/Globalization/TaiwanCalendar.cs
index e190f66377..a0f64c9df2 100644
--- a/src/System.Private.CoreLib/shared/System/Globalization/TaiwanCalendar.cs
+++ b/src/System.Private.CoreLib/shared/System/Globalization/TaiwanCalendar.cs
@@ -30,7 +30,7 @@ namespace System.Globalization
new EraInfo( 1, 1912, 1, 1, 1911, 1, GregorianCalendar.MaxYear - 1911) // era #, start year/month/day, yearOffset, minEraYear
};
- private static volatile Calendar s_defaultInstance;
+ private static volatile Calendar? s_defaultInstance;
private readonly GregorianCalendarHelper _helper;
diff --git a/src/System.Private.CoreLib/shared/System/IO/FileStreamCompletionSource.Win32.cs b/src/System.Private.CoreLib/shared/System/IO/FileStreamCompletionSource.Win32.cs
index 837946e04f..246538b42b 100644
--- a/src/System.Private.CoreLib/shared/System/IO/FileStreamCompletionSource.Win32.cs
+++ b/src/System.Private.CoreLib/shared/System/IO/FileStreamCompletionSource.Win32.cs
@@ -24,7 +24,7 @@ namespace System.IO
private const long CompletedCallback = (long)8 << 32;
private const ulong ResultMask = ((ulong)uint.MaxValue) << 32;
- private static Action<object?> s_cancelCallback;
+ private static Action<object?>? s_cancelCallback;
private readonly FileStream _stream;
private readonly int _numBufferedBytes;
diff --git a/src/System.Private.CoreLib/shared/System/IO/Stream.cs b/src/System.Private.CoreLib/shared/System/IO/Stream.cs
index 4b3b0d3a06..85899ef98f 100644
--- a/src/System.Private.CoreLib/shared/System/IO/Stream.cs
+++ b/src/System.Private.CoreLib/shared/System/IO/Stream.cs
@@ -644,7 +644,7 @@ namespace System.IO
callback(rwc);
}
- private static ContextCallback s_invokeAsyncCallback;
+ private static ContextCallback? s_invokeAsyncCallback;
void ITaskCompletionAction.Invoke(Task completingTask)
{
diff --git a/src/System.Private.CoreLib/shared/System/Random.cs b/src/System.Private.CoreLib/shared/System/Random.cs
index ed79732c25..709fc0c5e4 100644
--- a/src/System.Private.CoreLib/shared/System/Random.cs
+++ b/src/System.Private.CoreLib/shared/System/Random.cs
@@ -116,7 +116,7 @@ namespace System
}
[ThreadStatic]
- private static Random t_threadRandom;
+ private static Random? t_threadRandom;
private static readonly Random s_globalRandom = new Random(GenerateGlobalSeed());
/*=====================================GenerateSeed=====================================
@@ -125,7 +125,7 @@ namespace System
========================================================================================*/
private static int GenerateSeed()
{
- Random rnd = t_threadRandom;
+ Random? rnd = t_threadRandom;
if (rnd == null)
{
int seed;
diff --git a/src/System.Private.CoreLib/shared/System/Runtime/Serialization/SerializationInfo.cs b/src/System.Private.CoreLib/shared/System/Runtime/Serialization/SerializationInfo.cs
index a11fa94bb8..57f1cf0e0e 100644
--- a/src/System.Private.CoreLib/shared/System/Runtime/Serialization/SerializationInfo.cs
+++ b/src/System.Private.CoreLib/shared/System/Runtime/Serialization/SerializationInfo.cs
@@ -32,7 +32,7 @@ namespace System.Runtime.Serialization
// On AoT, assume private members are reflection blocked, so there's no further protection required
// for the thread's DeserializationTracker
[ThreadStatic]
- private static DeserializationTracker t_deserializationTracker;
+ private static DeserializationTracker? t_deserializationTracker;
private static DeserializationTracker GetThreadDeserializationTracker()
{
diff --git a/src/System.Private.CoreLib/shared/System/Threading/ThreadPool.cs b/src/System.Private.CoreLib/shared/System/Threading/ThreadPool.cs
index dca22ab35a..21d8e8f484 100644
--- a/src/System.Private.CoreLib/shared/System/Threading/ThreadPool.cs
+++ b/src/System.Private.CoreLib/shared/System/Threading/ThreadPool.cs
@@ -494,7 +494,7 @@ namespace System.Threading
internal bool LocalFindAndPop(object callback)
{
- ThreadPoolWorkQueueThreadLocals tl = ThreadPoolWorkQueueThreadLocals.threadLocals;
+ ThreadPoolWorkQueueThreadLocals? tl = ThreadPoolWorkQueueThreadLocals.threadLocals;
return tl != null && tl.workStealingQueue.LocalFindAndPop(callback);
}
@@ -728,7 +728,7 @@ namespace System.Threading
internal sealed class ThreadPoolWorkQueueThreadLocals
{
[ThreadStatic]
- public static ThreadPoolWorkQueueThreadLocals threadLocals;
+ public static ThreadPoolWorkQueueThreadLocals? threadLocals;
public readonly ThreadPoolWorkQueue workQueue;
public readonly ThreadPoolWorkQueue.WorkStealingQueue workStealingQueue;
@@ -1231,7 +1231,7 @@ namespace System.Threading
internal static IEnumerable<object> GetLocallyQueuedWorkItems()
{
- ThreadPoolWorkQueue.WorkStealingQueue wsq = ThreadPoolWorkQueueThreadLocals.threadLocals.workStealingQueue;
+ ThreadPoolWorkQueue.WorkStealingQueue? wsq = ThreadPoolWorkQueueThreadLocals.threadLocals?.workStealingQueue;
if (wsq != null && wsq.m_array != null)
{
object?[] items = wsq.m_array;
diff --git a/src/System.Private.CoreLib/src/System/Diagnostics/Eventing/RuntimeEventSource.cs b/src/System.Private.CoreLib/src/System/Diagnostics/Eventing/RuntimeEventSource.cs
index f8498a6fd3..5e6f57dc5d 100644
--- a/src/System.Private.CoreLib/src/System/Diagnostics/Eventing/RuntimeEventSource.cs
+++ b/src/System.Private.CoreLib/src/System/Diagnostics/Eventing/RuntimeEventSource.cs
@@ -12,7 +12,7 @@ namespace System.Diagnostics.Tracing
[EventSource(Guid="49592C0F-5A05-516D-AA4B-A64E02026C89", Name = "System.Runtime")]
internal sealed class RuntimeEventSource : EventSource
{
- private static RuntimeEventSource s_RuntimeEventSource;
+ private static RuntimeEventSource? s_RuntimeEventSource;
private PollingCounter? _gcHeapSizeCounter;
private IncrementingPollingCounter? _gen0GCCounter;
private IncrementingPollingCounter? _gen1GCCounter;
diff --git a/src/System.Private.CoreLib/src/System/Reflection/Emit/DynamicMethod.cs b/src/System.Private.CoreLib/src/System/Reflection/Emit/DynamicMethod.cs
index 0991b09a04..11db43e54d 100644
--- a/src/System.Private.CoreLib/src/System/Reflection/Emit/DynamicMethod.cs
+++ b/src/System.Private.CoreLib/src/System/Reflection/Emit/DynamicMethod.cs
@@ -41,7 +41,7 @@ namespace System.Reflection.Emit
// We capture the creation context so that we can do the checks against the same context,
// irrespective of when the method gets compiled. Note that the DynamicMethod does not know when
// it is ready for use since there is not API which indictates that IL generation has completed.
- private static volatile InternalModuleBuilder s_anonymouslyHostedDynamicMethodsModule;
+ private static volatile InternalModuleBuilder? s_anonymouslyHostedDynamicMethodsModule;
private static readonly object s_anonymouslyHostedDynamicMethodsModuleLock = new object();
//
diff --git a/src/System.Private.CoreLib/src/System/Runtime/InteropServices/WindowsRuntime/CLRIPropertyValueImpl.cs b/src/System.Private.CoreLib/src/System/Runtime/InteropServices/WindowsRuntime/CLRIPropertyValueImpl.cs
index 752f7bc34d..b4b1b59670 100644
--- a/src/System.Private.CoreLib/src/System/Runtime/InteropServices/WindowsRuntime/CLRIPropertyValueImpl.cs
+++ b/src/System.Private.CoreLib/src/System/Runtime/InteropServices/WindowsRuntime/CLRIPropertyValueImpl.cs
@@ -15,7 +15,7 @@ namespace System.Runtime.InteropServices.WindowsRuntime
private object _data;
// Numeric scalar types which participate in coersion
- private static volatile Tuple<Type, PropertyType>[] s_numericScalarTypes;
+ private static volatile Tuple<Type, PropertyType>[]? s_numericScalarTypes;
internal CLRIPropertyValueImpl(PropertyType type, object data)
{
diff --git a/src/System.Private.CoreLib/src/System/Runtime/InteropServices/WindowsRuntime/WindowsRuntimeMetadata.cs b/src/System.Private.CoreLib/src/System/Runtime/InteropServices/WindowsRuntime/WindowsRuntimeMetadata.cs
index ce1d0ef215..273b270f37 100644
--- a/src/System.Private.CoreLib/src/System/Runtime/InteropServices/WindowsRuntime/WindowsRuntimeMetadata.cs
+++ b/src/System.Private.CoreLib/src/System/Runtime/InteropServices/WindowsRuntime/WindowsRuntimeMetadata.cs
@@ -8,7 +8,7 @@ namespace System.Runtime.InteropServices.WindowsRuntime
{
internal static class WindowsRuntimeMetadata
{
- private static EventHandler<DesignerNamespaceResolveEventArgs> DesignerNamespaceResolve;
+ private static EventHandler<DesignerNamespaceResolveEventArgs>? DesignerNamespaceResolve;
internal static string[]? OnDesignerNamespaceResolve(string namespaceName)
{
diff --git a/src/System.Private.CoreLib/src/System/RuntimeType.CoreCLR.cs b/src/System.Private.CoreLib/src/System/RuntimeType.CoreCLR.cs
index 6e7527c4bb..02518db3d7 100644
--- a/src/System.Private.CoreLib/src/System/RuntimeType.CoreCLR.cs
+++ b/src/System.Private.CoreLib/src/System/RuntimeType.CoreCLR.cs
@@ -4342,7 +4342,7 @@ namespace System
}
}
- private static OleAutBinder s_ForwardCallBinder;
+ private static OleAutBinder? s_ForwardCallBinder;
private OleAutBinder ForwardCallBinder
{
get => s_ForwardCallBinder ?? (s_ForwardCallBinder = new OleAutBinder());
diff --git a/src/System.Private.CoreLib/src/System/String.CoreCLR.cs b/src/System.Private.CoreLib/src/System/String.CoreCLR.cs
index b942ea5336..79eeca6926 100644
--- a/src/System.Private.CoreLib/src/System/String.CoreCLR.cs
+++ b/src/System.Private.CoreLib/src/System/String.CoreCLR.cs
@@ -31,8 +31,10 @@ namespace System
// We need to call the String constructor so that the compiler doesn't mark this as a literal.
// Marking this as a literal would mean that it doesn't show up as a field which we can access
// from native.
+#pragma warning disable CS8618 // compiler sees this non-nullable static string as uninitialized
[Intrinsic]
public static readonly string Empty;
+#pragma warning restore CS8618
// Gets the character at a specified position.
//
diff --git a/src/System.Private.CoreLib/src/System/Threading/Tasks/AsyncCausalityTracer.cs b/src/System.Private.CoreLib/src/System/Threading/Tasks/AsyncCausalityTracer.cs
index 3332f44dba..614b61e4cc 100644
--- a/src/System.Private.CoreLib/src/System/Threading/Tasks/AsyncCausalityTracer.cs
+++ b/src/System.Private.CoreLib/src/System/Threading/Tasks/AsyncCausalityTracer.cs
@@ -33,8 +33,7 @@ namespace System.Threading.Tasks
//Indicates this information comes from the BCL Library
private const WFD.CausalitySource s_CausalitySource = WFD.CausalitySource.Library;
- //Lazy initialize the actual factory
- private static WFD.IAsyncCausalityTracerStatics s_TracerFactory;
+ private static WFD.IAsyncCausalityTracerStatics s_TracerFactory = null!;
// The loggers that this Tracer knows about.
[Flags]