public bool TryCreateCompiler(RunRequest request, out CommonCompiler compiler) { switch (request.Language) { case LanguageNames.CSharp: compiler = new CSharpCompilerServer( this, args: request.Arguments, clientDirectory: ClientDirectory, baseDirectory: request.CurrentDirectory, sdkDirectory: SdkDirectory, libDirectory: request.LibDirectory, analyzerLoader: AnalyzerAssemblyLoader); return(true); case LanguageNames.VisualBasic: compiler = new VisualBasicCompilerServer( this, args: request.Arguments, clientDirectory: ClientDirectory, baseDirectory: request.CurrentDirectory, sdkDirectory: SdkDirectory, libDirectory: request.LibDirectory, analyzerLoader: AnalyzerAssemblyLoader); return(true); default: compiler = null; return(false); } }
public bool TryCreateCompiler(RunRequest request, out CommonCompiler compiler) { var buildPaths = new BuildPaths(ClientDirectory, request.CurrentDirectory, SdkDirectory, request.TempDirectory); switch (request.Language) { case LanguageNames.CSharp: compiler = new CSharpCompilerServer( AssemblyReferenceProvider, args: request.Arguments, buildPaths: buildPaths, libDirectory: request.LibDirectory, analyzerLoader: AnalyzerAssemblyLoader); return true; case LanguageNames.VisualBasic: compiler = new VisualBasicCompilerServer( AssemblyReferenceProvider, args: request.Arguments, buildPaths: buildPaths, libDirectory: request.LibDirectory, analyzerLoader: AnalyzerAssemblyLoader); return true; default: compiler = null; return false; } }
/// <summary> /// Invoke the C# compiler with the given arguments and current directory, and send output and error /// to the given TextWriters. /// </summary> private int CSharpCompile( string currentDirectory, string libDirectory, string responseFileDirectory, string tempPath, string[] commandLineArguments, TextWriter output, CancellationToken cancellationToken, out bool utf8output) { CompilerServerLogger.Log("CurrentDirectory = '{0}'", currentDirectory); CompilerServerLogger.Log("LIB = '{0}'", libDirectory); for (int i = 0; i < commandLineArguments.Length; ++i) { CompilerServerLogger.Log("Argument[{0}] = '{1}'", i, commandLineArguments[i]); } return(CSharpCompilerServer.RunCompiler( responseFileDirectory, commandLineArguments, currentDirectory, libDirectory, tempPath, output, cancellationToken, out utf8output)); }
public bool TryCreateCompiler(RunRequest request, out CommonCompiler compiler) { switch (request.Language) { case LanguageNames.CSharp: compiler = new CSharpCompilerServer( this, args: request.Arguments, clientDirectory: ClientDirectory, baseDirectory: request.CurrentDirectory, sdkDirectory: SdkDirectory, libDirectory: request.LibDirectory, analyzerLoader: AnalyzerAssemblyLoader); return true; case LanguageNames.VisualBasic: compiler = new VisualBasicCompilerServer( this, args: request.Arguments, clientDirectory: ClientDirectory, baseDirectory: request.CurrentDirectory, sdkDirectory: SdkDirectory, libDirectory: request.LibDirectory, analyzerLoader: AnalyzerAssemblyLoader); return true; default: compiler = null; return false; } }
public bool TryCreateCompiler(RunRequest request, out CommonCompiler compiler) { var buildPaths = new BuildPaths(ClientDirectory, request.CurrentDirectory, SdkDirectory, request.TempDirectory); switch (request.Language) { case LanguageNames.CSharp: compiler = new CSharpCompilerServer( AssemblyReferenceProvider, args: request.Arguments, buildPaths: buildPaths, libDirectory: request.LibDirectory, analyzerLoader: AnalyzerAssemblyLoader); return(true); case LanguageNames.VisualBasic: compiler = new VisualBasicCompilerServer( AssemblyReferenceProvider, args: request.Arguments, buildPaths: buildPaths, libDirectory: request.LibDirectory, analyzerLoader: AnalyzerAssemblyLoader); return(true); default: compiler = null; return(false); } }
public bool TryCreateCompiler(RunRequest request, BuildPaths buildPaths, [NotNullWhen(true)] out CommonCompiler?compiler) { switch (request.Language) { case LanguageNames.CSharp: compiler = new CSharpCompilerServer( AssemblyReferenceProvider, args: request.Arguments, buildPaths: buildPaths, libDirectory: request.LibDirectory, analyzerLoader: AnalyzerAssemblyLoader); return(true); case LanguageNames.VisualBasic: compiler = new VisualBasicCompilerServer( AssemblyReferenceProvider, args: request.Arguments, buildPaths: buildPaths, libDirectory: request.LibDirectory, analyzerLoader: AnalyzerAssemblyLoader); return(true); default: compiler = null; return(false); } }
public static int RunCompiler(string[] args, string baseDirectory, string libDirectory, TextWriter output, CancellationToken cancellationToken, out bool utf8output) { CSharpCompiler compiler = new CSharpCompilerServer(CSharpResponseFileName, args, baseDirectory, libDirectory); utf8output = compiler.Arguments.Utf8Output; return(compiler.Run(output, cancellationToken)); }
public static int RunCompiler( string clientDirectory, string[] args, string baseDirectory, string sdkDirectory, string libDirectory, TextWriter output, CancellationToken cancellationToken, out bool utf8output) { var compiler = new CSharpCompilerServer(args, clientDirectory, baseDirectory, sdkDirectory, libDirectory); utf8output = compiler.Arguments.Utf8Output; return(compiler.Run(output, cancellationToken)); }
public static int RunCompiler( string responseFileDirectory, string[] args, string baseDirectory, string libDirectory, string tempPath, TextWriter output, CancellationToken cancellationToken, out bool utf8output) { var responseFile = Path.Combine(responseFileDirectory, CSharpCompiler.ResponseFileName); var compiler = new CSharpCompilerServer(responseFile, args, baseDirectory, libDirectory, tempPath); utf8output = compiler.Arguments.Utf8Output; return compiler.Run(output, cancellationToken); }
public static int RunCompiler( string responseFileDirectory, string[] args, string baseDirectory, string libDirectory, string tempPath, TextWriter output, CancellationToken cancellationToken, out bool utf8output) { var responseFile = Path.Combine(responseFileDirectory, CSharpCompiler.ResponseFileName); var compiler = new CSharpCompilerServer(responseFile, args, baseDirectory, libDirectory, tempPath); utf8output = compiler.Arguments.Utf8Output; return(compiler.Run(output, cancellationToken)); }
public static int RunCompiler( string clientDirectory, string[] args, string baseDirectory, string sdkDirectory, string libDirectory, IAnalyzerAssemblyLoader analyzerLoader, TextWriter output, CancellationToken cancellationToken, out bool utf8output) { var compiler = new CSharpCompilerServer(args, clientDirectory, baseDirectory, sdkDirectory, libDirectory, analyzerLoader); utf8output = compiler.Arguments.Utf8Output; foreach (var analyzer in compiler.Arguments.AnalyzerReferences) { CompilerServerFileWatcher.AddPath(analyzer.FilePath); } return(compiler.Run(output, cancellationToken)); }
public static BuildResponse RunCompiler( string clientDirectory, string[] args, string baseDirectory, string sdkDirectory, string libDirectory, IAnalyzerAssemblyLoader analyzerLoader, CancellationToken cancellationToken) { var compiler = new CSharpCompilerServer(args, clientDirectory, baseDirectory, sdkDirectory, libDirectory, analyzerLoader); bool utf8output = compiler.Arguments.Utf8Output; if (!AnalyzerConsistencyChecker.Check(baseDirectory, compiler.Arguments.AnalyzerReferences, analyzerLoader)) { return new AnalyzerInconsistencyBuildResponse(); } TextWriter output = new StringWriter(CultureInfo.InvariantCulture); int returnCode = compiler.Run(output, cancellationToken); return new CompletedBuildResponse(returnCode, utf8output, output.ToString(), string.Empty); }
public static BuildResponse RunCompiler( string clientDirectory, string[] args, string baseDirectory, string sdkDirectory, string libDirectory, IAnalyzerAssemblyLoader analyzerLoader, CancellationToken cancellationToken) { var compiler = new CSharpCompilerServer(args, clientDirectory, baseDirectory, sdkDirectory, libDirectory, analyzerLoader); bool utf8output = compiler.Arguments.Utf8Output; if (!AnalyzerConsistencyChecker.Check(baseDirectory, compiler.Arguments.AnalyzerReferences, analyzerLoader)) { return(new AnalyzerInconsistencyBuildResponse()); } TextWriter output = new StringWriter(CultureInfo.InvariantCulture); int returnCode = compiler.Run(output, cancellationToken); return(new CompletedBuildResponse(returnCode, utf8output, output.ToString(), string.Empty)); }
/// <summary> /// Invoke the C# compiler with the given arguments and current directory, and send output and error /// to the given TextWriters. /// </summary> private BuildResponse CSharpCompile( string currentDirectory, string libDirectory, string responseFileDirectory, string[] commandLineArguments, CancellationToken cancellationToken) { CompilerServerLogger.Log("CurrentDirectory = '{0}'", currentDirectory); CompilerServerLogger.Log("LIB = '{0}'", libDirectory); for (int i = 0; i < commandLineArguments.Length; ++i) { CompilerServerLogger.Log("Argument[{0}] = '{1}'", i, commandLineArguments[i]); } return(CSharpCompilerServer.RunCompiler( responseFileDirectory, commandLineArguments, currentDirectory, RuntimeEnvironment.GetRuntimeDirectory(), libDirectory, AnalyzerLoader, cancellationToken)); }
public void TrivialMetadataCaching() { List<String> filelist = new List<string>(); // Do the following compilation twice. // The compiler server API should hold on to the mscorlib bits // in memory, but the file tracker should still map that it was // touched. for (int i = 0; i < 2; i++) { var source1 = Temp.CreateFile().WriteAllText(helloWorldCS).Path; var touchedDir = Temp.CreateDirectory(); var touchedBase = Path.Combine(touchedDir.Path, "touched"); filelist.Add(source1); var outWriter = new StringWriter(); var cmd = new CSharpCompilerServer( new[] { "/nologo", "/touchedfiles:" + touchedBase, source1 }, null, _baseDirectory, RuntimeEnvironment.GetRuntimeDirectory(), s_libDirectory); List<string> expectedReads; List<string> expectedWrites; BuildTouchedFiles(cmd, Path.ChangeExtension(source1, "exe"), out expectedReads, out expectedWrites); var exitCode = cmd.Run(outWriter); Assert.Equal(string.Empty, outWriter.ToString().Trim()); Assert.Equal(0, exitCode); AssertTouchedFilesEqual(expectedReads, expectedWrites, touchedBase); } foreach (String f in filelist) { CleanupAllGeneratedFiles(f); } }
public static int RunCompiler(string[] args, string baseDirectory, string libDirectory, TextWriter output, CancellationToken cancellationToken) { CSharpCompiler compiler = new CSharpCompilerServer(CSharpResponseFileName, args, baseDirectory, libDirectory); return compiler.Run(output, cancellationToken); }