From: Rahul Kumar Date: Tue, 8 Nov 2016 19:13:33 +0000 (-0800) Subject: Expose AppDomain::AssemblyResolve X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=5812c03f214da72df18b41c478d4b4bb8e1bc4c1;p=platform%2Fupstream%2Fcoreclr.git Expose AppDomain::AssemblyResolve --- diff --git a/src/mscorlib/model.xml b/src/mscorlib/model.xml index 95284d5bf0..5fb44e8075 100644 --- a/src/mscorlib/model.xml +++ b/src/mscorlib/model.xml @@ -1054,6 +1054,7 @@ + diff --git a/src/mscorlib/ref/mscorlib.cs b/src/mscorlib/ref/mscorlib.cs index 1b6611c112..4c364ada18 100644 --- a/src/mscorlib/ref/mscorlib.cs +++ b/src/mscorlib/ref/mscorlib.cs @@ -11971,6 +11971,7 @@ namespace System.Runtime.Loader public event System.Func Resolving { add { } remove { } } public event System.Action Unloading { add { } remove { } } public static event AssemblyLoadEventHandler AssemblyLoad { add { } remove { } } + public static event ResolveEventHandler AssemblyResolve { add { } remove { } } public static event ResolveEventHandler TypeResolve { add { } remove { } } public static event ResolveEventHandler ResourceResolve { add { } remove { } } public static System.Reflection.AssemblyName GetAssemblyName(string assemblyPath) { throw null; } diff --git a/src/mscorlib/src/System/Reflection/Assembly.cs b/src/mscorlib/src/System/Reflection/Assembly.cs index 4383c432b4..04f7faef97 100644 --- a/src/mscorlib/src/System/Reflection/Assembly.cs +++ b/src/mscorlib/src/System/Reflection/Assembly.cs @@ -484,7 +484,7 @@ namespace System.Reflection #if FEATURE_CORECLR if(rawAssembly == null) throw new ArgumentNullException(nameof(rawAssembly)); - AssemblyLoadContext alc = new FileLoadAssemblyLoadContext(); + AssemblyLoadContext alc = new IndividualAssemblyLoadContext(); MemoryStream assemblyStream = new MemoryStream(rawAssembly); MemoryStream symbolStream = (rawSymbolStore!=null)?new MemoryStream(rawSymbolStore):null; return alc.LoadFromStream(assemblyStream, symbolStream); @@ -595,7 +595,7 @@ namespace System.Reflection { if(s_loadfile.TryGetValue(normalizedPath, out result)) return result; - AssemblyLoadContext alc = new FileLoadAssemblyLoadContext(); + AssemblyLoadContext alc = new IndividualAssemblyLoadContext(); result = alc.LoadFromAssemblyPath(normalizedPath); s_loadfile.Add(normalizedPath, result); } diff --git a/src/mscorlib/src/System/Runtime/Loader/AssemblyLoadContext.cs b/src/mscorlib/src/System/Runtime/Loader/AssemblyLoadContext.cs index d46d0d0d88..fd896a6b42 100644 --- a/src/mscorlib/src/System/Runtime/Loader/AssemblyLoadContext.cs +++ b/src/mscorlib/src/System/Runtime/Loader/AssemblyLoadContext.cs @@ -491,6 +491,14 @@ namespace System.Runtime.Loader add { AppDomain.CurrentDomain.ResourceResolve += value; } remove { AppDomain.CurrentDomain.ResourceResolve -= value; } } + + // Occurs when resolution of assembly fails + // This event is fired after resolve events of AssemblyLoadContext fails + public static event ResolveEventHandler AssemblyResolve + { + add { AppDomain.CurrentDomain.AssemblyResolve += value; } + remove { AppDomain.CurrentDomain.AssemblyResolve -= value; } + } } [System.Security.SecuritySafeCritical] @@ -510,9 +518,9 @@ namespace System.Runtime.Loader } [System.Security.SecuritySafeCritical] - internal class FileLoadAssemblyLoadContext : AssemblyLoadContext + internal class IndividualAssemblyLoadContext : AssemblyLoadContext { - internal FileLoadAssemblyLoadContext() : base(false) + internal IndividualAssemblyLoadContext() : base(false) { } diff --git a/src/vm/appdomain.cpp b/src/vm/appdomain.cpp index c8049bc1b8..47a90cafa2 100644 --- a/src/vm/appdomain.cpp +++ b/src/vm/appdomain.cpp @@ -12580,11 +12580,13 @@ AppDomain::RaiseAssemblyResolveEvent( { if (pSpec->GetParentAssembly() != NULL) { +#ifndef FEATURE_CORECLR if ( pSpec->IsIntrospectionOnly() #ifdef FEATURE_FUSION || pSpec->GetParentLoadContext() == LOADCTX_TYPE_UNKNOWN #endif ) +#endif // FEATURE_CORECLR { gc.AssemblyRef=pSpec->GetParentAssembly()->GetExposedAssemblyObject(); }