diff options
author | Santiago Fernandez Madero <safern@microsoft.com> | 2019-04-12 02:08:05 +0300 |
---|---|---|
committer | dotnet-bot <dotnet-bot@microsoft.com> | 2019-04-22 19:37:53 +0300 |
commit | 88f40c05472cf5dc81ff926fa1cbbbbf235181ec (patch) | |
tree | ffb7ca93b1988cd1c05fb0056828d5eb532aee97 /netcore/System.Private.CoreLib/shared/System/Runtime/Loader/AssemblyLoadContext.cs | |
parent | b4ed8f67820ecda2bb31bc6c6d25f502f0bf4ec5 (diff) |
Fix build errors due to merge conflicts
Signed-off-by: dotnet-bot <dotnet-bot@microsoft.com>
Diffstat (limited to 'netcore/System.Private.CoreLib/shared/System/Runtime/Loader/AssemblyLoadContext.cs')
-rw-r--r-- | netcore/System.Private.CoreLib/shared/System/Runtime/Loader/AssemblyLoadContext.cs | 34 |
1 files changed, 13 insertions, 21 deletions
diff --git a/netcore/System.Private.CoreLib/shared/System/Runtime/Loader/AssemblyLoadContext.cs b/netcore/System.Private.CoreLib/shared/System/Runtime/Loader/AssemblyLoadContext.cs index c0a118c8e7b..8cabd5c2950 100644 --- a/netcore/System.Private.CoreLib/shared/System/Runtime/Loader/AssemblyLoadContext.cs +++ b/netcore/System.Private.CoreLib/shared/System/Runtime/Loader/AssemblyLoadContext.cs @@ -8,6 +8,7 @@ using System.ComponentModel; using System.Diagnostics; using System.IO; using System.Reflection; +using System.Runtime.CompilerServices; using System.Runtime.InteropServices; using System.Threading; @@ -443,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> @@ -469,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<AsyncLocal<AssemblyLoadContext>?>(ref s_asyncLocalCurrent, new AsyncLocal<AssemblyLoadContext>(), null); + Interlocked.CompareExchange(ref s_asyncLocalCurrent, new AsyncLocal<AssemblyLoadContext>(), null); } - s_asyncLocalCurrent!.Value = value!; // TODO-NULLABLE-GENERIC + s_asyncLocalCurrent.Value = value; } /// <summary>Enter scope using this AssemblyLoadContext for ContextualReflection</summary> @@ -507,20 +508,11 @@ 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) { - if (activating == null) - return new ContextualReflectionScope(null); - - AssemblyLoadContext? assemblyLoadContext = GetLoadContext(activating); - - if (assemblyLoadContext == null) - { - // All RuntimeAssemblies & Only RuntimeAssemblies have an AssemblyLoadContext - throw new ArgumentException(SR.Arg_MustBeRuntimeAssembly, nameof(activating)); - } - - return assemblyLoadContext.EnterContextualReflection(); + return activating != null ? + GetLoadContext(activating).EnterContextualReflection() : + new ContextualReflectionScope(null); } /// <summary>Opaque disposable struct used to restore CurrentContextualReflectionContext</summary> @@ -533,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); |