private CompilerResults CompileFromSourceBatch(CompilerParameters options, string[] sources) { if (options == null) { throw new ArgumentNullException("options"); } if (sources == null) { throw new ArgumentNullException("sources"); } string[] array = new string[sources.Length]; for (int i = 0; i < sources.Length; i++) { array[i] = ColossalCSharpCodeCompiler.GetTempFileNameWithExtension(options.TempFiles, i.ToString() + ".cs"); FileStream fileStream = new FileStream(array[i], FileMode.OpenOrCreate); using (StreamWriter streamWriter = new StreamWriter(fileStream, Encoding.UTF8)) { streamWriter.Write(sources[i]); streamWriter.Close(); } fileStream.Close(); } return(this.CompileFromFileBatch(options, array)); }
private static string BuildArgs(CompilerParameters options, string[] fileNames) { StringBuilder stringBuilder = new StringBuilder(); if (options.GenerateExecutable) { throw new NotSupportedException(); } stringBuilder.Append("/target:library "); string privateBinPath = AppDomain.CurrentDomain.SetupInformation.PrivateBinPath; if (!string.IsNullOrEmpty(privateBinPath)) { stringBuilder.AppendFormat("/lib:\"{0}\" ", privateBinPath); } if (options.IncludeDebugInformation) { stringBuilder.Append("/debug+ /optimize- "); } else { stringBuilder.Append("/debug- /optimize+ "); } if (options.TreatWarningsAsErrors) { stringBuilder.Append("/warnaserror "); } if (options.WarningLevel >= 0) { stringBuilder.AppendFormat("/warn:{0} ", options.WarningLevel); } if (string.IsNullOrEmpty(options.OutputAssembly)) { options.OutputAssembly = ColossalCSharpCodeCompiler.GetTempFileNameWithExtension(options.TempFiles, "dll", !options.GenerateInMemory); } stringBuilder.AppendFormat("/out:\"{0}\" ", options.OutputAssembly); foreach (string text in options.ReferencedAssemblies) { if (text != null && text.Length != 0) { stringBuilder.AppendFormat("/r:\"{0}\" ", text); } } if (options.CompilerOptions != null) { stringBuilder.Append(options.CompilerOptions); stringBuilder.Append(" "); } foreach (string arg in options.EmbeddedResources) { stringBuilder.AppendFormat("/resource:\"{0}\" ", arg); } foreach (string arg2 in options.LinkedResources) { stringBuilder.AppendFormat("/linkresource:\"{0}\" ", arg2); } stringBuilder.Append(" -- "); foreach (string arg3 in fileNames) { stringBuilder.AppendFormat("\"{0}\" ", arg3); } return(stringBuilder.ToString()); }