Fix build errors due to merge conflicts
authorSantiago Fernandez Madero <safern@microsoft.com>
Thu, 11 Apr 2019 23:08:05 +0000 (16:08 -0700)
committerSantiago Fernandez Madero <safern@microsoft.com>
Thu, 11 Apr 2019 23:08:05 +0000 (16:08 -0700)
Commit migrated from https://github.com/dotnet/coreclr/commit/e65ab1c53b8e234c77d9746a91e9a9c03aecb335

src/coreclr/src/System.Private.CoreLib/src/System/Reflection/Assembly.CoreCLR.cs
src/coreclr/src/System.Private.CoreLib/src/System/Reflection/AssemblyName.CoreCLR.cs
src/coreclr/src/System.Private.CoreLib/src/System/Reflection/RuntimeAssembly.cs
src/libraries/System.Private.CoreLib/src/System/Reflection/AssemblyName.cs
src/libraries/System.Private.CoreLib/src/System/Runtime/CompilerServices/RuntimeHelpers.cs
src/libraries/System.Private.CoreLib/src/System/Runtime/Loader/AssemblyLoadContext.cs
src/libraries/System.Private.CoreLib/src/System/Threading/TimerQueue.Windows.cs

index fd8420d..edc0c09 100644 (file)
@@ -5,6 +5,7 @@
 #nullable enable
 using System.Runtime.CompilerServices;
 using System.Runtime.InteropServices;
+using System.Runtime.Loader;
 using System.Runtime.Serialization;
 using StackCrawlMark = System.Threading.StackCrawlMark;
 
@@ -35,7 +36,7 @@ namespace System.Reflection
 
         // Locate an assembly by its name. The name can be strong or
         // weak. The assembly is loaded into the domain of the caller.
-        internal static Assembly Load(AssemblyName assemblyRef, ref StackCrawlMark stackMark, AssemblyLoadContext assemblyLoadContext)
+        internal static Assembly Load(AssemblyName assemblyRef, ref StackCrawlMark stackMark, AssemblyLoadContext? assemblyLoadContext)
         {
             AssemblyName? modifiedAssemblyRef = null;
             if (assemblyRef.CodeBase != null)
index 7b6e5b9..e6bc0b7 100644 (file)
@@ -22,7 +22,7 @@ namespace System.Reflection
                 throw new ArgumentException(SR.Format_StringZeroLength);
 
             _name = assemblyName;
-            nInit(out RuntimeAssembly dummy, false);
+            nInit(out RuntimeAssembly? dummy, false);
         }
 
         internal AssemblyName(string? name,
index a2c7b8e..16dc8ec 100644 (file)
@@ -164,7 +164,7 @@ namespace System.Reflection
 
             RuntimeType? type = null;
             object? keepAlive = null;
-            AssemblyLoadContext assemblyLoadContextStack = AssemblyLoadContext.CurrentContextualReflectionContext;
+            AssemblyLoadContext? assemblyLoadContextStack = AssemblyLoadContext.CurrentContextualReflectionContext;
 
             GetType(GetNativeHandle(),
                     name,
@@ -302,7 +302,7 @@ namespace System.Reflection
             return CustomAttributeData.GetCustomAttributesInternal(this);
         }
 
-        internal static RuntimeAssembly InternalLoad(string assemblyString, ref StackCrawlMark stackMark, AssemblyLoadContext assemblyLoadContext = null)
+        internal static RuntimeAssembly InternalLoad(string assemblyString, ref StackCrawlMark stackMark, AssemblyLoadContext? assemblyLoadContext = null)
         {
             RuntimeAssembly? assembly;
             AssemblyName an = CreateAssemblyName(assemblyString, out assembly);
@@ -336,7 +336,7 @@ namespace System.Reflection
             return an;
         }
 
-        internal static RuntimeAssembly InternalLoadAssemblyName(AssemblyName assemblyRef, ref StackCrawlMark stackMark, AssemblyLoadContext assemblyLoadContext = null)
+        internal static RuntimeAssembly InternalLoadAssemblyName(AssemblyName assemblyRef, ref StackCrawlMark stackMark, AssemblyLoadContext? assemblyLoadContext = null)
         {
 #if FEATURE_APPX
             if (ApplicationModel.IsUap)
@@ -366,7 +366,7 @@ namespace System.Reflection
                                                     RuntimeAssembly? assemblyContext,
                                                     ref StackCrawlMark stackMark,
                                                     bool throwOnFileNotFound,
-                                                    AssemblyLoadContext assemblyLoadContext = null);
+                                                    AssemblyLoadContext? assemblyLoadContext = null);
 
         public override bool ReflectionOnly
         {
index 7542e5a..7610268 100644 (file)
@@ -135,10 +135,10 @@ namespace System.Reflection
             var name = new AssemblyName
             {
                 _name = _name,
-                _publicKey = (byte[])_publicKey?.Clone(),
-                _publicKeyToken = (byte[])_publicKeyToken?.Clone(),
+                _publicKey = (byte[]?)_publicKey?.Clone(),
+                _publicKeyToken = (byte[]?)_publicKeyToken?.Clone(),
                 _cultureInfo = _cultureInfo,
-                _version = (Version)_version?.Clone(),
+                _version = (Version?)_version?.Clone(),
                 _flags = _flags,
                 _codeBase = _codeBase,
                 _hashAlgorithm = _hashAlgorithm,
index 5528139..2ec8b76 100644 (file)
@@ -24,9 +24,9 @@ namespace System.Runtime.CompilerServices
                 ThrowHelper.ThrowArgumentNullException(ExceptionArgument.array);
             }
 
-            (int offset, int length) = range.GetOffsetAndLength(array.Length);
+            (int offset, int length) = range.GetOffsetAndLength(array!.Length); // TODO-NULLABLE: https://github.com/dotnet/csharplang/issues/538
 
-            if (default(T) != null || typeof(T[]) == array.GetType())
+            if (default(T)! != null || typeof(T[]) == array.GetType()) // TODO-NULLABLE: https://github.com/dotnet/roslyn/issues/34757
             {
                 // We know the type of the array to be exactly T[].
 
index 8cabd5c..038a076 100644 (file)
@@ -444,7 +444,7 @@ namespace System.Runtime.Loader
             }
         }
 
-        private static AsyncLocal<AssemblyLoadContext> s_asyncLocalCurrent;
+        private static AsyncLocal<AssemblyLoadContext>? s_asyncLocalCurrent;
 
         /// <summary>Nullable current AssemblyLoadContext used for context sensitive reflection APIs</summary>
         /// <remarks>
@@ -470,18 +470,18 @@ namespace System.Runtime.Loader
         ///
         /// For more details see https://github.com/dotnet/coreclr/blob/master/Documentation/design-docs/AssemblyLoadContext.ContextualReflection.md
         /// </remarks>
-        public static AssemblyLoadContext CurrentContextualReflectionContext
+        public static AssemblyLoadContext? CurrentContextualReflectionContext
         {
             get { return s_asyncLocalCurrent?.Value; }
         }
 
-        private static void SetCurrentContextualReflectionContext(AssemblyLoadContext value)
+        private static void SetCurrentContextualReflectionContext(AssemblyLoadContext? value)
         {
             if (s_asyncLocalCurrent == null)
             {
-                Interlocked.CompareExchange(ref s_asyncLocalCurrent, new AsyncLocal<AssemblyLoadContext>(), null);
+                Interlocked.CompareExchange<AsyncLocal<AssemblyLoadContext>?>(ref s_asyncLocalCurrent, new AsyncLocal<AssemblyLoadContext>(), null);
             }
-            s_asyncLocalCurrent.Value = value;
+            s_asyncLocalCurrent!.Value = value!; // TODO-NULLABLE-GENERIC
         }
 
         /// <summary>Enter scope using this AssemblyLoadContext for ContextualReflection</summary>
@@ -508,10 +508,10 @@ namespace System.Runtime.Loader
         /// Returns a disposable ContextualReflectionScope for use in a using block. When the using calls the
         /// Dispose() method, it restores the ContextualReflectionScope to its previous value.
         /// </remarks>
-        public static ContextualReflectionScope EnterContextualReflection(Assembly activating)
+        public static ContextualReflectionScope EnterContextualReflection(Assembly? activating)
         {
             return activating != null ?
-                GetLoadContext(activating).EnterContextualReflection() :
+                GetLoadContext(activating)?.EnterContextualReflection() ?? default :
                 new ContextualReflectionScope(null);
         }
 
@@ -525,11 +525,11 @@ namespace System.Runtime.Loader
         [EditorBrowsable(EditorBrowsableState.Never)]
         public struct ContextualReflectionScope : IDisposable
         {
-            private readonly AssemblyLoadContext _activated;
-            private readonly AssemblyLoadContext _predecessor;
+            private readonly AssemblyLoadContext? _activated;
+            private readonly AssemblyLoadContext? _predecessor;
             private readonly bool _initialized;
 
-            internal ContextualReflectionScope(AssemblyLoadContext activating)
+            internal ContextualReflectionScope(AssemblyLoadContext? activating)
             {
                 _predecessor = AssemblyLoadContext.CurrentContextualReflectionContext;
                 AssemblyLoadContext.SetCurrentContextualReflectionContext(activating);
index 923add5..5421b9f 100644 (file)
@@ -26,7 +26,7 @@ namespace System.Threading
 
                     bool result = Interop.Kernel32.QueryUnbiasedInterruptTime(out time100ns);
                     if (!result)
-                        Marshal.ThrowExceptionForHR(Marshal.GetLastWin32Error())!;
+                        Marshal.ThrowExceptionForHR(Marshal.GetLastWin32Error());
 
                     // convert to 100ns to milliseconds, and truncate to 32 bits.
                     return (int)(uint)(time100ns / 10000);