private VsaEngine CreateAndInitEngine(CompilerParameters options, string[] sourceFiles, string outputFile, TextWriter output) { VsaEngine engine = new VsaEngine(true); VsaSite site = new VsaSite(output); engine.InitVsaEngine("JSCodeGenerator://Microsoft.JScript.Vsa.VsaEngine", site); // Ensure that all options are valid; throw a CmdLineException otherwise this.ValidateOptions(options, engine); // Set options on the engine (equivalent of cmdline args in out-of-proc scenario) engine.GenerateDebugInfo = options.IncludeDebugInformation; engine.SetOption("referenceLoaderAPI", "LoadFile"); engine.SetOption("fast", true); engine.SetOption("print", false); engine.SetOption("VersionSafe", false); engine.SetOption("output", options.OutputAssembly); if (options.GenerateExecutable) { engine.SetOption("PEFileKind", PEFileKinds.ConsoleApplication); } else { engine.SetOption("PEFileKind", PEFileKinds.Dll); } site.treatWarningsAsErrors = options.TreatWarningsAsErrors; engine.SetOption("warnaserror", options.TreatWarningsAsErrors); site.warningLevel = options.WarningLevel; engine.SetOption("WarningLevel", options.WarningLevel); bool stdLibAdded = false; foreach (string assemblyName in options.ReferencedAssemblies) { if (String.Compare(Path.GetFileName(assemblyName), "mscorlib.dll", StringComparison.OrdinalIgnoreCase) == 0) { stdLibAdded = true; } this.AddAssemblyReference(engine, assemblyName); } if (!stdLibAdded) { this.AddAssemblyReference(engine, "mscorlib.dll"); } // Parse any additional compiler options StringCollection compilerOptions = this.SplitCmdLineArguments(options.CompilerOptions); this.ParseCompilerOptions(engine, compilerOptions, output, options.GenerateExecutable); // Add the source files to the engine (as IVsaCodeItems) for (int j = 0; j < sourceFiles.Length; j++) { this.AddSourceFile(engine, sourceFiles[j]); } return(engine); }
private VsaEngine CreateAndInitEngine(CompilerParameters options, string[] sourceFiles, string outputFile, TextWriter output) { VsaEngine engine = new VsaEngine(true); VsaSite site = new VsaSite(output); engine.InitVsaEngine("JSCodeGenerator://Microsoft.JScript.Vsa.VsaEngine", site); this.ValidateOptions(options, engine); engine.GenerateDebugInfo = options.IncludeDebugInformation; engine.SetOption("referenceLoaderAPI", "LoadFile"); engine.SetOption("fast", true); engine.SetOption("print", false); engine.SetOption("VersionSafe", false); engine.SetOption("output", options.OutputAssembly); if (options.GenerateExecutable) { engine.SetOption("PEFileKind", PEFileKinds.ConsoleApplication); } else { engine.SetOption("PEFileKind", PEFileKinds.Dll); } site.treatWarningsAsErrors = options.TreatWarningsAsErrors; engine.SetOption("warnaserror", options.TreatWarningsAsErrors); site.warningLevel = options.WarningLevel; engine.SetOption("WarningLevel", options.WarningLevel); if ((options.Win32Resource != null) && (options.Win32Resource.Length > 0)) { engine.SetOption("win32resource", options.Win32Resource); } bool flag = false; foreach (string str in options.ReferencedAssemblies) { if (string.Compare(Path.GetFileName(str), "mscorlib.dll", StringComparison.OrdinalIgnoreCase) == 0) { flag = true; } this.AddAssemblyReference(engine, str); } if (!flag) { this.AddAssemblyReference(engine, "mscorlib.dll"); } StringCollection args = this.SplitCmdLineArguments(options.CompilerOptions); this.ParseCompilerOptions(engine, args, output, options.GenerateExecutable); for (int i = 0; i < sourceFiles.Length; i++) { this.AddSourceFile(engine, sourceFiles[i]); } return(engine); }
private VsaEngine CreateAndInitEngine(CompilerParameters options, string[] sourceFiles, string outputFile, TextWriter output) { VsaEngine engine = new VsaEngine(true); VsaSite site = new VsaSite(output); engine.InitVsaEngine("JSCodeGenerator://Microsoft.JScript.Vsa.VsaEngine", site); this.ValidateOptions(options, engine); engine.GenerateDebugInfo = options.IncludeDebugInformation; engine.SetOption("referenceLoaderAPI", "LoadFile"); engine.SetOption("fast", true); engine.SetOption("print", false); engine.SetOption("VersionSafe", false); engine.SetOption("output", options.OutputAssembly); if (options.GenerateExecutable) { engine.SetOption("PEFileKind", PEFileKinds.ConsoleApplication); } else { engine.SetOption("PEFileKind", PEFileKinds.Dll); } site.treatWarningsAsErrors = options.TreatWarningsAsErrors; engine.SetOption("warnaserror", options.TreatWarningsAsErrors); site.warningLevel = options.WarningLevel; engine.SetOption("WarningLevel", options.WarningLevel); if ((options.Win32Resource != null) && (options.Win32Resource.Length > 0)) { engine.SetOption("win32resource", options.Win32Resource); } bool flag = false; foreach (string str in options.ReferencedAssemblies) { if (string.Compare(Path.GetFileName(str), "mscorlib.dll", StringComparison.OrdinalIgnoreCase) == 0) { flag = true; } this.AddAssemblyReference(engine, str); } if (!flag) { this.AddAssemblyReference(engine, "mscorlib.dll"); } StringCollection args = this.SplitCmdLineArguments(options.CompilerOptions); this.ParseCompilerOptions(engine, args, output, options.GenerateExecutable); for (int i = 0; i < sourceFiles.Length; i++) { this.AddSourceFile(engine, sourceFiles[i]); } return engine; }
private VsaEngine CreateAndInitEngine(CompilerParameters options, string[] sourceFiles, string outputFile, TextWriter output){ VsaEngine engine = new VsaEngine(true); VsaSite site = new VsaSite(output); engine.InitVsaEngine("JSCodeGenerator://Microsoft.JScript.Vsa.VsaEngine", site); // Ensure that all options are valid; throw a CmdLineException otherwise this.ValidateOptions(options, engine); // Set options on the engine (equivalent of cmdline args in out-of-proc scenario) engine.GenerateDebugInfo = options.IncludeDebugInformation; engine.SetOption("referenceLoaderAPI", "LoadFile"); engine.SetOption("fast", true); engine.SetOption("print", false); engine.SetOption("VersionSafe", false); engine.SetOption("output", options.OutputAssembly); if (options.GenerateExecutable) engine.SetOption("PEFileKind", PEFileKinds.ConsoleApplication); else engine.SetOption("PEFileKind", PEFileKinds.Dll); site.treatWarningsAsErrors = options.TreatWarningsAsErrors; engine.SetOption("warnaserror", options.TreatWarningsAsErrors); site.warningLevel = options.WarningLevel; engine.SetOption("WarningLevel", options.WarningLevel); bool stdLibAdded = false; foreach (string assemblyName in options.ReferencedAssemblies){ if (String.Compare(Path.GetFileName(assemblyName), "mscorlib.dll", StringComparison.OrdinalIgnoreCase) == 0) stdLibAdded = true; this.AddAssemblyReference(engine, assemblyName); } if (!stdLibAdded) this.AddAssemblyReference(engine, "mscorlib.dll"); // Parse any additional compiler options StringCollection compilerOptions = this.SplitCmdLineArguments(options.CompilerOptions); this.ParseCompilerOptions(engine, compilerOptions, output, options.GenerateExecutable); // Add the source files to the engine (as IVsaCodeItems) for (int j = 0; j < sourceFiles.Length; j++) this.AddSourceFile(engine, sourceFiles[j]); return engine; }