Пример #1
0
        internal void Read(XmlReader reader)
        {
            while (reader.Read())
            {
                // Look for the end element.
                if (reader.NodeType == XmlNodeType.EndElement && AppConfig.StringEquals(reader.Name, "runtime"))
                {
                    return;
                }

                // Look for a <dependentAssembly> element
                if (reader.NodeType == XmlNodeType.Element && AppConfig.StringEquals(reader.Name, "dependentAssembly"))
                {
                    var dependentAssembly = new DependentAssembly();
                    dependentAssembly.Read(reader);

                    // Only add if there was an <assemblyIdentity> tag.
                    // Otherwise, this section is no use.
                    if (dependentAssembly.PartialAssemblyName != null)
                    {
                        DependentAssemblies.Add(dependentAssembly);
                    }
                }
            }
        }
Пример #2
0
        /// <summary>
        /// The reader is positioned on a &lt;runtime&gt; element--read it.
        /// </summary>
        /// <param name="reader"></param>
        internal void Read(XmlTextReader reader)
        {
            while (reader.Read())
            {
                // Look for the end element.
                if (reader.NodeType == XmlNodeType.EndElement && AppConfig.StringEquals(reader.Name, "runtime"))
                {
                    return;
                }

                // Look for a <dependentAssembly> element
                if (reader.NodeType == XmlNodeType.Element && AppConfig.StringEquals(reader.Name, "dependentAssembly"))
                {
                    DependentAssembly dependentAssembly = new DependentAssembly();
                    dependentAssembly.Read(reader);

                    // Only add if there was an <assemblyIdentity> tag.
                    // Otherwise, this section is no use.
                    if (dependentAssembly.PartialAssemblyName != null)
                    {
                        _dependentAssemblies.Add(dependentAssembly);
                    }
                }
            }
        }
Пример #3
0
        public void SerializeDeserialize()
        {
            DependentAssembly dependentAssembly = new DependentAssembly();

            string xml = "<assemblyIdentity name='ClassLibrary1'/>";

            dependentAssembly.Read(new XmlTextReader(xml, XmlNodeType.Document, null));

            Assert.IsTrue(dependentAssembly.PartialAssemblyName != null);
        }
 internal void Read(XmlTextReader reader)
 {
     while (reader.Read())
     {
         if ((reader.NodeType == XmlNodeType.EndElement) && AppConfig.StringEquals(reader.Name, "runtime"))
         {
             return;
         }
         if ((reader.NodeType == XmlNodeType.Element) && AppConfig.StringEquals(reader.Name, "dependentAssembly"))
         {
             DependentAssembly assembly = new DependentAssembly();
             assembly.Read(reader);
             if (assembly.PartialAssemblyName != null)
             {
                 this.dependentAssemblies.Add(assembly);
             }
         }
     }
 }
 internal void Read(XmlTextReader reader)
 {
     while (reader.Read())
     {
         if ((reader.NodeType == XmlNodeType.EndElement) && AppConfig.StringEquals(reader.Name, "runtime"))
         {
             return;
         }
         if ((reader.NodeType == XmlNodeType.Element) && AppConfig.StringEquals(reader.Name, "dependentAssembly"))
         {
             DependentAssembly assembly = new DependentAssembly();
             assembly.Read(reader);
             if (assembly.PartialAssemblyName != null)
             {
                 this.dependentAssemblies.Add(assembly);
             }
         }
     }
 }
Пример #6
0
        /// <summary>
        /// Based on the closure, get a table of ideal remappings needed to 
        /// produce zero conflicts.
        /// </summary>
        internal void ResolveConflicts
        (
            out DependentAssembly[] idealRemappings,
            out AssemblyNameReference[] conflictingReferences
        )
        {
            idealRemappings = null;
            conflictingReferences = null;

            // First, resolve all conflicts between references.
            if (0 == ResolveConflictsBetweenReferences())
            {
                // If there were no basename conflicts then there can be no version-to-version conflicts.
                // In this case, short-circuit now rather than building up all the tables below.
                return;
            }

            // Build two tables, one with a count and one with the corresponding references.
            // Dependencies which differ only by version number need a suggested redirect.
            // The count tells us whether there are two or more.
            Hashtable counts = new Hashtable(StringComparer.OrdinalIgnoreCase);
            Hashtable references = new Hashtable(StringComparer.OrdinalIgnoreCase);

            foreach (AssemblyNameExtension assemblyName in References.Keys)
            {
                Reference reference = GetReference(assemblyName);

                // If the assembly has a parent which has specific version set to true then we need to see if it is framework assembly
                if (reference.CheckForSpecificVersionMetadataOnParentsReference(true))
                {
                    // Try and find an entry in the redist list by comparing everything except the version.
                    AssemblyEntry entry = null;

                    if (_installedAssemblies != null)
                    {
                        entry = _installedAssemblies.FindHighestVersionInRedistList(assemblyName);
                    }

                    if (entry != null)
                    {
                        // We have found an entry in the redist list that this assembly is a framework assembly of some version
                        // also one if its parent refernces has specific version set to true, therefore we need to make sure
                        // that we do not consider it for conflict resolution.
                        continue;
                    }
                }

                byte[] pkt = assemblyName.GetPublicKeyToken();
                if (pkt != null && pkt.Length > 0)
                {
                    AssemblyName baseKey = (AssemblyName)assemblyName.AssemblyName.Clone();
                    Version version = baseKey.Version;
                    baseKey.Version = null;
                    string key = baseKey.ToString();

                    if (counts.ContainsKey(key))
                    {
                        counts[key] = ((int)counts[key]) + 1;
                        Version lastVersion = ((AssemblyNameReference)references[key]).assemblyName.Version;

                        if (lastVersion == null || lastVersion < version)
                        {
                            references[key] = AssemblyNameReference.Create(assemblyName, reference);
                        }
                    }
                    else
                    {
                        counts[key] = 1;
                        references[key] = AssemblyNameReference.Create(assemblyName, reference);
                    }
                }
            }

            // Build the list of conflicted assemblies.
            List<AssemblyNameReference> assemblyNamesList = new List<AssemblyNameReference>();
            foreach (string versionLessAssemblyName in counts.Keys)
            {
                if (((int)counts[versionLessAssemblyName]) > 1)
                {
                    assemblyNamesList.Add((AssemblyNameReference)references[versionLessAssemblyName]);
                }
            }

            // Pass over the list of conflicting references and make a binding redirect for each.
            List<DependentAssembly> idealRemappingsList = new List<DependentAssembly>();

            foreach (AssemblyNameReference assemblyNameReference in assemblyNamesList)
            {
                DependentAssembly remapping = new DependentAssembly();
                remapping.PartialAssemblyName = assemblyNameReference.assemblyName.AssemblyName;
                BindingRedirect bindingRedirect = new BindingRedirect();
                bindingRedirect.OldVersionLow = new Version("0.0.0.0");
                bindingRedirect.OldVersionHigh = assemblyNameReference.assemblyName.AssemblyName.Version;
                bindingRedirect.NewVersion = assemblyNameReference.assemblyName.AssemblyName.Version;
                remapping.BindingRedirects = new BindingRedirect[] { bindingRedirect };

                idealRemappingsList.Add(remapping);
            }

            idealRemappings = idealRemappingsList.ToArray();
            conflictingReferences = assemblyNamesList.ToArray();
        }
Пример #7
0
        /// <summary>
        /// Searches the table for references that haven't been resolved to their full file names and
        /// for dependencies that haven't yet been found.
        ///
        /// If any are found, they're resolved and then dependencies are found. Then the process is repeated 
        /// until nothing is left unresolved.
        /// </summary>
        /// <param name="remappedAssemblies">The table of remapped assemblies.</param>
        /// <param name="referenceAssemblyFiles">The task items which contain file names to add.</param>
        /// <param name="referenceAssemblyNames">The task items which contain fusion names to add.</param>
        /// <param name="exceptions">Errors encountered while computing closure.</param>
        internal void ComputeClosure
        (
            DependentAssembly[] remappedAssembliesValue,
            ITaskItem[] referenceAssemblyFiles,
            ITaskItem[] referenceAssemblyNames,
            ArrayList exceptions
        )
        {
#if (!STANDALONEBUILD)
            using (new CodeMarkerStartEnd(CodeMarkerEvent.perfMSBuildRARComputeClosureBegin, CodeMarkerEvent.perfMSBuildRARComputeClosureEnd))
#endif
            {
                _references.Clear();
                _remappedAssemblies = remappedAssembliesValue;
                SetPrimaryItems(referenceAssemblyFiles, referenceAssemblyNames, exceptions);

                ComputeClosure();
            }
        }
Пример #8
0
        /// <summary>
        /// Log the results.
        /// </summary>
        /// <param name="dependencyTable">Reference table.</param>
        /// <param name="idealAssemblyRemappings">Array of ideal assembly remappings.</param>
        /// <param name="idealAssemblyRemappingsIdentities">Array of identities of ideal assembly remappings.</param>
        /// <param name="generalResolutionExceptions">List of exceptions that were not attributable to a particular fusion name.</param>
        /// <returns></returns>
        private bool LogResults
        (
            ReferenceTable dependencyTable,
            DependentAssembly[] idealAssemblyRemappings,
            AssemblyNameReference[] idealAssemblyRemappingsIdentities,
            ArrayList generalResolutionExceptions
        )
        {
            bool success = true;
#if (!STANDALONEBUILD)
            using (new CodeMarkerStartEnd(CodeMarkerEvent.perfMSBuildRARLogResultsBegin, CodeMarkerEvent.perfMSBuildRARLogResultsEnd))
#endif
            {
                /*
                PERF NOTE: The Silent flag turns off logging completely from the task side. This means
                we avoid the String.Formats that would normally occur even if the verbosity was set to 
                quiet at the engine level.
                */
                if (!Silent)
                {
                    // First, loop over primaries and display information.
                    foreach (AssemblyNameExtension assemblyName in dependencyTable.References.Keys)
                    {
                        string fusionName = assemblyName.FullName;
                        Reference primaryCandidate = dependencyTable.GetReference(assemblyName);

                        if (primaryCandidate.IsPrimary && !(primaryCandidate.IsConflictVictim && primaryCandidate.IsCopyLocal))
                        {
                            LogReference(primaryCandidate, fusionName);
                        }
                    }

                    // Second, loop over dependencies and display information.
                    foreach (AssemblyNameExtension assemblyName in dependencyTable.References.Keys)
                    {
                        string fusionName = assemblyName.FullName;
                        Reference dependencyCandidate = dependencyTable.GetReference(assemblyName);

                        if (!dependencyCandidate.IsPrimary && !(dependencyCandidate.IsConflictVictim && dependencyCandidate.IsCopyLocal))
                        {
                            LogReference(dependencyCandidate, fusionName);
                        }
                    }

                    // Third, show conflicts and their resolution.
                    foreach (AssemblyNameExtension assemblyName in dependencyTable.References.Keys)
                    {
                        string fusionName = assemblyName.FullName;
                        Reference conflictCandidate = dependencyTable.GetReference(assemblyName);

                        if (conflictCandidate.IsConflictVictim)
                        {
                            LogConflict(conflictCandidate, fusionName);

                            // Log the assemblies and primary source items which are related to the conflict which was just logged.
                            Reference victor = dependencyTable.GetReference(conflictCandidate.ConflictVictorName);

                            // Log the winner of the conflict resolution, the source items and dependencies which caused it
                            LogReferenceDependenciesAndSourceItems(conflictCandidate.ConflictVictorName.FullName, victor);

                            // Log the reference which lost the conflict and the dependencies and source items which caused it.
                            LogReferenceDependenciesAndSourceItems(fusionName, conflictCandidate);
                        }
                    }

                    // Fourth, if there were any suggested redirects. Show one message per redirect and a single warning.
                    if (idealAssemblyRemappings != null)
                    {
                        bool foundAtLeastOneValidBindingRedirect = false;
                        bool foundAtLeastOneUnresolvableConflict = false;

                        var buffer = new StringBuilder();
                        var ns = XNamespace.Get("urn:schemas-microsoft-com:asm.v1");

                        // A high-priority message for each individual redirect.
                        for (int i = 0; i < idealAssemblyRemappings.Length; i++)
                        {
                            DependentAssembly idealRemapping = idealAssemblyRemappings[i];
                            AssemblyName idealRemappingPartialAssemblyName = idealRemapping.PartialAssemblyName;
                            Reference reference = idealAssemblyRemappingsIdentities[i].reference;

                            for (int j = 0; j < idealRemapping.BindingRedirects.Length; j++)
                            {
                                AssemblyNameExtension[] conflictVictims = reference.GetConflictVictims();
                                foreach (AssemblyNameExtension conflictVictim in conflictVictims)
                                {
                                    // Make note we only output a conflict suggestion if the reference has at 
                                    // least one conflict victim - that way we don't suggest redirects to 
                                    // assemblies that don't exist at runtime. For example, this avoids us suggesting
                                    // a redirect from Foo 1.0.0.0 -> 2.0.0.0 in the following:
                                    //
                                    //      Project -> Foo, 1.0.0.0
                                    //      Project -> Bar -> Foo, 2.0.0.0
                                    //
                                    // Above, Foo, 1.0.0.0 wins out and is copied to the output directory because 
                                    // it is a primary reference.
                                    foundAtLeastOneValidBindingRedirect = true;

                                    Reference victimReference = dependencyTable.GetReference(conflictVictim);
                                    var newVerStr = idealRemapping.BindingRedirects[j].NewVersion.ToString();
                                    Log.LogMessageFromResources
                                    (
                                        MessageImportance.High,
                                        "ResolveAssemblyReference.ConflictRedirectSuggestion",
                                        idealRemappingPartialAssemblyName,
                                        conflictVictim.Version,
                                        victimReference.FullPath,
                                        newVerStr,
                                        reference.FullPath
                                    );

                                    if (!SupportsBindingRedirectGeneration && !AutoUnify)
                                    {
                                        // When running against projects types (such as Web Projects) where we can't auto-generate
                                        // binding redirects during the build, populate a buffer (to be output below) with the
                                        // binding redirect syntax that users need to add manually to the App.Config.

                                        var assemblyIdentityAttributes = new List<XAttribute>(4);

                                        assemblyIdentityAttributes.Add(new XAttribute("name", idealRemappingPartialAssemblyName.Name));

                                        // We use "neutral" for "Invariant Language (Invariant Country)" in assembly names.
                                        var cultureString = idealRemappingPartialAssemblyName.CultureName;
                                        assemblyIdentityAttributes.Add(new XAttribute("culture", String.IsNullOrEmpty(idealRemappingPartialAssemblyName.CultureName) ? "neutral" : idealRemappingPartialAssemblyName.CultureName));

                                        var publicKeyToken = idealRemappingPartialAssemblyName.GetPublicKeyToken();
                                        assemblyIdentityAttributes.Add(new XAttribute("publicKeyToken", ResolveAssemblyReference.ByteArrayToString(publicKeyToken)));

                                        var node = new XElement(
                                            ns + "assemblyBinding",
                                            new XElement(
                                                ns + "dependentAssembly",
                                                new XElement(
                                                    ns + "assemblyIdentity",
                                                    assemblyIdentityAttributes),
                                                new XElement(
                                                    ns + "bindingRedirect",
                                                    new XAttribute("oldVersion", "0.0.0.0-" + newVerStr),
                                                    new XAttribute("newVersion", newVerStr))));

                                        buffer.Append(node.ToString(SaveOptions.DisableFormatting));
                                    }
                                }

                                if (conflictVictims.Length == 0)
                                {
                                    foundAtLeastOneUnresolvableConflict = true;
                                }
                            }
                        }

                        // Log the warning
                        if (idealAssemblyRemappings.Length > 0 && foundAtLeastOneValidBindingRedirect)
                        {
                            if (SupportsBindingRedirectGeneration)
                            {
                                if (!AutoUnify)
                                {
                                    Log.LogWarningWithCodeFromResources("ResolveAssemblyReference.TurnOnAutoGenerateBindingRedirects");
                                }
                                // else we'll generate bindingRedirects to address the remappings
                            }
                            else if (!AutoUnify)
                            {
                                Log.LogWarningWithCodeFromResources("ResolveAssemblyReference.SuggestedRedirects", buffer.ToString());
                            }
                            // else AutoUnify is on and bindingRedirect generation is not supported
                            // we don't warn in this case since the binder will automatically unify these remappings
                        }

                        if (foundAtLeastOneUnresolvableConflict)
                        {
                            // This warning is logged regardless of AutoUnify since it means a conflict existed where the reference
                            // chosen was not the conflict victor in a version comparison, in other words it was older.
                            Log.LogWarningWithCodeFromResources("ResolveAssemblyReference.FoundConflicts");
                        }
                    }

                    // Fifth, log general resolution problems.

                    // Log general resolution exceptions.
                    foreach (Exception error in generalResolutionExceptions)
                    {
                        if (error is InvalidReferenceAssemblyNameException)
                        {
                            InvalidReferenceAssemblyNameException e = (InvalidReferenceAssemblyNameException)error;
                            Log.LogWarningWithCodeFromResources("General.MalformedAssemblyName", e.SourceItemSpec);
                        }
                        else
                        {
                            // An unknown Exception type was returned. Just throw.
                            throw error;
                        }
                    }
                }
            }

            if (dependencyTable.Resolvers != null)
            {
                foreach (Resolver r in dependencyTable.Resolvers)
                {
                    if (r is AssemblyFoldersExResolver)
                    {
                        AssemblyFoldersEx assemblyFoldersEx = ((AssemblyFoldersExResolver)r).AssemblyFoldersExLocations;

                        MessageImportance messageImportance = MessageImportance.Low;
                        if (assemblyFoldersEx != null && _showAssemblyFoldersExLocations.TryGetValue(r.SearchPath, out messageImportance))
                        {
                            Log.LogMessageFromResources(messageImportance, "ResolveAssemblyReference.AssemblyFoldersExSearchLocations", r.SearchPath);
                            foreach (AssemblyFoldersExInfo info in assemblyFoldersEx)
                            {
                                Log.LogMessageFromResources(messageImportance, "ResolveAssemblyReference.EightSpaceIndent", info.DirectoryPath);
                            }
                        }
                    }
                }
            }

            return success;
        }
Пример #9
0
        /// <summary>
        /// Populates the suggested redirects output parameter.
        /// </summary>
        /// <param name="idealAssemblyRemappings">The list of ideal remappings.</param>
        /// <param name="idealAssemblyRemappedReferences">The list of of references to ideal assembly remappings.</param>
        private void PopulateSuggestedRedirects(DependentAssembly[] idealAssemblyRemappings, AssemblyNameReference[] idealAssemblyRemappedReferences)
        {
            ArrayList holdSuggestedRedirects = new ArrayList();
            if (idealAssemblyRemappings != null)
            {
                for (int i = 0; i < idealAssemblyRemappings.Length; i++)
                {
                    DependentAssembly idealRemapping = idealAssemblyRemappings[i];
                    string itemSpec = idealRemapping.PartialAssemblyName.ToString();

                    Reference reference = idealAssemblyRemappedReferences[i].reference;
                    AssemblyNameExtension[] conflictVictims = reference.GetConflictVictims();

                    // Skip any remapping that has no conflict victims since a redirect will not help.
                    if (null == conflictVictims || 0 == conflictVictims.Length)
                    {
                        continue;
                    }

                    for (int j = 0; j < idealRemapping.BindingRedirects.Length; j++)
                    {
                        ITaskItem suggestedRedirect = new TaskItem();
                        suggestedRedirect.ItemSpec = itemSpec;
                        suggestedRedirect.SetMetadata("MaxVersion", idealRemapping.BindingRedirects[j].NewVersion.ToString());
                        holdSuggestedRedirects.Add(suggestedRedirect);
                    }
                }
            }
            _suggestedRedirects = (ITaskItem[])holdSuggestedRedirects.ToArray(typeof(ITaskItem));
        }
Пример #10
0
        /// <summary>
        /// Combines two DependentAssembly arrays into one.
        /// </summary>
        private static DependentAssembly[] CombineRemappedAssemblies(DependentAssembly[] first, DependentAssembly[] second)
        {
            if (first == null)
                return second;

            if (second == null)
                return first;

            DependentAssembly[] combined = new DependentAssembly[first.Length + second.Length];
            first.CopyTo(combined, 0);
            second.CopyTo(combined, first.Length);

            return combined;
        }
 private void PopulateSuggestedRedirects(DependentAssembly[] idealAssemblyRemappings)
 {
     ArrayList list = new ArrayList();
     if (idealAssemblyRemappings != null)
     {
         for (int i = 0; i < idealAssemblyRemappings.Length; i++)
         {
             DependentAssembly assembly = idealAssemblyRemappings[i];
             string str = assembly.PartialAssemblyName.ToString();
             for (int j = 0; j < assembly.BindingRedirects.Length; j++)
             {
                 ITaskItem item = new TaskItem {
                     ItemSpec = str
                 };
                 item.SetMetadata("MaxVersion", assembly.BindingRedirects[j].NewVersion.ToString());
                 list.Add(item);
             }
         }
     }
     this.suggestedRedirects = (ITaskItem[]) list.ToArray(typeof(ITaskItem));
 }
 private bool LogResults(ReferenceTable dependencyTable, DependentAssembly[] idealAssemblyRemappings, AssemblyNameReference[] idealAssemblyRemappingsIdentities, ArrayList generalResolutionExceptions)
 {
     bool flag = true;
     using (new CodeMarkerStartEnd(CodeMarkerEvent.perfMSBuildRARLogResultsBegin, CodeMarkerEvent.perfMSBuildRARLogResultsEnd))
     {
         if (this.Silent)
         {
             return flag;
         }
         foreach (AssemblyNameExtension extension in dependencyTable.References.Keys)
         {
             string fullName = extension.FullName;
             Reference reference = dependencyTable.GetReference(extension);
             if (reference.IsPrimary && (!reference.IsConflictVictim || !reference.IsCopyLocal))
             {
                 this.LogReference(reference, fullName);
             }
         }
         foreach (AssemblyNameExtension extension2 in dependencyTable.References.Keys)
         {
             string fusionName = extension2.FullName;
             Reference reference2 = dependencyTable.GetReference(extension2);
             if (!reference2.IsPrimary && (!reference2.IsConflictVictim || !reference2.IsCopyLocal))
             {
                 this.LogReference(reference2, fusionName);
             }
         }
         foreach (AssemblyNameExtension extension3 in dependencyTable.References.Keys)
         {
             string str3 = extension3.FullName;
             Reference reference3 = dependencyTable.GetReference(extension3);
             if (reference3.IsConflictVictim)
             {
                 this.LogConflict(reference3, str3);
                 Reference conflictCandidate = dependencyTable.GetReference(reference3.ConflictVictorName);
                 this.LogReferenceDependenciesAndSourceItems(reference3.ConflictVictorName.FullName, conflictCandidate);
                 this.LogReferenceDependenciesAndSourceItems(str3, reference3);
             }
         }
         if (this.suggestedRedirects.Length > 0)
         {
             for (int i = 0; i < idealAssemblyRemappings.Length; i++)
             {
                 DependentAssembly assembly = idealAssemblyRemappings[i];
                 AssemblyName partialAssemblyName = assembly.PartialAssemblyName;
                 Reference reference5 = idealAssemblyRemappingsIdentities[i].reference;
                 for (int j = 0; j < assembly.BindingRedirects.Length; j++)
                 {
                     foreach (AssemblyNameExtension extension4 in reference5.GetConflictVictims())
                     {
                         Reference reference6 = dependencyTable.GetReference(extension4);
                         base.Log.LogMessageFromResources(MessageImportance.High, "ResolveAssemblyReference.ConflictRedirectSuggestion", new object[] { partialAssemblyName, extension4.Version, reference6.FullPath, assembly.BindingRedirects[j].NewVersion, reference5.FullPath });
                     }
                 }
             }
             base.Log.LogWarningWithCodeFromResources("ResolveAssemblyReference.SuggestedRedirects", new object[0]);
         }
         foreach (Exception exception in generalResolutionExceptions)
         {
             if (!(exception is InvalidReferenceAssemblyNameException))
             {
                 throw exception;
             }
             InvalidReferenceAssemblyNameException exception2 = (InvalidReferenceAssemblyNameException) exception;
             base.Log.LogWarningWithCodeFromResources("General.MalformedAssemblyName", new object[] { exception2.SourceItemSpec });
         }
     }
     return flag;
 }
 internal void ResolveConflicts(out DependentAssembly[] idealRemappings, out AssemblyNameReference[] conflictingReferences)
 {
     idealRemappings = null;
     conflictingReferences = null;
     if (this.ResolveConflictsBetweenReferences() != 0)
     {
         Hashtable hashtable = new Hashtable(StringComparer.OrdinalIgnoreCase);
         Hashtable hashtable2 = new Hashtable(StringComparer.OrdinalIgnoreCase);
         foreach (AssemblyNameExtension extension in this.References.Keys)
         {
             Reference reference = this.GetReference(extension);
             if (reference.CheckForSpecificVersionMetadataOnParentsReference(true))
             {
                 AssemblyEntry entry = null;
                 if (this.installedAssemblies != null)
                 {
                     entry = this.installedAssemblies.FindHighestVersionInRedistList(extension);
                 }
                 if (entry != null)
                 {
                     continue;
                 }
             }
             byte[] publicKeyToken = extension.GetPublicKeyToken();
             if ((publicKeyToken != null) && (publicKeyToken.Length > 0))
             {
                 AssemblyName name = (AssemblyName) extension.AssemblyName.Clone();
                 Version version = name.Version;
                 name.Version = null;
                 string key = name.ToString();
                 if (hashtable.ContainsKey(key))
                 {
                     hashtable[key] = ((int) hashtable[key]) + 1;
                     Version version2 = ((AssemblyNameReference) hashtable2[key]).assemblyName.Version;
                     if ((version2 == null) || (version2 < version))
                     {
                         hashtable2[key] = AssemblyNameReference.Create(extension, reference);
                     }
                 }
                 else
                 {
                     hashtable[key] = 1;
                     hashtable2[key] = AssemblyNameReference.Create(extension, reference);
                 }
             }
         }
         List<AssemblyNameReference> list = new List<AssemblyNameReference>();
         foreach (string str2 in hashtable.Keys)
         {
             if (((int) hashtable[str2]) > 1)
             {
                 list.Add((AssemblyNameReference) hashtable2[str2]);
             }
         }
         List<DependentAssembly> list2 = new List<DependentAssembly>();
         foreach (AssemblyNameReference reference2 in list)
         {
             DependentAssembly item = new DependentAssembly {
                 PartialAssemblyName = reference2.assemblyName.AssemblyName
             };
             BindingRedirect redirect = new BindingRedirect {
                 OldVersionLow = new Version("0.0.0.0"),
                 OldVersionHigh = reference2.assemblyName.AssemblyName.Version,
                 NewVersion = reference2.assemblyName.AssemblyName.Version
             };
             item.BindingRedirects = new BindingRedirect[] { redirect };
             list2.Add(item);
         }
         idealRemappings = list2.ToArray();
         conflictingReferences = list.ToArray();
     }
 }
 internal void ComputeClosure(DependentAssembly[] remappedAssembliesValue, ITaskItem[] referenceAssemblyFiles, ITaskItem[] referenceAssemblyNames, ArrayList exceptions)
 {
     using (new CodeMarkerStartEnd(CodeMarkerEvent.perfMSBuildRARComputeClosureBegin, CodeMarkerEvent.perfMSBuildRARComputeClosureEnd))
     {
         this.references.Clear();
         this.remappedAssemblies = remappedAssembliesValue;
         this.SetPrimaryItems(referenceAssemblyFiles, referenceAssemblyNames, exceptions);
         this.ComputeClosure();
     }
 }