private bool TryGetMatchingByFullName(ModuleDataId id, out AssemblyData assemblyData, out bool fullMatch)
        {
            if (_fullNameToAssemblyDataMap.TryGetValue(id.FullName, out assemblyData))
            {
                fullMatch = _preloadedSet.Contains(id.SimpleName) || id.Mvid == assemblyData.Id.Mvid;
                return(true);
            }

            assemblyData = default(AssemblyData);
            fullMatch    = false;
            return(false);
        }
Example #2
0
        internal Assembly GetOrDefault(ModuleDataId id, bool reflectionOnly)
        {
            var cache = reflectionOnly ? _reflectionOnlyAssemblyCache : _assemblyCache;

            lock (s_guard)
            {
                if (cache.TryGetValue(id.Mvid, out var assembly))
                {
                    return(assembly);
                }

                return(null);
            }
        }
        private RuntimeData CreateAndInitializeRuntimeData(IEnumerable <ModuleData> compilationDependencies, ModuleDataId mainModuleId)
        {
            var allModules = compilationDependencies;

            if (_additionalDependencies != null)
            {
                allModules = allModules.Concat(_additionalDependencies);
            }

            allModules = allModules.ToArray();

            var runtimeData = GetOrCreateRuntimeData(allModules);

            // Many prominent assemblys like mscorlib are already in the RuntimeAssemblyManager.  Only
            // add in the delta values to reduce serialization overhead going across AppDomains.
            var manager     = runtimeData.Manager;
            var missingList = manager
                              .GetMissing(allModules.Select(x => new RuntimeModuleDataId(x.Id)).ToList())
                              .Select(x => x.Id);
            var deltaList = allModules
                            .Where(x => missingList.Contains(x.Id))
                            .Select(x => new RuntimeModuleData(x))
                            .ToList();

            manager.AddModuleData(deltaList);
            manager.AddMainModuleMvid(mainModuleId.Mvid);

            return(runtimeData);
        }
 public RuntimeModuleDataId(ModuleDataId id)
 {
     Id = id;
 }