internal static int Run(string[] args)
        {

            CompilerFatalError.Handler = FailFast.OnFatalException;

            Csc compiler = new Csc(CSharpResponseFileName, Directory.GetCurrentDirectory(), args);

            // We store original encoding and restore it later to revert 
            // the changes that might be done by /utf8output options
            // NOTE: original encoding may not be restored if process terminated 
            Encoding origEncoding = Console.OutputEncoding;
            try
            {
                if (compiler.Arguments.Utf8Output && Console.IsOutputRedirected)
                {
                    Console.OutputEncoding = Encoding.UTF8;
                }
                return compiler.Run(Console.Out);
            }
            finally
            {
                try
                {
                    Console.OutputEncoding = origEncoding;
                }
                catch
                { // Try to reset the output encoding, ignore if we can't
                }
            }

        }
Beispiel #2
0
        internal static int Run(string[] args, BuildPaths buildPaths, TextWriter textWriter, IAnalyzerAssemblyLoader analyzerLoader)
        {
            FatalError.Handler = FailFast.OnFatalException;

            var responseFile = Path.Combine(buildPaths.ClientDirectory, CSharpCompiler.ResponseFileName);
            var compiler = new Csc(responseFile, buildPaths, args, analyzerLoader);
            return ConsoleUtil.RunWithUtf8Output(compiler.Arguments.Utf8Output, textWriter, tw => compiler.Run(tw));
        }
Beispiel #3
0
        internal static int Run(string clientDirectory, string sdkDirectory, string[] args)
        {
            FatalError.Handler = FailFast.OnFatalException;

            var responseFile = Path.Combine(clientDirectory, CSharpCompiler.ResponseFileName);
            Csc compiler     = new Csc(responseFile, clientDirectory, Directory.GetCurrentDirectory(), sdkDirectory, args);

            return(ConsoleUtil.RunWithOutput(compiler.Arguments.Utf8Output, (textWriterOut, _) => compiler.Run(textWriterOut)));
        }
Beispiel #4
0
        internal static int Run(string clientDirectory, string sdkDirectory, string[] args, IAnalyzerAssemblyLoader analyzerLoader)
        {
            FatalError.Handler = FailFast.OnFatalException;

            var responseFile = Path.Combine(clientDirectory, CSharpCompiler.ResponseFileName);
            Csc compiler = new Csc(responseFile, clientDirectory, Directory.GetCurrentDirectory(), sdkDirectory, args, analyzerLoader);

            return ConsoleUtil.RunWithOutput(compiler.Arguments.Utf8Output, (textWriterOut, _) => compiler.Run(textWriterOut));
        }
Beispiel #5
0
        internal static int Run(string[] args, BuildPathsAlt buildPaths, TextWriter textWriter, IAnalyzerAssemblyLoader analyzerLoader)
        {
            ReflFatalError.set_Handler(FailFast.OnFatalException);

            var responseFile = Path.Combine(buildPaths.ClientDirectory, CSharpCompiler.ResponseFileName);
            var compiler     = new Csc(responseFile, buildPaths, args, analyzerLoader);

            return(ConsoleUtil.RunWithUtf8Output(compiler.Arguments.Utf8Output, textWriter, tw => compiler.Run(tw)));
        }
Beispiel #6
0
 public static int Run(
     string[] args,
     string clientDir,
     string workingDir,
     string sdkDir,
     string tempDir,
     TextWriter textWriter,
     IAnalyzerAssemblyLoader analyzerLoader
     ) =>
 Csc.Run(
     args,
     new BuildPaths(
         clientDir: clientDir,
         workingDir: workingDir,
         sdkDir: sdkDir,
         tempDir: tempDir
         ),
     textWriter,
     analyzerLoader
     );
Beispiel #7
0
 public static int Main(string[] args)
 => Csc.Run(args: args,
            clientDirectory: AppContext.BaseDirectory,
            sdkDirectory: null,
            analyzerLoader: CoreClrAnalyzerAssemblyLoader.CreateAndSetDefault());
Beispiel #8
0
 public static int Main(string[] args)
 => Csc.Run(args: args,
            clientDirectory: AppContext.BaseDirectory,
            sdkDirectory: @"C:\Windows\Microsoft.NET\Framework\v4.0.30319",
            analyzerLoader: new NoOpAnalyzerAssemblyLoader());