internal void AddAssembliesToReference <T>(IEnumerable <T> assemblyInfos, Func <T, AssemblyIdentity> toId, Func <T, MetadataReference> toMDReference) { IEnumerable <AssemblyIdentity> newAssemblyIds = assemblyInfos.Select(assemblySymbol => toId(assemblySymbol)).Except(TheCompilation.ReferencedAssemblyNames).ToList(); IEnumerable <T> newAssemblies = assemblyInfos.Where(aSymbol => newAssemblyIds.Contains(toId(aSymbol))).ToList(); if (newAssemblies.IsNullOrEmpty()) { return; } IEnumerable <MetadataReference> allMetadataReferences = TheCompilation.References.Union(newAssemblies.SelectMany(assemblySymbol => toMDReference(assemblySymbol).ToCollection())).ToList(); TheProj = TheProj.WithMetadataReferences(allMetadataReferences); TheCompilation = TheCompilation.WithReferences(allMetadataReferences); }
internal void AddAssembliesToReference(IEnumerable <Assembly> assemblies) { IEnumerable <Assembly> newAssemblies = assemblies.Except(this.AllReferencedAssemblies); if (newAssemblies.IsNullOrEmpty()) { return; } newAssemblies.DoForEach(assembly => AllReferencedAssemblies.Add(assembly)); MetadataReference[] newReferences = newAssemblies.Select(assmbly => assmbly.ToRef()).ToArray(); MetadataReference[] allReferences = AllReferencedAssemblies.Select(assmbly => assmbly.ToRef()).ToArray(); TheProj = TheProj.WithMetadataReferences(allReferences); TheCompilation = TheCompilation.WithReferences(allReferences); }