예제 #1
0
        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));
        }
예제 #2
0
        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));
        }
예제 #3
0
 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);
 }
예제 #4
0
        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));
        }
예제 #5
0
        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));
        }
예제 #6
0
        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);
        }
예제 #7
0
        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 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);
            }
        }
예제 #9
0
 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);
 }