public SimpleCompilation(ISolutionSnapshot solutionSnapshot, IUnresolvedAssembly mainAssembly, IEnumerable <IAssemblyReference> assemblyReferences)
        {
            if (solutionSnapshot == null)
            {
                throw new ArgumentNullException("solutionSnapshot");
            }
            if (mainAssembly == null)
            {
                throw new ArgumentNullException("mainAssembly");
            }
            if (assemblyReferences == null)
            {
                throw new ArgumentNullException("assemblyReferences");
            }
            this.solutionSnapshot = solutionSnapshot;
            this.context          = new SimpleTypeResolveContext(this);
            this.mainAssembly     = mainAssembly.Resolve(context);
            List <IAssembly> referencedAssemblies = new List <IAssembly>();

            foreach (var asmRef in assemblyReferences)
            {
                IAssembly asm = asmRef.Resolve(context);
                if (asm != null)
                {
                    referencedAssemblies.Add(asm);
                }
            }
            this.referencedAssemblies = referencedAssemblies.AsReadOnly();
            this.knownTypeCache       = new KnownTypeCache(this);
        }
		public SimpleCompilation(ISolutionSnapshot solutionSnapshot, IUnresolvedAssembly mainAssembly, IEnumerable<IAssemblyReference> assemblyReferences)
		{
			if (solutionSnapshot == null)
				throw new ArgumentNullException("solutionSnapshot");
			if (mainAssembly == null)
				throw new ArgumentNullException("mainAssembly");
			if (assemblyReferences == null)
				throw new ArgumentNullException("assemblyReferences");
			this.solutionSnapshot = solutionSnapshot;
			this.context = new SimpleTypeResolveContext(this);
			this.mainAssembly = mainAssembly.Resolve(context);
			List<IAssembly> assemblies = new List<IAssembly>();
			assemblies.Add(this.mainAssembly);
			List<IAssembly> referencedAssemblies = new List<IAssembly>();
			foreach (var asmRef in assemblyReferences) {
				IAssembly asm = asmRef.Resolve(context);
				if (asm != null && !assemblies.Contains(asm))
					assemblies.Add(asm);
				if (asm != null && !referencedAssemblies.Contains(asm))
					referencedAssemblies.Add(asm);
			}
			this.assemblies = assemblies.AsReadOnly();
			this.referencedAssemblies = referencedAssemblies.AsReadOnly();
			this.knownTypeCache = new KnownTypeCache(this);
		}
		public SimpleCompilation(ISolutionSnapshot solutionSnapshot, IUnresolvedAssembly mainAssembly, IEnumerable<IAssemblyReference> assemblyReferences)
		{
			if (solutionSnapshot == null)
				throw new ArgumentNullException("solutionSnapshot");
			if (mainAssembly == null)
				throw new ArgumentNullException("mainAssembly");
			if (assemblyReferences == null)
				throw new ArgumentNullException("assemblyReferences");
			this.solutionSnapshot = solutionSnapshot;
			this.context = new SimpleTypeResolveContext(this);
			this.mainAssembly = mainAssembly.Resolve(context);
			List<IAssembly> assemblies = new List<IAssembly>();
			assemblies.Add(this.mainAssembly);
			List<IAssembly> referencedAssemblies = new List<IAssembly>();
			foreach (var asmRef in assemblyReferences) {
				IAssembly asm;
				try {
					asm = asmRef.Resolve(context);
				} catch (InvalidOperationException) {
					throw new InvalidOperationException("Tried to initialize compilation with an invalid assembly reference. (Forgot to load the assembly reference ? - see CecilLoader)");
				}
				if (asm != null && !assemblies.Contains(asm))
					assemblies.Add(asm);
				if (asm != null && !referencedAssemblies.Contains(asm))
					referencedAssemblies.Add(asm);
			}
			this.assemblies = assemblies.AsReadOnly();
			this.referencedAssemblies = referencedAssemblies.AsReadOnly();
			this.knownTypeCache = new KnownTypeCache(this);
		}
        public SimpleCompilation(ISolutionSnapshot solutionSnapshot, IUnresolvedAssembly mainAssembly, IEnumerable <IAssemblyReference> assemblyReferences)
        {
            if (solutionSnapshot == null)
            {
                throw new ArgumentNullException("solutionSnapshot");
            }
            if (mainAssembly == null)
            {
                throw new ArgumentNullException("mainAssembly");
            }
            if (assemblyReferences == null)
            {
                throw new ArgumentNullException("assemblyReferences");
            }
            this.solutionSnapshot = solutionSnapshot;
            this.context          = new SimpleTypeResolveContext(this);
            this.mainAssembly     = mainAssembly.Resolve(context);
            List <IAssembly> assemblies = new List <IAssembly>();

            assemblies.Add(this.mainAssembly);
            List <IAssembly> referencedAssemblies = new List <IAssembly>();

            foreach (var asmRef in assemblyReferences)
            {
                IAssembly asm;
                try
                {
                    asm = asmRef.Resolve(context);
                }
                catch (InvalidOperationException)
                {
                    throw new InvalidOperationException("Tried to initialize compilation with an invalid assembly reference. (Forgot to load the assembly reference ? - see CecilLoader)");
                }
                if (asm != null && !assemblies.Contains(asm))
                {
                    assemblies.Add(asm);
                }
                if (asm != null && !referencedAssemblies.Contains(asm))
                {
                    referencedAssemblies.Add(asm);
                }
            }
            this.assemblies           = assemblies.AsReadOnly();
            this.referencedAssemblies = referencedAssemblies.AsReadOnly();
            this.knownTypeCache       = new KnownTypeCache(this);
        }