public BVE5Compilation(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");

            solution_snapshot = solutionSnapshot;
            context = new SimpleTypeResolveContext(this);
            main_assembly = mainAssembly.Resolve(context);
            var assemblies = new List<IAssembly>{main_assembly};
            var referenced_assemblies = new List<IAssembly>();
            foreach(var asm_ref in assemblyReferences){
                IAssembly asm = asm_ref.Resolve(context);
                if(asm != null && !assemblies.Contains(asm))
                    assemblies.Add(asm);

                if(asm != null && !referenced_assemblies.Contains(asm))
                    referenced_assemblies.Add(asm);
            }

            this.assemblies = assemblies.AsReadOnly();
            this.referenced_assemblies = referenced_assemblies.AsReadOnly();
            this.type_cache = new PrimitiveTypeCache(this);
        }
Example #2
0
        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);
        }
Example #3
0
		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);
		}
Example #4
0
		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);
		}
Example #5
0
        public void Setup()
        {
            pc1 = new CSharpProjectContent()
                  .SetAssemblyName("PC1")
                  .SetProjectFileName("PC1.csproj")
                  .AddAssemblyReferences(new IAssemblyReference[] { CecilLoaderTests.Mscorlib, new ProjectReference("PC2.csproj") });

            pc2 = new CSharpProjectContent()
                  .SetAssemblyName("PC2")
                  .SetProjectFileName("PC2.csproj")
                  .AddAssemblyReferences(new IAssemblyReference[] { CecilLoaderTests.Mscorlib, new ProjectReference("PC1.csproj") });

            solution = new DefaultSolutionSnapshot(new[] { pc1, pc2 });
        }
		public void Setup()
		{
			pc1 = new CSharpProjectContent()
				.SetAssemblyName("PC1")
				.SetProjectFileName("PC1.csproj")
				.AddAssemblyReferences(new IAssemblyReference[] { CecilLoaderTests.Mscorlib, new ProjectReference("PC2.csproj") });

			pc2 = new CSharpProjectContent()
				.SetAssemblyName("PC2")
				.SetProjectFileName("PC2.csproj")
				.AddAssemblyReferences(new IAssemblyReference[] { CecilLoaderTests.Mscorlib, new ProjectReference("PC1.csproj") });
			
			solution = new DefaultSolutionSnapshot(new[] { pc1, pc2 });
		}
Example #7
0
        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);
        }
Example #8
0
		public virtual ICompilation CreateCompilation(ISolutionSnapshot solutionSnapshot)
		{
			return new SimpleCompilation(solutionSnapshot, this, assemblyReferences);
		}
 public virtual ICompilation CreateCompilation(ISolutionSnapshot solutionSnapshot)
 {
     return(new SimpleCompilation(solutionSnapshot, this, assemblyReferences));
 }
 public SimpleCompilation(ISolutionSnapshot solutionSnapshot, IUnresolvedAssembly mainAssembly, params IAssemblyReference[] assemblyReferences)
     : this(solutionSnapshot, mainAssembly, (IEnumerable <IAssemblyReference>)assemblyReferences)
 {
 }
Example #11
0
 public SimpleCompilation(ISolutionSnapshot solutionSnapshot, IUnresolvedAssembly mainAssembly, params IAssemblyReference[] assemblyReferences)
     : this(solutionSnapshot, mainAssembly, (IEnumerable<IAssemblyReference>)assemblyReferences)
 {
 }
 public MonoDevelopCompilation(ISolutionSnapshot solutionSnapshot, MonoDevelopProjectContent content, IEnumerable<IAssemblyReference> assemblyReferences)
     : base(solutionSnapshot, content, assemblyReferences)
 {
     this.content = content;
 }
 public override ICompilation CreateCompilation(ISolutionSnapshot solutionSnapshot)
 {
     return new MonoDevelopCompilation(solutionSnapshot, this, AssemblyReferences);
 }
 public MonoDevelopCompilation(ISolutionSnapshot solutionSnapshot, MonoDevelopProjectContent content, IEnumerable <IAssemblyReference> assemblyReferences) : base(solutionSnapshot, content, assemblyReferences)
 {
     this.content = content;
 }
 public override ICompilation CreateCompilation(ISolutionSnapshot solutionSnapshot)
 {
     return(new MonoDevelopCompilation(solutionSnapshot, this, AssemblyReferences));
 }
 public ICompilation CreateCompilation(ISolutionSnapshot solutionSnapshot)
 {
     return new BVE5Compilation(solutionSnapshot, this, assembly_references);
 }