Example #1
0
        public CompilerResults CompileAssemblyFromFileBatch(CompilerParameters options, string[] fileNames)
        {
            //System.Diagnostics.Debug.Assert(false);
            foreach (string file in fileNames)
                if (file.ToLower().EndsWith(".xaml"))
                    return CompileAssemblyFromFileBatchImpl(options, fileNames);

            if (options.ToString() == "" || options == null)
                return new CSharpCodeProvider().CreateCompiler().CompileAssemblyFromFileBatch(options, fileNames);
            else
                return new CSharpCodeProvider(new Dictionary<string, string>() { { "CompilerVersion", options.ToString() } }).CreateCompiler().CompileAssemblyFromFileBatch(options, fileNames);
        }
Example #2
0
		public CompilerResults CompileAssemblyFromFileBatch(CompilerParameters options, string[] fileNames)
		{
			string tempFile;
			ArrayList classlessFiles = new ArrayList(); 
			ArrayList files = new ArrayList();
			int count = 0;
			CCSharpParser ccs;
			foreach (string file in fileNames)
			{
				ccs = new CCSharpParser(file);
				if (!ccs.isClassless)
				{
					files.Add(file);
				}
				else
				{
					tempFile = ccs.ToTempFile(count > 0 );
					classlessFiles.Add(tempFile);
					files.Add(tempFile);
				}
				count++;
			}
			
            Microsoft.CSharp.CSharpCodeProvider provider;

            if (options.ToString() == "" || options == null)
                return new Microsoft.CSharp.CSharpCodeProvider().CreateCompiler().CompileAssemblyFromFileBatch(options, fileNames);
            else
                return new Microsoft.CSharp.CSharpCodeProvider(new Dictionary<string, string>() { { "CompilerVersion", options.ToString() } }).CreateCompiler().CompileAssemblyFromFileBatch(options, fileNames);

            CompilerResults retval;
            retval = provider.CreateCompiler().CompileAssemblyFromFileBatch(options, (string[])files.ToArray(typeof(string)));
			
			
			if (!retval.Errors.HasErrors)
				foreach (string file in classlessFiles)
					try
					{ 
						File.Delete(file);
					} 
					catch{}

			return retval;
		}
        public CompilationException(
            CodeDomProvider provider,
            CompilerParameters parameters,
            CompilerResults results,
            params String[] sources
            )
        {
            StringWriter sw = new StringWriter();
            sw.WriteLine("Compilation:  {0} errors", results.Errors.Count);
            sw.WriteLine("Compiler: {0}", provider.FileExtension);
            sw.WriteLine("CompilerParameters: {0}", parameters.ToString());
            foreach (CompilerError error in results.Errors)
            {
                sw.WriteLine(error.ToString());
            }
            sw.WriteLine("Sources:");
            foreach (string source in sources)
                sw.WriteLine(source);

            this.body = sw.ToString();
        }
        public CompilationException(
            ICodeCompiler compiler,
            CompilerParameters parameters,
            CompilerResults results,
            params String[] sources
            )
        {
            StringWriter sw = new StringWriter();
            sw.WriteLine("Compilation:  {0} errors",results.Errors.Count);
            sw.WriteLine("Compiler: {0}",compiler.GetType().Name);
            sw.WriteLine("CompilerParameters: {0}",parameters.ToString());
            foreach(CompilerError error in results.Errors)
            {
                sw.WriteLine(error.ToString());
            }
            sw.WriteLine("Sources:");
            foreach(string source in sources)
                sw.WriteLine(source);

            this.message =sw.ToString();
        }