CSharpCodeCompiler NET_2_0 cleanup
[mono.git] / mcs / class / System / Microsoft.CSharp / CSharpCodeCompiler.cs
index e87382edba56daf6811841516503fd4ae82d4319..c0c635ef2d64906b4a9407bab4a8b3d9893ff3f8 100644 (file)
@@ -42,21 +42,16 @@ namespace Mono.CSharp
        using System.Collections.Specialized;
        using System.Diagnostics;
        using System.Text.RegularExpressions;
-       
-#if NET_2_0
        using System.Threading;
        using System.Collections.Generic;
-#endif
        
        internal class CSharpCodeCompiler : CSharpCodeGenerator, ICodeCompiler
        {
                static string windowsMcsPath;
                static string windowsMonoPath;
 
-#if NET_2_0
                Mutex mcsOutMutex;
                StringCollection mcsOutput;
-#endif
                
                static CSharpCodeCompiler ()
                {
@@ -85,12 +80,9 @@ namespace Mono.CSharp
 #if NET_4_0
                                windowsMcsPath =
                                        Path.Combine (p, "4.0\\dmcs.exe");
-#elif NET_2_0
-                               windowsMcsPath =
-                                       Path.Combine (p, "2.0\\gmcs.exe");
 #else
                                windowsMcsPath =
-                                       Path.Combine (p, "1.0\\mcs.exe");
+                                       Path.Combine (p, "2.0\\gmcs.exe");
 #endif
                                if (!File.Exists (windowsMcsPath))
 #if NET_4_0
@@ -98,16 +90,11 @@ namespace Mono.CSharp
                                                Path.Combine(
                                                        Path.GetDirectoryName (p),
                                                        "lib\\net_4_0\\dmcs.exe");
-#elif NET_2_0
-                                       windowsMcsPath = 
-                                               Path.Combine(
-                                                       Path.GetDirectoryName (p),
-                                                       "lib\\net_2_0\\gmcs.exe");
 #else
                                        windowsMcsPath = 
                                                Path.Combine(
                                                        Path.GetDirectoryName (p),
-                                                       "lib\\default\\mcs.exe");
+                                                       "lib\\net_2_0\\gmcs.exe");
 #endif
                                if (!File.Exists (windowsMcsPath))
                                        throw new FileNotFoundException ("Windows mcs path not found: " + windowsMcsPath);
@@ -121,12 +108,10 @@ namespace Mono.CSharp
                {
                }
 
-#if NET_2_0
                public CSharpCodeCompiler (IDictionary <string, string> providerOptions) :
                        base (providerOptions)
                {
                }
-#endif
                
                //
                // Methods
@@ -194,24 +179,13 @@ namespace Mono.CSharp
 
                        CompilerResults results=new CompilerResults(options.TempFiles);
                        Process mcs=new Process();
-
-#if !NET_2_0
-                       string mcs_output;
-                       string mcs_stdout;
-                       string[] mcsOutput;
-#endif
                        
                        // FIXME: these lines had better be platform independent.
                        if (Path.DirectorySeparatorChar == '\\') {
                                mcs.StartInfo.FileName = windowsMonoPath;
                                mcs.StartInfo.Arguments = "\"" + windowsMcsPath + "\" " +
-#if NET_2_0
                                        BuildArgs (options, fileNames, ProviderOptions);
-#else
-                                       BuildArgs (options, fileNames);
-#endif
                        } else {
-#if NET_2_0
                                // FIXME: This is a temporary hack to make code genaration work in 2.0+
 #if NET_4_0
                                mcs.StartInfo.FileName="dmcs";
@@ -219,16 +193,10 @@ namespace Mono.CSharp
                                mcs.StartInfo.FileName="gmcs";
 #endif
                                mcs.StartInfo.Arguments=BuildArgs(options, fileNames, ProviderOptions);
-#else
-                               mcs.StartInfo.FileName="mcs";
-                               mcs.StartInfo.Arguments=BuildArgs(options, fileNames);
-#endif
                        }
 
-#if NET_2_0
                        mcsOutput = new StringCollection ();
                        mcsOutMutex = new Mutex ();
-#endif
 
                        string monoPath = Environment.GetEnvironmentVariable ("MONO_PATH");
                        if (monoPath == null)
@@ -250,9 +218,7 @@ namespace Mono.CSharp
                        mcs.StartInfo.UseShellExecute=false;
                        mcs.StartInfo.RedirectStandardOutput=true;
                        mcs.StartInfo.RedirectStandardError=true;
-#if NET_2_0
                        mcs.ErrorDataReceived += new DataReceivedEventHandler (McsStderrDataReceived);
-#endif
                        
                        try {
                                mcs.Start();
@@ -266,38 +232,21 @@ namespace Mono.CSharp
                        }
 
                        try {
-#if NET_2_0
                                mcs.BeginOutputReadLine ();
                                mcs.BeginErrorReadLine ();
-#else
-                               // If there are a few kB in stdout, we might lock
-                               mcs_output=mcs.StandardError.ReadToEnd();
-                               mcs_stdout=mcs.StandardOutput.ReadToEnd ();
-#endif
                                mcs.WaitForExit();
                                
                                results.NativeCompilerReturnValue = mcs.ExitCode;
                        } finally {
-#if NET_2_0
                                mcs.CancelErrorRead ();
                                mcs.CancelOutputRead ();
-#endif
-
                                mcs.Close();
                        }
 
-#if NET_2_0
                        StringCollection sc = mcsOutput;
-#else
-                       mcsOutput = mcs_output.Split (System.Environment.NewLine.ToCharArray ());
-                       StringCollection sc = new StringCollection ();
-#endif
                       
                        bool loadIt=true;
                        foreach (string error_line in mcsOutput) {
-#if !NET_2_0
-                               sc.Add (error_line);
-#endif
                                CompilerError error = CreateErrorFromString (error_line);
                                if (error != null) {
                                        results.Errors.Add (error);
@@ -338,7 +287,6 @@ namespace Mono.CSharp
                        return results;
                }
 
-#if NET_2_0
                void McsStderrDataReceived (object sender, DataReceivedEventArgs args)
                {
                        if (args.Data != null) {
@@ -349,9 +297,6 @@ namespace Mono.CSharp
                }               
 
                private static string BuildArgs(CompilerParameters options,string[] fileNames, IDictionary <string, string> providerOptions)
-#else
-               private static string BuildArgs(CompilerParameters options,string[] fileNames)
-#endif
                {
                        StringBuilder args=new StringBuilder();
                        if (options.GenerateExecutable)
@@ -397,7 +342,6 @@ namespace Mono.CSharp
                                args.Append (" ");
                        }
 
-#if NET_2_0
                        foreach (string embeddedResource in options.EmbeddedResources) {
                                args.AppendFormat("/resource:\"{0}\" ", embeddedResource);
                        }
@@ -429,7 +373,6 @@ namespace Mono.CSharp
                                                break;
                                }
                        }
-#endif
 
                        args.Append (" -- ");
                        foreach (string source in fileNames)
@@ -438,10 +381,9 @@ namespace Mono.CSharp
                }
                private static CompilerError CreateErrorFromString(string error_string)
                {
-#if NET_2_0
                        if (error_string.StartsWith ("BETA"))
                                return null;
-#endif
+
                        if (error_string == null || error_string == "")
                                return null;