예제 #1
0
 // <summary>
 // The method loads the O-space metadata for all the referenced assemblies starting from the given assembly
 // in a recursive way.
 // The assembly should be from Assembly.GetCallingAssembly via one of our public API's.
 // </summary>
 // <param name="assembly"> assembly whose dependency list we are going to traverse </param>
 internal void ImplicitLoadAllReferencedAssemblies(Assembly assembly, EdmItemCollection edmItemCollection)
 {
     if (!MetadataAssemblyHelper.ShouldFilterAssembly(assembly))
     {
         LoadAssemblyFromCache(assembly, true, edmItemCollection, null);
     }
 }
예제 #2
0
        /// <summary>
        ///     Implicit loading means that we are trying to help the user find the right
        ///     assembly, but they didn't explicitly ask for it. Our Implicit rules require that
        ///     we filter out assemblies with the Ecma or MicrosoftPublic PublicKeyToken on them
        ///     Load metadata from the type's assembly.
        /// </summary>
        /// <param name="type"> The type's assembly is loaded into the OSpace ItemCollection </param>
        /// <returns> true if the type and all its generic arguments are filtered out (did not attempt to load assembly) </returns>
        internal bool ImplicitLoadAssemblyForType(Type type, EdmItemCollection edmItemCollection)
        {
            bool result;

            if (!MetadataAssemblyHelper.ShouldFilterAssembly(type.Assembly))
            {
                // InternalLoadFromAssembly will check _knownAssemblies
                result = LoadAssemblyFromCache(this, type.Assembly, false /*loadAllReferencedAssemblies*/, edmItemCollection, null);
            }
            else
            {
                result = false;
            }

            if (type.IsGenericType)
            {
                // recursively load all generic types
                // interesting code paths are ObjectQuery<Nullable<Int32>>, ObjectQuery<IEnumerable<Product>>
                foreach (var t in type.GetGenericArguments())
                {
                    result |= ImplicitLoadAssemblyForType(t, edmItemCollection);
                }
            }
            return(result);
        }
예제 #3
0
 /// <summary>
 ///     Implicit loading means that we are trying to help the user find the right
 ///     assembly, but they didn't explicitly ask for it. Our Implicit rules require that
 ///     we filter out assemblies with the Ecma or MicrosoftPublic PublicKeyToken on them
 /// </summary>
 internal void ImplicitLoadFromAssembly(Assembly assembly, EdmItemCollection edmItemCollection)
 {
     if (!MetadataAssemblyHelper.ShouldFilterAssembly(assembly))
     {
         // it meets the Implicit rules Load it
         ExplicitLoadFromAssembly(assembly, edmItemCollection, null);
     }
 }
예제 #4
0
 internal void ImplicitLoadAllReferencedAssemblies(
     Assembly assembly,
     EdmItemCollection edmItemCollection)
 {
     if (MetadataAssemblyHelper.ShouldFilterAssembly(assembly))
     {
         return;
     }
     this.LoadAssemblyFromCache(assembly, true, edmItemCollection, (Action <string>)null);
 }
예제 #5
0
 private static IEnumerable <Assembly> GetAlreadyLoadedNonSystemAssemblies()
 {
     return(((IEnumerable <Assembly>)AppDomain.CurrentDomain.GetAssemblies()).Where <Assembly>((Func <Assembly, bool>)(a =>
     {
         if (a != (Assembly)null)
         {
             return !MetadataAssemblyHelper.ShouldFilterAssembly(a);
         }
         return false;
     })));
 }
예제 #6
0
        // <summary>
        // This method returns a list of assemblies whose contents depend on whether we
        // are running in an ASP.NET environment. If we are indeed in a Web/ASP.NET
        // scenario, we pick up the assemblies that all page compilations need to
        // reference. If not, then we simply get the list of assemblies referenced by
        // the entry assembly.
        // </summary>
        // <returns> A list of assemblies </returns>
        private static IEnumerable <Assembly> GetAllDiscoverableAssemblies()
        {
            var assembly     = Assembly.GetEntryAssembly();
            var assemblyList = new HashSet <Assembly>(
                AssemblyComparer.Instance);

            foreach (var loadedAssembly in GetAlreadyLoadedNonSystemAssemblies())
            {
                assemblyList.Add(loadedAssembly);
            }

            var aspProxy = new AspProxy();

            if (!aspProxy.IsAspNetEnvironment())
            {
                if (assembly == null)
                {
                    return(assemblyList);
                }

                assemblyList.Add(assembly);

                foreach (var referenceAssembly in MetadataAssemblyHelper.GetNonSystemReferencedAssemblies(assembly))
                {
                    assemblyList.Add(referenceAssembly);
                }

                return(assemblyList);
            }

            if (aspProxy.HasBuildManagerType())
            {
                var referencedAssemblies = aspProxy.GetBuildManagerReferencedAssemblies();
                // filter out system assemblies
                if (referencedAssemblies != null)
                {
                    foreach (var referencedAssembly in referencedAssemblies)
                    {
                        if (MetadataAssemblyHelper.ShouldFilterAssembly(referencedAssembly))
                        {
                            continue;
                        }

                        assemblyList.Add(referencedAssembly);
                    }
                }
            }

            return(assemblyList.Where(a => a != null));
        }
예제 #7
0
 internal static IEnumerable <Assembly> GetNonSystemReferencedAssemblies(
     Assembly assembly)
 {
     foreach (AssemblyName referencedAssembly in assembly.GetReferencedAssemblies())
     {
         if (!MetadataAssemblyHelper.ShouldFilterAssembly(referencedAssembly))
         {
             Assembly referenceAssembly = MetadataAssemblyHelper.SafeLoadReferencedAssembly(referencedAssembly);
             if (referenceAssembly != (Assembly)null)
             {
                 yield return(referenceAssembly);
             }
         }
     }
 }
예제 #8
0
        internal void ImplicitLoadViewsFromAllReferencedAssemblies(Assembly assembly)
        {
            // we filter implicit loads
            if (MetadataAssemblyHelper.ShouldFilterAssembly(assembly))
            {
                return;
            }
            lock (this)
            {
                CollectIfViewGenAssembly(assembly);

                foreach (var referenceAssembly in MetadataAssemblyHelper.GetNonSystemReferencedAssemblies(assembly))
                {
                    CollectIfViewGenAssembly(referenceAssembly);
                }
            }
        }
예제 #9
0
        internal bool ImplicitLoadAssemblyForType(Type type, EdmItemCollection edmItemCollection)
        {
            bool flag = false;

            if (!MetadataAssemblyHelper.ShouldFilterAssembly(type.Assembly()))
            {
                flag = this.LoadAssemblyFromCache(type.Assembly(), false, edmItemCollection, (Action <string>)null);
            }
            if (type.IsGenericType())
            {
                foreach (Type genericArgument in type.GetGenericArguments())
                {
                    flag |= this.ImplicitLoadAssemblyForType(genericArgument, edmItemCollection);
                }
            }
            return(flag);
        }
예제 #10
0
        private static IEnumerable <Assembly> GetAllDiscoverableAssemblies()
        {
            Assembly           entryAssembly = Assembly.GetEntryAssembly();
            HashSet <Assembly> source        = new HashSet <Assembly>((IEqualityComparer <Assembly>)DefaultAssemblyResolver.AssemblyComparer.Instance);

            foreach (Assembly nonSystemAssembly in DefaultAssemblyResolver.GetAlreadyLoadedNonSystemAssemblies())
            {
                source.Add(nonSystemAssembly);
            }
            AspProxy aspProxy = new AspProxy();

            if (!aspProxy.IsAspNetEnvironment())
            {
                if (entryAssembly == (Assembly)null)
                {
                    return((IEnumerable <Assembly>)source);
                }
                source.Add(entryAssembly);
                foreach (Assembly referencedAssembly in MetadataAssemblyHelper.GetNonSystemReferencedAssemblies(entryAssembly))
                {
                    source.Add(referencedAssembly);
                }
                return((IEnumerable <Assembly>)source);
            }
            if (aspProxy.HasBuildManagerType())
            {
                IEnumerable <Assembly> referencedAssemblies = aspProxy.GetBuildManagerReferencedAssemblies();
                if (referencedAssemblies != null)
                {
                    foreach (Assembly assembly in referencedAssemblies)
                    {
                        if (!MetadataAssemblyHelper.ShouldFilterAssembly(assembly))
                        {
                            source.Add(assembly);
                        }
                    }
                }
            }
            return(source.Where <Assembly>((Func <Assembly, bool>)(a => a != (Assembly)null)));
        }
예제 #11
0
 private static bool ComputeShouldFilterAssembly(Assembly assembly)
 {
     return(MetadataAssemblyHelper.ShouldFilterAssembly(new AssemblyName(assembly.FullName)));
 }
예제 #12
0
        // <summary>
        // Return all assemblies loaded in the current AppDomain that are not signed
        // with the Microsoft Key.
        // </summary>
        // <returns> A list of assemblies </returns>
        private static IEnumerable <Assembly> GetAlreadyLoadedNonSystemAssemblies()
        {
            var assemblies = AppDomain.CurrentDomain.GetAssemblies();

            return(assemblies.Where(a => a != null && !MetadataAssemblyHelper.ShouldFilterAssembly(a)));
        }