Example #1
0
        private static void CheckIfPreloaded(AssemblyResolver resolver, AssemblyNode assemblyNode,
            AssemblyNode preloaded, ref bool isPreloadedAssembly)
        {
            Contract.Requires(preloaded == null || resolver != null);

            if (preloaded == null) return;

            resolver.PostLoadHook(preloaded);

            if (assemblyNode == preloaded)
            {
                isPreloadedAssembly = true;
            }
        }
Example #2
0
        private static void PossiblyLoadOOB(AssemblyResolver resolver, AssemblyNode assemblyNode, string originalAssemblyName)
        {
            Contract.Requires(assemblyNode != null);
            Contract.Requires(originalAssemblyName != null);

            // Do NOT automatically attach an out-of-band contract to the main assembly being worked on,
            // but only for the assemblies it references.
            // That is because there might be a contract assembly X.Contracts for an assembly X that contains
            // contracts and we don't want to be confused or get duplicate contracts if that contract assembly
            // is found the next time X is rewritten.
            // So attach the contract only if it is explicitly listed in the options
            if (assemblyNode.Name.ToLower() == originalAssemblyName.ToLower())
            {
                assemblyNode.AssemblyReferenceResolution +=
                    new Module.AssemblyReferenceResolver(resolver.ResolveAssemblyReference);

                LogFileLoads(assemblyNode);
                return;
            }

            resolver.PostLoadHook(assemblyNode);
        }