Expose AppDomain::AssemblyResolve
authorRahul Kumar <rahku@microsoft.com>
Tue, 8 Nov 2016 19:13:33 +0000 (11:13 -0800)
committerRahul Kumar <rahku@microsoft.com>
Thu, 10 Nov 2016 18:48:54 +0000 (10:48 -0800)
src/mscorlib/model.xml
src/mscorlib/ref/mscorlib.cs
src/mscorlib/src/System/Reflection/Assembly.cs
src/mscorlib/src/System/Runtime/Loader/AssemblyLoadContext.cs
src/vm/appdomain.cpp

index 95284d5bf0093df677ed16c791524a11f5927276..5fb44e80753814462eceeec66077ad4ca74c6352 100644 (file)
       <Member Name="SetProfileOptimizationRoot(System.String)" />
       <Member Name="StartProfileOptimization(System.String)" />
       <Member MemberType="Event" Name="AssemblyLoad" />
+      <Member MemberType="Event" Name="AssemblyResolve" />
       <Member MemberType="Event" Name="Resolving" />
       <Member MemberType="Event" Name="ResourceResolve" />
       <Member MemberType="Event" Name="TypeResolve" />
index 1b6611c1129b4b045bd5b9c4f7aec194f8f28f27..4c364ada180d56ece8c7c4305fd1ba2866f3074a 100644 (file)
@@ -11971,6 +11971,7 @@ namespace System.Runtime.Loader
         public event System.Func<System.Runtime.Loader.AssemblyLoadContext, System.Reflection.AssemblyName, System.Reflection.Assembly> Resolving { add { } remove { } }
         public event System.Action<System.Runtime.Loader.AssemblyLoadContext> 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; }
index 4383c432b43340be0a4b305af10100c846283842..04f7faef975716e7cfbba27d92dfd05cafff65db 100644 (file)
@@ -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);
             }
index d46d0d0d88282febf6ca9719db30627f84835406..fd896a6b42b7d8f48c4e474910fcc91bb68be788 100644 (file)
@@ -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)
         {
         }
 
index c8049bc1b8993416bd7f53dd2f12564c03c3c48e..47a90cafa2e052f319a49a57e03eef6ad9074105 100644 (file)
@@ -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();
             }