[assembly] When loading framework facade assemblies, any version is ok in mono_assemb...
authorAleksey Kliger <aleksey@xamarin.com>
Fri, 21 Apr 2017 20:07:04 +0000 (16:07 -0400)
committerAleksey Kliger <aleksey@xamarin.com>
Tue, 25 Apr 2017 19:25:41 +0000 (15:25 -0400)
As long as the name and public key token matches.

This is different from the non-facade framework assemblies for which the
name and version must match but the public key token is ignored.

mono/metadata/assembly.c

index 9f5f261753b2c54be0ba813011a342e9229d5659..13f1e628cdc5aa8947d30d52f7347eed4db08f6f 100644 (file)
@@ -60,6 +60,7 @@ typedef struct  {
        guint8 version_set_index;
        const char* new_assembly_name;
        gboolean only_lower_versions;
+       gboolean framework_facade_assembly;
 } AssemblyVersionMap;
 
 /* Flag bits for assembly_names_equal_flags (). */
@@ -1135,6 +1136,12 @@ mono_assembly_remap_version (MonoAssemblyName *aname, MonoAssemblyName *dest_ana
                g_assert (index < G_N_ELEMENTS (current_runtime->version_sets));
                vset = &current_runtime->version_sets [index];
 
+               if (vmap->framework_facade_assembly) {
+                       mono_trace (G_LOG_LEVEL_DEBUG, MONO_TRACE_ASSEMBLY, "Assembly %s is a framework Facade asseembly",
+                                   aname->name);
+                       return aname;
+               }
+
                if (aname->major == vset->major && aname->minor == vset->minor &&
                        aname->build == vset->build && aname->revision == vset->revision) {
                        mono_trace (G_LOG_LEVEL_DEBUG, MONO_TRACE_ASSEMBLY, "Found assembly remapping for %s and was for the same version %d.%d.%d.%d",
@@ -3467,10 +3474,18 @@ framework_assembly_sn_match (MonoAssemblyName *wanted_name, MonoAssemblyName *ca
 #ifndef DISABLE_ASSEMBLY_REMAPPING
        const AssemblyVersionMap *vmap = (AssemblyVersionMap *)g_hash_table_lookup (assembly_remapping_table, wanted_name->name);
        if (vmap) {
-               /* If the wanted name is a framework assembly, it's enough for the name/version/culture to match.  If the assembly was remapped, the public key token is likely unrelated. */
-               gboolean result = assembly_names_equal_flags (wanted_name, candidate_name, ANAME_EQ_IGNORE_PUBKEY);
-               mono_trace (G_LOG_LEVEL_INFO, MONO_TRACE_ASSEMBLY, "Predicate: candidate and wanted names %s (ignoring the public key token)", result ? "match, returning TRUE" : "don't match, returning FALSE");
-               return result;
+               if (!vmap->framework_facade_assembly) {
+                       /* If the wanted name is a framework assembly, it's enough for the name/version/culture to match.  If the assembly was remapped, the public key token is likely unrelated. */
+                       gboolean result = assembly_names_equal_flags (wanted_name, candidate_name, ANAME_EQ_IGNORE_PUBKEY);
+                       mono_trace (G_LOG_LEVEL_INFO, MONO_TRACE_ASSEMBLY, "Predicate: candidate and wanted names %s (ignoring the public key token)", result ? "match, returning TRUE" : "don't match, returning FALSE");
+                       return result;
+               } else {
+                       /* For facades, the name and public key token should
+                        * match, but the version doesn't matter. */
+                       gboolean result = assembly_names_equal_flags (wanted_name, candidate_name, ANAME_EQ_IGNORE_VERSION);
+                       mono_trace (G_LOG_LEVEL_INFO, MONO_TRACE_ASSEMBLY, "Predicate: candidate and wanted names %s (ignoring version)", result ? "match, returning TRUE" : "don't match, returning FALSE");
+                       return result;
+               }
        }
 #endif
        return FALSE;