Add [Category ("NotWorking")] to failing test.
[mono.git] / mcs / mcs / settings.cs
1 //
2 // settings.cs: All compiler settings
3 //
4 // Author: Miguel de Icaza (miguel@ximian.com)
5 //            Ravi Pratap  (ravi@ximian.com)
6 //            Marek Safar  (marek.safar@gmail.com)
7 //
8 //
9 // Dual licensed under the terms of the MIT X11 or GNU GPL
10 //
11 // Copyright 2001 Ximian, Inc (http://www.ximian.com)
12 // Copyright 2004-2008 Novell, Inc
13 // Copyright 2011 Xamarin, Inc (http://www.xamarin.com)
14 //
15
16 using System.Collections.Generic;
17 using System.IO;
18 using System.Text;
19 using System.Globalization;
20 using System;
21
22 namespace Mono.CSharp {
23
24         public enum LanguageVersion
25         {
26                 ISO_1 = 1,
27                 ISO_2 = 2,
28                 V_3 = 3,
29                 V_4 = 4,
30                 V_5 = 5,
31                 Future = 100,
32
33                 Default = LanguageVersion.V_5,
34         }
35
36         public enum RuntimeVersion
37         {
38                 v1,
39                 v2,
40                 v4
41         }
42
43         public enum Target
44         {
45                 Library, Exe, Module, WinExe
46         }
47
48         public enum Platform
49         {
50                 AnyCPU,
51                 AnyCPU32Preferred,
52                 Arm,
53                 X86,
54                 X64,
55                 IA64
56         }
57
58         public class CompilerSettings
59         {
60                 public Target Target;
61                 public Platform Platform;
62                 public string TargetExt;
63                 public bool VerifyClsCompliance;
64                 public bool Optimize;
65                 public LanguageVersion Version;
66                 public bool EnhancedWarnings;
67                 public bool LoadDefaultReferences;
68                 public string SdkVersion;
69
70                 public string StrongNameKeyFile;
71                 public string StrongNameKeyContainer;
72                 public bool StrongNameDelaySign;
73
74                 public int TabSize;
75
76                 public bool WarningsAreErrors;
77                 public int WarningLevel;
78
79                 //
80                 // Assemblies references to be loaded
81                 //
82                 public List<string> AssemblyReferences;
83
84                 // 
85                 // External aliases for assemblies
86                 //
87                 public List<Tuple<string, string>> AssemblyReferencesAliases;
88
89                 //
90                 // Modules to be embedded
91                 //
92                 public List<string> Modules;
93
94                 //
95                 // Lookup paths for referenced assemblies
96                 //
97                 public List<string> ReferencesLookupPaths;
98
99                 //
100                 // Encoding.
101                 //
102                 public Encoding Encoding;
103
104                 //
105                 // If set, enable XML documentation generation
106                 //
107                 public string DocumentationFile;
108
109                 public string MainClass;
110
111                 //
112                 // Output file
113                 //
114                 public string OutputFile;
115
116                 // 
117                 // The default compiler checked state
118                 //
119                 public bool Checked;
120
121                 //
122                 // If true, the compiler is operating in statement mode,
123                 // this currently turns local variable declaration into
124                 // static variables of a class
125                 //
126                 public bool StatementMode;      // TODO: SUPER UGLY
127                 
128                 //
129                 // Whether to allow Unsafe code
130                 //
131                 public bool Unsafe;
132
133                 public string Win32ResourceFile;
134                 public string Win32IconFile;
135
136                 //
137                 // A list of resource files for embedding
138                 //
139                 public List<AssemblyResource> Resources;
140
141                 public bool GenerateDebugInfo;
142
143                 #region Compiler debug flags only
144                 public bool ParseOnly, TokenizeOnly, Timestamps;
145                 public int DebugFlags;
146                 public int VerboseParserFlag;
147                 public int FatalCounter;
148                 public bool Stacktrace;
149                 #endregion
150
151                 public bool ShowFullPaths;
152
153                 //
154                 // Whether we are being linked against the standard libraries.
155                 // This is only used to tell whether `System.Object' should
156                 // have a base class or not.
157                 //
158                 public bool StdLib;
159
160                 public RuntimeVersion StdLibRuntimeVersion;
161
162                 public bool WriteMetadataOnly;
163
164                 readonly List<string> conditional_symbols;
165
166                 readonly List<SourceFile> source_files;
167
168                 List<int> warnings_as_error;
169                 List<int> warnings_only;
170                 HashSet<int> warning_ignore_table;
171
172                 public CompilerSettings ()
173                 {
174                         StdLib = true;
175                         Target = Target.Exe;
176                         TargetExt = ".exe";
177                         Platform = Platform.AnyCPU;
178                         Version = LanguageVersion.Default;
179                         VerifyClsCompliance = true;
180                         Encoding = Encoding.UTF8;
181                         LoadDefaultReferences = true;
182                         StdLibRuntimeVersion = RuntimeVersion.v4;
183                         WarningLevel = 4;
184
185                         // Default to 1 or mdb files would be platform speficic
186                         TabSize = 1;
187
188                         AssemblyReferences = new List<string> ();
189                         AssemblyReferencesAliases = new List<Tuple<string, string>> ();
190                         Modules = new List<string> ();
191                         ReferencesLookupPaths = new List<string> ();
192
193                         conditional_symbols = new List<string> ();
194                         //
195                         // Add default mcs define
196                         //
197                         conditional_symbols.Add ("__MonoCS__");
198
199                         source_files = new List<SourceFile> ();
200                 }
201
202                 #region Properties
203
204                 public SourceFile FirstSourceFile {
205                         get {
206                                 return source_files.Count > 0 ? source_files [0] : null;
207                         }
208                 }
209
210                 public bool HasKeyFileOrContainer {
211                         get {
212                                 return StrongNameKeyFile != null || StrongNameKeyContainer != null;
213                         }
214                 }
215
216                 public bool NeedsEntryPoint {
217                         get {
218                                 return Target == Target.Exe || Target == Target.WinExe;
219                         }
220                 }
221
222                 public List<SourceFile> SourceFiles {
223                         get {
224                                 return source_files;
225                         }
226                 }
227
228                 #endregion
229
230                 public void AddConditionalSymbol (string symbol)
231                 {
232                         if (!conditional_symbols.Contains (symbol))
233                                 conditional_symbols.Add (symbol);
234                 }
235
236                 public void AddWarningAsError (int id)
237                 {
238                         if (warnings_as_error == null)
239                                 warnings_as_error = new List<int> ();
240
241                         warnings_as_error.Add (id);
242                 }
243
244                 public void AddWarningOnly (int id)
245                 {
246                         if (warnings_only == null)
247                                 warnings_only = new List<int> ();
248
249                         warnings_only.Add (id);
250                 }
251
252                 public bool IsConditionalSymbolDefined (string symbol)
253                 {
254                         return conditional_symbols.Contains (symbol);
255                 }
256
257                 public bool IsWarningAsError (int code)
258                 {
259                         bool is_error = WarningsAreErrors;
260
261                         // Check specific list
262                         if (warnings_as_error != null)
263                                 is_error |= warnings_as_error.Contains (code);
264
265                         // Ignore excluded warnings
266                         if (warnings_only != null && warnings_only.Contains (code))
267                                 is_error = false;
268
269                         return is_error;
270                 }
271
272                 public bool IsWarningEnabled (int code, int level)
273                 {
274                         if (WarningLevel < level)
275                                 return false;
276
277                         return !IsWarningDisabledGlobally (code);
278                 }
279
280                 public bool IsWarningDisabledGlobally (int code)
281                 {
282                         return warning_ignore_table != null && warning_ignore_table.Contains (code);
283                 }
284
285                 public void SetIgnoreWarning (int code)
286                 {
287                         if (warning_ignore_table == null)
288                                 warning_ignore_table = new HashSet<int> ();
289
290                         warning_ignore_table.Add (code);
291                 }
292         }
293
294         public class CommandLineParser
295         {
296                 enum ParseResult
297                 {
298                         Success,
299                         Error,
300                         Stop,
301                         UnknownOption
302                 }
303
304                 static readonly char[] argument_value_separator = { ';', ',' };
305                 static readonly char[] numeric_value_separator = { ';', ',', ' ' };
306
307                 readonly TextWriter output;
308                 readonly Report report;
309                 bool stop_argument;
310
311                 Dictionary<string, int> source_file_index;
312
313                 public event Func<string[], int, int> UnknownOptionHandler;
314
315                 CompilerSettings parser_settings;
316
317                 public CommandLineParser (TextWriter errorOutput)
318                         : this (errorOutput, Console.Out)
319                 {
320                 }
321
322                 public CommandLineParser (TextWriter errorOutput, TextWriter messagesOutput)
323                 {
324                         var rp = new StreamReportPrinter (errorOutput);
325
326                         parser_settings = new CompilerSettings ();
327                         report = new Report (new CompilerContext (parser_settings, rp), rp);
328                         this.output = messagesOutput;
329                 }
330
331                 public bool HasBeenStopped {
332                         get {
333                                 return stop_argument;
334                         }
335                 }
336
337                 void About ()
338                 {
339                         output.WriteLine (
340                                 "The Mono C# compiler is Copyright 2001-2011, Novell, Inc.\n\n" +
341                                 "The compiler source code is released under the terms of the \n" +
342                                 "MIT X11 or GNU GPL licenses\n\n" +
343
344                                 "For more information on Mono, visit the project Web site\n" +
345                                 "   http://www.mono-project.com\n\n" +
346
347                                 "The compiler was written by Miguel de Icaza, Ravi Pratap, Martin Baulig, Marek Safar, Raja R Harinath, Atushi Enomoto");
348                 }
349
350                 public CompilerSettings ParseArguments (string[] args)
351                 {
352                         CompilerSettings settings = new CompilerSettings ();
353                         if (!ParseArguments (settings, args))
354                                 return null;
355
356                         return settings;
357                 }
358
359                 public bool ParseArguments (CompilerSettings settings, string[] args)
360                 {
361                         if (settings == null)
362                                 throw new ArgumentNullException ("settings");
363
364                         List<string> response_file_list = null;
365                         bool parsing_options = true;
366                         stop_argument = false;
367                         source_file_index = new Dictionary<string, int> ();
368
369                         for (int i = 0; i < args.Length; i++) {
370                                 string arg = args[i];
371                                 if (arg.Length == 0)
372                                         continue;
373
374                                 if (arg[0] == '@') {
375                                         string[] extra_args;
376                                         string response_file = arg.Substring (1);
377
378                                         if (response_file_list == null)
379                                                 response_file_list = new List<string> ();
380
381                                         if (response_file_list.Contains (response_file)) {
382                                                 report.Error (1515, "Response file `{0}' specified multiple times", response_file);
383                                                 return false;
384                                         }
385
386                                         response_file_list.Add (response_file);
387
388                                         extra_args = LoadArgs (response_file);
389                                         if (extra_args == null) {
390                                                 report.Error (2011, "Unable to open response file: " + response_file);
391                                                 return false;
392                                         }
393
394                                         args = AddArgs (args, extra_args);
395                                         continue;
396                                 }
397
398                                 if (parsing_options) {
399                                         if (arg == "--") {
400                                                 parsing_options = false;
401                                                 continue;
402                                         }
403
404                                         bool dash_opt = arg[0] == '-';
405                                         bool slash_opt = arg[0] == '/';
406                                         if (dash_opt) {
407                                                 switch (ParseOptionUnix (arg, ref args, ref i, settings)) {
408                                                 case ParseResult.Error:
409                                                 case ParseResult.Success:
410                                                         continue;
411                                                 case ParseResult.Stop:
412                                                         stop_argument = true;
413                                                         return true;
414                                                 case ParseResult.UnknownOption:
415                                                         if (UnknownOptionHandler != null) {
416                                                                 var ret = UnknownOptionHandler (args, i);
417                                                                 if (ret != -1) {
418                                                                         i = ret;
419                                                                         continue;
420                                                                 }
421                                                         }
422                                                         break;
423                                                 }
424                                         }
425
426                                         if (dash_opt || slash_opt) {
427                                                 // Try a -CSCOPTION
428                                                 string csc_opt = dash_opt ? "/" + arg.Substring (1) : arg;
429                                                 switch (ParseOption (csc_opt, ref args, settings)) {
430                                                 case ParseResult.Error:
431                                                 case ParseResult.Success:
432                                                         continue;
433                                                 case ParseResult.UnknownOption:
434                                                         // Need to skip `/home/test.cs' however /test.cs is considered as error
435                                                         if ((slash_opt && arg.Length > 3 && arg.IndexOf ('/', 2) > 0))
436                                                                 break;
437
438                                                         if (UnknownOptionHandler != null) {
439                                                                 var ret = UnknownOptionHandler (args, i);
440                                                                 if (ret != -1) {
441                                                                         i = ret;
442                                                                         continue;
443                                                                 }
444                                                         }
445
446                                                         Error_WrongOption (arg);
447                                                         return false;
448
449                                                 case ParseResult.Stop:
450                                                         stop_argument = true;
451                                                         return true;
452                                                 }
453                                         }
454                                 }
455
456                                 ProcessSourceFiles (arg, false, settings.SourceFiles);
457                         }
458
459                         return report.Errors == 0;
460                 }
461
462                 void ProcessSourceFiles (string spec, bool recurse, List<SourceFile> sourceFiles)
463                 {
464                         string path, pattern;
465
466                         SplitPathAndPattern (spec, out path, out pattern);
467                         if (pattern.IndexOf ('*') == -1) {
468                                 AddSourceFile (spec, sourceFiles);
469                                 return;
470                         }
471
472                         string[] files;
473                         try {
474                                 files = Directory.GetFiles (path, pattern);
475                         } catch (System.IO.DirectoryNotFoundException) {
476                                 report.Error (2001, "Source file `" + spec + "' could not be found");
477                                 return;
478                         } catch (System.IO.IOException) {
479                                 report.Error (2001, "Source file `" + spec + "' could not be found");
480                                 return;
481                         }
482                         foreach (string f in files) {
483                                 AddSourceFile (f, sourceFiles);
484                         }
485
486                         if (!recurse)
487                                 return;
488
489                         string[] dirs = null;
490
491                         try {
492                                 dirs = Directory.GetDirectories (path);
493                         } catch {
494                         }
495
496                         foreach (string d in dirs) {
497
498                                 // Don't include path in this string, as each
499                                 // directory entry already does
500                                 ProcessSourceFiles (d + "/" + pattern, true, sourceFiles);
501                         }
502                 }
503
504                 static string[] AddArgs (string[] args, string[] extra_args)
505                 {
506                         string[] new_args;
507                         new_args = new string[extra_args.Length + args.Length];
508
509                         // if args contains '--' we have to take that into account
510                         // split args into first half and second half based on '--'
511                         // and add the extra_args before --
512                         int split_position = Array.IndexOf (args, "--");
513                         if (split_position != -1) {
514                                 Array.Copy (args, new_args, split_position);
515                                 extra_args.CopyTo (new_args, split_position);
516                                 Array.Copy (args, split_position, new_args, split_position + extra_args.Length, args.Length - split_position);
517                         } else {
518                                 args.CopyTo (new_args, 0);
519                                 extra_args.CopyTo (new_args, args.Length);
520                         }
521
522                         return new_args;
523                 }
524
525                 void AddAssemblyReference (string alias, string assembly, CompilerSettings settings)
526                 {
527                         if (assembly.Length == 0) {
528                                 report.Error (1680, "Invalid reference alias `{0}='. Missing filename", alias);
529                                 return;
530                         }
531
532                         if (!IsExternAliasValid (alias)) {
533                                 report.Error (1679, "Invalid extern alias for -reference. Alias `{0}' is not a valid identifier", alias);
534                                 return;
535                         }
536
537                         settings.AssemblyReferencesAliases.Add (Tuple.Create (alias, assembly));
538                 }
539
540                 void AddResource (AssemblyResource res, CompilerSettings settings)
541                 {
542                         if (settings.Resources == null) {
543                                 settings.Resources = new List<AssemblyResource> ();
544                                 settings.Resources.Add (res);
545                                 return;
546                         }
547
548                         if (settings.Resources.Contains (res)) {
549                                 report.Error (1508, "The resource identifier `{0}' has already been used in this assembly", res.Name);
550                                 return;
551                         }
552
553                         settings.Resources.Add (res);
554                 }
555
556                 void AddSourceFile (string fileName, List<SourceFile> sourceFiles)
557                 {
558                         string path = Path.GetFullPath (fileName);
559
560                         int index;
561                         if (source_file_index.TryGetValue (path, out index)) {
562                                 string other_name = sourceFiles[index - 1].Name;
563                                 if (fileName.Equals (other_name))
564                                         report.Warning (2002, 1, "Source file `{0}' specified multiple times", other_name);
565                                 else
566                                         report.Warning (2002, 1, "Source filenames `{0}' and `{1}' both refer to the same file: {2}", fileName, other_name, path);
567
568                                 return;
569                         }
570
571                         var unit = new SourceFile (fileName, path, sourceFiles.Count + 1);
572                         sourceFiles.Add (unit);
573                         source_file_index.Add (path, unit.Index);
574                 }
575
576                 public bool ProcessWarningsList (string text, Action<int> action)
577                 {
578                         bool valid = true;
579                         foreach (string wid in text.Split (numeric_value_separator, StringSplitOptions.RemoveEmptyEntries)) {
580                                 int id;
581                                 if (!int.TryParse (wid, NumberStyles.AllowLeadingWhite, CultureInfo.InvariantCulture, out id)) {
582                                         report.Error (1904, "`{0}' is not a valid warning number", wid);
583                                         valid = false;
584                                         continue;
585                                 }
586
587                                 if (report.CheckWarningCode (id, Location.Null))
588                                         action (id);
589                         }
590
591                         return valid;
592                 }
593
594                 void Error_RequiresArgument (string option)
595                 {
596                         report.Error (2006, "Missing argument for `{0}' option", option);
597                 }
598
599                 void Error_RequiresFileName (string option)
600                 {
601                         report.Error (2005, "Missing file specification for `{0}' option", option);
602                 }
603
604                 void Error_WrongOption (string option)
605                 {
606                         report.Error (2007, "Unrecognized command-line option: `{0}'", option);
607                 }
608
609                 static bool IsExternAliasValid (string identifier)
610                 {
611                         return Tokenizer.IsValidIdentifier (identifier);
612                 }
613
614                 static string[] LoadArgs (string file)
615                 {
616                         StreamReader f;
617                         var args = new List<string> ();
618                         string line;
619                         try {
620                                 f = new StreamReader (file);
621                         } catch {
622                                 return null;
623                         }
624
625                         StringBuilder sb = new StringBuilder ();
626
627                         while ((line = f.ReadLine ()) != null) {
628                                 int t = line.Length;
629
630                                 for (int i = 0; i < t; i++) {
631                                         char c = line[i];
632
633                                         if (c == '"' || c == '\'') {
634                                                 char end = c;
635
636                                                 for (i++; i < t; i++) {
637                                                         c = line[i];
638
639                                                         if (c == end)
640                                                                 break;
641                                                         sb.Append (c);
642                                                 }
643                                         } else if (c == ' ') {
644                                                 if (sb.Length > 0) {
645                                                         args.Add (sb.ToString ());
646                                                         sb.Length = 0;
647                                                 }
648                                         } else
649                                                 sb.Append (c);
650                                 }
651                                 if (sb.Length > 0) {
652                                         args.Add (sb.ToString ());
653                                         sb.Length = 0;
654                                 }
655                         }
656
657                         return args.ToArray ();
658                 }
659
660                 void OtherFlags ()
661                 {
662                         output.WriteLine (
663                                 "Other flags in the compiler\n" +
664                                 "   --fatal[=COUNT]    Makes error after COUNT fatal\n" +
665                                 "   --lint             Enhanced warnings\n" +
666                                 "   --metadata-only    Produced assembly will contain metadata only\n" +
667                                 "   --parse            Only parses the source file\n" +
668                                 "   --runtime:VERSION  Sets mscorlib.dll metadata version: v1, v2, v4\n" +
669                                 "   --stacktrace       Shows stack trace at error location\n" +
670                                 "   --timestamp        Displays time stamps of various compiler events\n" +
671                                 "   -v                 Verbose parsing (for debugging the parser)\n" +
672                                 "   --mcs-debug X      Sets MCS debugging level to X\n");
673                 }
674
675                 //
676                 // This parses the -arg and /arg options to the compiler, even if the strings
677                 // in the following text use "/arg" on the strings.
678                 //
679                 ParseResult ParseOption (string option, ref string[] args, CompilerSettings settings)
680                 {
681                         int idx = option.IndexOf (':');
682                         string arg, value;
683
684                         if (idx == -1) {
685                                 arg = option;
686                                 value = "";
687                         } else {
688                                 arg = option.Substring (0, idx);
689
690                                 value = option.Substring (idx + 1);
691                         }
692
693                         switch (arg.ToLowerInvariant ()) {
694                         case "/nologo":
695                                 return ParseResult.Success;
696
697                         case "/t":
698                         case "/target":
699                                 switch (value) {
700                                 case "exe":
701                                         settings.Target = Target.Exe;
702                                         break;
703
704                                 case "winexe":
705                                         settings.Target = Target.WinExe;
706                                         break;
707
708                                 case "library":
709                                         settings.Target = Target.Library;
710                                         settings.TargetExt = ".dll";
711                                         break;
712
713                                 case "module":
714                                         settings.Target = Target.Module;
715                                         settings.TargetExt = ".netmodule";
716                                         break;
717
718                                 default:
719                                         report.Error (2019, "Invalid target type for -target. Valid options are `exe', `winexe', `library' or `module'");
720                                         return ParseResult.Error;
721                                 }
722                                 return ParseResult.Success;
723
724                         case "/out":
725                                 if (value.Length == 0) {
726                                         Error_RequiresFileName (option);
727                                         return ParseResult.Error;
728                                 }
729                                 settings.OutputFile = value;
730                                 return ParseResult.Success;
731
732                         case "/o":
733                         case "/o+":
734                         case "/optimize":
735                         case "/optimize+":
736                                 settings.Optimize = true;
737                                 return ParseResult.Success;
738
739                         case "/o-":
740                         case "/optimize-":
741                                 settings.Optimize = false;
742                                 return ParseResult.Success;
743
744                         // TODO: Not supported by csc 3.5+
745                         case "/incremental":
746                         case "/incremental+":
747                         case "/incremental-":
748                                 // nothing.
749                                 return ParseResult.Success;
750
751                         case "/d":
752                         case "/define": {
753                                         if (value.Length == 0) {
754                                                 Error_RequiresArgument (option);
755                                                 return ParseResult.Error;
756                                         }
757
758                                         foreach (string d in value.Split (argument_value_separator)) {
759                                                 string conditional = d.Trim ();
760                                                 if (!Tokenizer.IsValidIdentifier (conditional)) {
761                                                         report.Warning (2029, 1, "Invalid conditional define symbol `{0}'", conditional);
762                                                         continue;
763                                                 }
764
765                                                 settings.AddConditionalSymbol (conditional);
766                                         }
767                                         return ParseResult.Success;
768                                 }
769
770                         case "/bugreport":
771                                 //
772                                 // We should collect data, runtime, etc and store in the file specified
773                                 //
774                                 output.WriteLine ("To file bug reports, please visit: http://www.mono-project.com/Bugs");
775                                 return ParseResult.Success;
776
777                         case "/pkg": {
778                                         string packages;
779
780                                         if (value.Length == 0) {
781                                                 Error_RequiresArgument (option);
782                                                 return ParseResult.Error;
783                                         }
784                                         packages = String.Join (" ", value.Split (new Char[] { ';', ',', '\n', '\r' }));
785                                         string pkgout = Driver.GetPackageFlags (packages, report);
786
787                                         if (pkgout == null)
788                                                 return ParseResult.Error;
789
790                                         string[] xargs = pkgout.Trim (new Char[] { ' ', '\n', '\r', '\t' }).Split (new Char[] { ' ', '\t' });
791                                         args = AddArgs (args, xargs);
792                                         return ParseResult.Success;
793                                 }
794
795                         case "/linkres":
796                         case "/linkresource":
797                         case "/res":
798                         case "/resource":
799                                 AssemblyResource res = null;
800                                 string[] s = value.Split (argument_value_separator, StringSplitOptions.RemoveEmptyEntries);
801                                 switch (s.Length) {
802                                 case 1:
803                                         if (s[0].Length == 0)
804                                                 goto default;
805                                         res = new AssemblyResource (s[0], Path.GetFileName (s[0]));
806                                         break;
807                                 case 2:
808                                         res = new AssemblyResource (s[0], s[1]);
809                                         break;
810                                 case 3:
811                                         if (s[2] != "public" && s[2] != "private") {
812                                                 report.Error (1906, "Invalid resource visibility option `{0}'. Use either `public' or `private' instead", s[2]);
813                                                 return ParseResult.Error;
814                                         }
815                                         res = new AssemblyResource (s[0], s[1], s[2] == "private");
816                                         break;
817                                 default:
818                                         report.Error (-2005, "Wrong number of arguments for option `{0}'", option);
819                                         return ParseResult.Error;
820                                 }
821
822                                 if (res != null) {
823                                         res.IsEmbeded = arg[1] == 'r' || arg[1] == 'R';
824                                         AddResource (res, settings);
825                                 }
826
827                                 return ParseResult.Success;
828
829                         case "/recurse":
830                                 if (value.Length == 0) {
831                                         Error_RequiresFileName (option);
832                                         return ParseResult.Error;
833                                 }
834                                 ProcessSourceFiles (value, true, settings.SourceFiles);
835                                 return ParseResult.Success;
836
837                         case "/r":
838                         case "/reference": {
839                                         if (value.Length == 0) {
840                                                 Error_RequiresFileName (option);
841                                                 return ParseResult.Error;
842                                         }
843
844                                         string[] refs = value.Split (argument_value_separator);
845                                         foreach (string r in refs) {
846                                                 if (r.Length == 0)
847                                                         continue;
848
849                                                 string val = r;
850                                                 int index = val.IndexOf ('=');
851                                                 if (index > -1) {
852                                                         string alias = r.Substring (0, index);
853                                                         string assembly = r.Substring (index + 1);
854                                                         AddAssemblyReference (alias, assembly, settings);
855                                                         if (refs.Length != 1) {
856                                                                 report.Error (2034, "Cannot specify multiple aliases using single /reference option");
857                                                                 return ParseResult.Error;
858                                                         }
859                                                 } else {
860                                                         settings.AssemblyReferences.Add (val);
861                                                 }
862                                         }
863                                         return ParseResult.Success;
864                                 }
865                         case "/addmodule": {
866                                         if (value.Length == 0) {
867                                                 Error_RequiresFileName (option);
868                                                 return ParseResult.Error;
869                                         }
870
871                                         string[] refs = value.Split (argument_value_separator);
872                                         foreach (string r in refs) {
873                                                 settings.Modules.Add (r);
874                                         }
875                                         return ParseResult.Success;
876                                 }
877                         case "/win32res": {
878                                         if (value.Length == 0) {
879                                                 Error_RequiresFileName (option);
880                                                 return ParseResult.Error;
881                                         }
882
883                                         if (settings.Win32IconFile != null)
884                                                 report.Error (1565, "Cannot specify the `win32res' and the `win32ico' compiler option at the same time");
885
886                                         settings.Win32ResourceFile = value;
887                                         return ParseResult.Success;
888                                 }
889                         case "/win32icon": {
890                                         if (value.Length == 0) {
891                                                 Error_RequiresFileName (option);
892                                                 return ParseResult.Error;
893                                         }
894
895                                         if (settings.Win32ResourceFile != null)
896                                                 report.Error (1565, "Cannot specify the `win32res' and the `win32ico' compiler option at the same time");
897
898                                         settings.Win32IconFile = value;
899                                         return ParseResult.Success;
900                                 }
901                         case "/doc": {
902                                         if (value.Length == 0) {
903                                                 Error_RequiresFileName (option);
904                                                 return ParseResult.Error;
905                                         }
906
907                                         settings.DocumentationFile = value;
908                                         return ParseResult.Success;
909                                 }
910                         case "/lib": {
911                                         string[] libdirs;
912
913                                         if (value.Length == 0) {
914                                                 return ParseResult.Error;
915                                         }
916
917                                         libdirs = value.Split (argument_value_separator);
918                                         foreach (string dir in libdirs)
919                                                 settings.ReferencesLookupPaths.Add (dir);
920                                         return ParseResult.Success;
921                                 }
922
923                         case "/debug-":
924                                 settings.GenerateDebugInfo = false;
925                                 return ParseResult.Success;
926
927                         case "/debug":
928                                 if (value.Equals ("full", StringComparison.OrdinalIgnoreCase) || value.Equals ("pdbonly", StringComparison.OrdinalIgnoreCase) || idx < 0) {
929                                         settings.GenerateDebugInfo = true;
930                                         return ParseResult.Success;
931                                 }
932
933                                 if (value.Length > 0) {
934                                         report.Error (1902, "Invalid debug option `{0}'. Valid options are `full' or `pdbonly'", value);
935                                 } else {
936                                         Error_RequiresArgument (option);
937                                 }
938
939                                 return ParseResult.Error;
940
941                         case "/debug+":
942                                 settings.GenerateDebugInfo = true;
943                                 return ParseResult.Success;
944
945                         case "/checked":
946                         case "/checked+":
947                                 settings.Checked = true;
948                                 return ParseResult.Success;
949
950                         case "/checked-":
951                                 settings.Checked = false;
952                                 return ParseResult.Success;
953
954                         case "/clscheck":
955                         case "/clscheck+":
956                                 settings.VerifyClsCompliance = true;
957                                 return ParseResult.Success;
958
959                         case "/clscheck-":
960                                 settings.VerifyClsCompliance = false;
961                                 return ParseResult.Success;
962
963                         case "/unsafe":
964                         case "/unsafe+":
965                                 settings.Unsafe = true;
966                                 return ParseResult.Success;
967
968                         case "/unsafe-":
969                                 settings.Unsafe = false;
970                                 return ParseResult.Success;
971
972                         case "/warnaserror":
973                         case "/warnaserror+":
974                                 if (value.Length == 0) {
975                                         settings.WarningsAreErrors = true;
976                                         parser_settings.WarningsAreErrors = true;
977                                 } else {
978                                         if (!ProcessWarningsList (value, settings.AddWarningAsError))
979                                                 return ParseResult.Error;
980                                 }
981                                 return ParseResult.Success;
982
983                         case "/warnaserror-":
984                                 if (value.Length == 0) {
985                                         settings.WarningsAreErrors = false;
986                                 } else {
987                                         if (!ProcessWarningsList (value, settings.AddWarningOnly))
988                                                 return ParseResult.Error;
989                                 }
990                                 return ParseResult.Success;
991
992                         case "/warn":
993                         case "/w":
994                                 if (value.Length == 0) {
995                                         Error_RequiresArgument (option);
996                                         return ParseResult.Error;
997                                 }
998
999                                 SetWarningLevel (value, settings);
1000                                 return ParseResult.Success;
1001
1002                         case "/nowarn":
1003                                 if (value.Length == 0) {
1004                                         Error_RequiresArgument (option);
1005                                         return ParseResult.Error;
1006                                 }
1007
1008                                 if (!ProcessWarningsList (value, settings.SetIgnoreWarning))
1009                                         return ParseResult.Error;
1010
1011                                 return ParseResult.Success;
1012
1013                         case "/noconfig":
1014                                 settings.LoadDefaultReferences = false;
1015                                 return ParseResult.Success;
1016
1017                         case "/platform":
1018                                 if (value.Length == 0) {
1019                                         Error_RequiresArgument (option);
1020                                         return ParseResult.Error;
1021                                 }
1022
1023                                 switch (value.ToLowerInvariant ()) {
1024                                 case "arm":
1025                                         settings.Platform = Platform.Arm;
1026                                         break;
1027                                 case "anycpu":
1028                                         settings.Platform = Platform.AnyCPU;
1029                                         break;
1030                                 case "x86":
1031                                         settings.Platform = Platform.X86;
1032                                         break;
1033                                 case "x64":
1034                                         settings.Platform = Platform.X64;
1035                                         break;
1036                                 case "itanium":
1037                                         settings.Platform = Platform.IA64;
1038                                         break;
1039                                 case "anycpu32bitpreferred":
1040                                         settings.Platform = Platform.AnyCPU32Preferred;
1041                                         break;
1042                                 default:
1043                                         report.Error (1672, "Invalid -platform option `{0}'. Valid options are `anycpu', `anycpu32bitpreferred', `arm', `x86', `x64' or `itanium'",
1044                                                 value);
1045                                         return ParseResult.Error;
1046                                 }
1047
1048                                 return ParseResult.Success;
1049
1050                         case "/sdk":
1051                                 if (value.Length == 0) {
1052                                         Error_RequiresArgument (option);
1053                                         return ParseResult.Error;
1054                                 }
1055
1056                                 settings.SdkVersion = value;
1057                                 return ParseResult.Success;
1058
1059                         // We just ignore this.
1060                         case "/errorreport":
1061                         case "/filealign":
1062                                 if (value.Length == 0) {
1063                                         Error_RequiresArgument (option);
1064                                         return ParseResult.Error;
1065                                 }
1066
1067                                 return ParseResult.Success;
1068
1069                         case "/helpinternal":
1070                                 OtherFlags ();
1071                                 return ParseResult.Stop;
1072
1073                         case "/help":
1074                         case "/?":
1075                                 Usage ();
1076                                 return ParseResult.Stop;
1077
1078                         case "/main":
1079                         case "/m":
1080                                 if (value.Length == 0) {
1081                                         Error_RequiresArgument (option);
1082                                         return ParseResult.Error;
1083                                 }
1084                                 settings.MainClass = value;
1085                                 return ParseResult.Success;
1086
1087                         case "/nostdlib":
1088                         case "/nostdlib+":
1089                                 settings.StdLib = false;
1090                                 return ParseResult.Success;
1091
1092                         case "/nostdlib-":
1093                                 settings.StdLib = true;
1094                                 return ParseResult.Success;
1095
1096                         case "/fullpaths":
1097                                 settings.ShowFullPaths = true;
1098                                 return ParseResult.Success;
1099
1100                         case "/keyfile":
1101                                 if (value.Length == 0) {
1102                                         Error_RequiresFileName (option);
1103                                         return ParseResult.Error;
1104                                 }
1105
1106                                 settings.StrongNameKeyFile = value;
1107                                 return ParseResult.Success;
1108
1109                         case "/keycontainer":
1110                                 if (value.Length == 0) {
1111                                         Error_RequiresArgument (option);
1112                                         return ParseResult.Error;
1113                                 }
1114
1115                                 settings.StrongNameKeyContainer = value;
1116                                 return ParseResult.Success;
1117
1118                         case "/delaysign+":
1119                         case "/delaysign":
1120                                 settings.StrongNameDelaySign = true;
1121                                 return ParseResult.Success;
1122
1123                         case "/delaysign-":
1124                                 settings.StrongNameDelaySign = false;
1125                                 return ParseResult.Success;
1126
1127                         case "/langversion":
1128                                 if (value.Length == 0) {
1129                                         Error_RequiresArgument (option);
1130                                         return ParseResult.Error;
1131                                 }
1132
1133                                 switch (value.ToLowerInvariant ()) {
1134                                 case "iso-1":
1135                                         settings.Version = LanguageVersion.ISO_1;
1136                                         return ParseResult.Success;
1137                                 case "default":
1138                                         settings.Version = LanguageVersion.Default;
1139                                         return ParseResult.Success;
1140                                 case "iso-2":
1141                                         settings.Version = LanguageVersion.ISO_2;
1142                                         return ParseResult.Success;
1143                                 case "3":
1144                                         settings.Version = LanguageVersion.V_3;
1145                                         return ParseResult.Success;
1146                                 case "4":
1147                                         settings.Version = LanguageVersion.V_4;
1148                                         return ParseResult.Success;
1149                                 case "5":
1150                                         settings.Version = LanguageVersion.V_5;
1151                                         return ParseResult.Success;
1152                                 case "future":
1153                                         settings.Version = LanguageVersion.Future;
1154                                         return ParseResult.Success;
1155                                 }
1156
1157                                 report.Error (1617, "Invalid -langversion option `{0}'. It must be `ISO-1', `ISO-2', `3', `4', `5', `Default' or `Future'", value);
1158                                 return ParseResult.Error;
1159
1160                         case "/codepage":
1161                                 if (value.Length == 0) {
1162                                         Error_RequiresArgument (option);
1163                                         return ParseResult.Error;
1164                                 }
1165
1166                                 switch (value) {
1167                                 case "utf8":
1168                                         settings.Encoding = Encoding.UTF8;
1169                                         break;
1170                                 case "reset":
1171                                         settings.Encoding = Encoding.Default;
1172                                         break;
1173                                 default:
1174                                         try {
1175                                                 settings.Encoding = Encoding.GetEncoding (int.Parse (value));
1176                                         } catch {
1177                                                 report.Error (2016, "Code page `{0}' is invalid or not installed", value);
1178                                         }
1179                                         return ParseResult.Error;
1180                                 }
1181                                 return ParseResult.Success;
1182
1183                         default:
1184                                 return ParseResult.UnknownOption;
1185                         }
1186                 }
1187
1188                 //
1189                 // Currently handles the Unix-like command line options, but will be
1190                 // deprecated in favor of the CSCParseOption, which will also handle the
1191                 // options that start with a dash in the future.
1192                 //
1193                 ParseResult ParseOptionUnix (string arg, ref string[] args, ref int i, CompilerSettings settings)
1194                 {
1195                         switch (arg){
1196                         case "-v":
1197                                 settings.VerboseParserFlag++;
1198                                 return ParseResult.Success;
1199
1200                         case "--version":
1201                                 Version ();
1202                                 return ParseResult.Stop;
1203                                 
1204                         case "--parse":
1205                                 settings.ParseOnly = true;
1206                                 return ParseResult.Success;
1207                                 
1208                         case "--main": case "-m":
1209                                 report.Warning (-29, 1, "Compatibility: Use -main:CLASS instead of --main CLASS or -m CLASS");
1210                                 if ((i + 1) >= args.Length){
1211                                         Error_RequiresArgument (arg);
1212                                         return ParseResult.Error;
1213                                 }
1214                                 settings.MainClass = args[++i];
1215                                 return ParseResult.Success;
1216                                 
1217                         case "--unsafe":
1218                                 report.Warning (-29, 1, "Compatibility: Use -unsafe instead of --unsafe");
1219                                 settings.Unsafe = true;
1220                                 return ParseResult.Success;
1221                                 
1222                         case "/?": case "/h": case "/help":
1223                         case "--help":
1224                                 Usage ();
1225                                 return ParseResult.Stop;
1226
1227                         case "--define":
1228                                 report.Warning (-29, 1, "Compatibility: Use -d:SYMBOL instead of --define SYMBOL");
1229                                 if ((i + 1) >= args.Length){
1230                                         Error_RequiresArgument (arg);
1231                                         return ParseResult.Error;
1232                                 }
1233
1234                                 settings.AddConditionalSymbol (args [++i]);
1235                                 return ParseResult.Success;
1236
1237                         case "--tokenize":
1238                                 settings.TokenizeOnly = true;
1239                                 return ParseResult.Success;
1240                                 
1241                         case "-o": 
1242                         case "--output":
1243                                 report.Warning (-29, 1, "Compatibility: Use -out:FILE instead of --output FILE or -o FILE");
1244                                 if ((i + 1) >= args.Length){
1245                                         Error_RequiresArgument (arg);
1246                                         return ParseResult.Error;
1247                                 }
1248                                 settings.OutputFile = args[++i];
1249                                 return ParseResult.Success;
1250
1251                         case "--checked":
1252                                 report.Warning (-29, 1, "Compatibility: Use -checked instead of --checked");
1253                                 settings.Checked = true;
1254                                 return ParseResult.Success;
1255                                 
1256                         case "--stacktrace":
1257                                 settings.Stacktrace = true;
1258                                 return ParseResult.Success;
1259                                 
1260                         case "--linkresource":
1261                         case "--linkres":
1262                                 report.Warning (-29, 1, "Compatibility: Use -linkres:VALUE instead of --linkres VALUE");
1263                                 if ((i + 1) >= args.Length){
1264                                         Error_RequiresArgument (arg);
1265                                         return ParseResult.Error;
1266                                 }
1267
1268                                 AddResource (new AssemblyResource (args[++i], args[i]), settings);
1269                                 return ParseResult.Success;
1270                                 
1271                         case "--resource":
1272                         case "--res":
1273                                 report.Warning (-29, 1, "Compatibility: Use -res:VALUE instead of --res VALUE");
1274                                 if ((i + 1) >= args.Length){
1275                                         Error_RequiresArgument (arg);
1276                                         return ParseResult.Error;
1277                                 }
1278
1279                                 AddResource (new AssemblyResource (args[++i], args[i], true), settings);
1280                                 return ParseResult.Success;
1281                                 
1282                         case "--target":
1283                                 report.Warning (-29, 1, "Compatibility: Use -target:KIND instead of --target KIND");
1284                                 if ((i + 1) >= args.Length){
1285                                         Error_RequiresArgument (arg);
1286                                         return ParseResult.Error;
1287                                 }
1288                                 
1289                                 string type = args [++i];
1290                                 switch (type){
1291                                 case "library":
1292                                         settings.Target = Target.Library;
1293                                         settings.TargetExt = ".dll";
1294                                         break;
1295                                         
1296                                 case "exe":
1297                                         settings.Target = Target.Exe;
1298                                         break;
1299                                         
1300                                 case "winexe":
1301                                         settings.Target = Target.WinExe;
1302                                         break;
1303                                         
1304                                 case "module":
1305                                         settings.Target = Target.Module;
1306                                         settings.TargetExt = ".dll";
1307                                         break;
1308                                 default:
1309                                         report.Error (2019, "Invalid target type for -target. Valid options are `exe', `winexe', `library' or `module'");
1310                                         break;
1311                                 }
1312                                 return ParseResult.Success;
1313                                 
1314                         case "-r":
1315                                 report.Warning (-29, 1, "Compatibility: Use -r:LIBRARY instead of -r library");
1316                                 if ((i + 1) >= args.Length){
1317                                         Error_RequiresArgument (arg);
1318                                         return ParseResult.Error;
1319                                 }
1320                                 
1321                                 string val = args [++i];
1322                                 int idx = val.IndexOf ('=');
1323                                 if (idx > -1) {
1324                                         string alias = val.Substring (0, idx);
1325                                         string assembly = val.Substring (idx + 1);
1326                                         AddAssemblyReference (alias, assembly, settings);
1327                                         return ParseResult.Success;
1328                                 }
1329
1330                                 settings.AssemblyReferences.Add (val);
1331                                 return ParseResult.Success;
1332                                 
1333                         case "-L":
1334                                 report.Warning (-29, 1, "Compatibility: Use -lib:ARG instead of --L arg");
1335                                 if ((i + 1) >= args.Length){
1336                                         Error_RequiresArgument (arg);
1337                                         return ParseResult.Error;
1338                                 }
1339                                 settings.ReferencesLookupPaths.Add (args [++i]);
1340                                 return ParseResult.Success;
1341
1342                         case "--lint":
1343                                 settings.EnhancedWarnings = true;
1344                                 return ParseResult.Success;
1345                                 
1346                         case "--nostdlib":
1347                                 report.Warning (-29, 1, "Compatibility: Use -nostdlib instead of --nostdlib");
1348                                 settings.StdLib = false;
1349                                 return ParseResult.Success;
1350                                 
1351                         case "--nowarn":
1352                                 report.Warning (-29, 1, "Compatibility: Use -nowarn instead of --nowarn");
1353                                 if ((i + 1) >= args.Length){
1354                                         Error_RequiresArgument (arg);
1355                                         return ParseResult.Error;
1356                                 }
1357                                 int warn = 0;
1358                                 
1359                                 try {
1360                                         warn = int.Parse (args [++i]);
1361                                 } catch {
1362                                         Usage ();
1363                                         Environment.Exit (1);
1364                                 }
1365                                 settings.SetIgnoreWarning (warn);
1366                                 return ParseResult.Success;
1367
1368                         case "--wlevel":
1369                                 report.Warning (-29, 1, "Compatibility: Use -warn:LEVEL instead of --wlevel LEVEL");
1370                                 if ((i + 1) >= args.Length){
1371                                         Error_RequiresArgument (arg);
1372                                         return ParseResult.Error;
1373                                 }
1374
1375                                 SetWarningLevel (args [++i], settings);
1376                                 return ParseResult.Success;
1377
1378                         case "--mcs-debug":
1379                                 if ((i + 1) >= args.Length){
1380                                         Error_RequiresArgument (arg);
1381                                         return ParseResult.Error;
1382                                 }
1383
1384                                 try {
1385                                         settings.DebugFlags = int.Parse (args [++i]);
1386                                 } catch {
1387                                         Error_RequiresArgument (arg);
1388                                         return ParseResult.Error;
1389                                 }
1390
1391                                 return ParseResult.Success;
1392                                 
1393                         case "--about":
1394                                 About ();
1395                                 return ParseResult.Stop;
1396                                 
1397                         case "--recurse":
1398                                 report.Warning (-29, 1, "Compatibility: Use -recurse:PATTERN option instead --recurse PATTERN");
1399                                 if ((i + 1) >= args.Length){
1400                                         Error_RequiresArgument (arg);
1401                                         return ParseResult.Error;
1402                                 }
1403                                 ProcessSourceFiles (args [++i], true, settings.SourceFiles);
1404                                 return ParseResult.Success;
1405                                 
1406                         case "--timestamp":
1407                                 settings.Timestamps = true;
1408                                 return ParseResult.Success;
1409
1410                         case "--debug": case "-g":
1411                                 report.Warning (-29, 1, "Compatibility: Use -debug option instead of -g or --debug");
1412                                 settings.GenerateDebugInfo = true;
1413                                 return ParseResult.Success;
1414                                 
1415                         case "--noconfig":
1416                                 report.Warning (-29, 1, "Compatibility: Use -noconfig option instead of --noconfig");
1417                                 settings.LoadDefaultReferences = false;
1418                                 return ParseResult.Success;
1419
1420                         case "--metadata-only":
1421                                 settings.WriteMetadataOnly = true;
1422                                 return ParseResult.Success;
1423
1424                         default:
1425                                 if (arg.StartsWith ("--fatal", StringComparison.Ordinal)){
1426                                         int fatal = 1;
1427                                         if (arg.StartsWith ("--fatal=", StringComparison.Ordinal))
1428                                                 int.TryParse (arg.Substring (8), out fatal);
1429
1430                                         settings.FatalCounter = fatal;
1431                                         return ParseResult.Success;
1432                                 }
1433                                 if (arg.StartsWith ("--runtime:", StringComparison.Ordinal)) {
1434                                         string version = arg.Substring (10);
1435
1436                                         switch (version) {
1437                                         case "v1":
1438                                         case "V1":
1439                                                 settings.StdLibRuntimeVersion = RuntimeVersion.v1;
1440                                                 break;
1441                                         case "v2":
1442                                         case "V2":
1443                                                 settings.StdLibRuntimeVersion = RuntimeVersion.v2;
1444                                                 break;
1445                                         case "v4":
1446                                         case "V4":
1447                                                 settings.StdLibRuntimeVersion = RuntimeVersion.v4;
1448                                                 break;
1449                                         }
1450                                         return ParseResult.Success;
1451                                 }
1452
1453                                 return ParseResult.UnknownOption;
1454                         }
1455                 }
1456
1457                 void SetWarningLevel (string s, CompilerSettings settings)
1458                 {
1459                         int level = -1;
1460
1461                         try {
1462                                 level = int.Parse (s);
1463                         } catch {
1464                         }
1465                         if (level < 0 || level > 4) {
1466                                 report.Error (1900, "Warning level must be in the range 0-4");
1467                                 return;
1468                         }
1469                         settings.WarningLevel = level;
1470                 }
1471
1472                 //
1473                 // Given a path specification, splits the path from the file/pattern
1474                 //
1475                 static void SplitPathAndPattern (string spec, out string path, out string pattern)
1476                 {
1477                         int p = spec.LastIndexOf ('/');
1478                         if (p != -1) {
1479                                 //
1480                                 // Windows does not like /file.cs, switch that to:
1481                                 // "\", "file.cs"
1482                                 //
1483                                 if (p == 0) {
1484                                         path = "\\";
1485                                         pattern = spec.Substring (1);
1486                                 } else {
1487                                         path = spec.Substring (0, p);
1488                                         pattern = spec.Substring (p + 1);
1489                                 }
1490                                 return;
1491                         }
1492
1493                         p = spec.LastIndexOf ('\\');
1494                         if (p != -1) {
1495                                 path = spec.Substring (0, p);
1496                                 pattern = spec.Substring (p + 1);
1497                                 return;
1498                         }
1499
1500                         path = ".";
1501                         pattern = spec;
1502                 }
1503
1504                 void Usage ()
1505                 {
1506                         output.WriteLine (
1507                                 "Mono C# compiler, Copyright 2001-2011 Novell, Inc., Copyright 2011-2012 Xamarin, Inc\n" +
1508                                 "mcs [options] source-files\n" +
1509                                 "   --about              About the Mono C# compiler\n" +
1510                                 "   -addmodule:M1[,Mn]   Adds the module to the generated assembly\n" +
1511                                 "   -checked[+|-]        Sets default aritmetic overflow context\n" +
1512                                 "   -clscheck[+|-]       Disables CLS Compliance verifications\n" +
1513                                 "   -codepage:ID         Sets code page to the one in ID (number, utf8, reset)\n" +
1514                                 "   -define:S1[;S2]      Defines one or more conditional symbols (short: -d)\n" +
1515                                 "   -debug[+|-], -g      Generate debugging information\n" +
1516                                 "   -delaysign[+|-]      Only insert the public key into the assembly (no signing)\n" +
1517                                 "   -doc:FILE            Process documentation comments to XML file\n" +
1518                                 "   -fullpaths           Any issued error or warning uses absolute file path\n" +
1519                                 "   -help                Lists all compiler options (short: -?)\n" +
1520                                 "   -keycontainer:NAME   The key pair container used to sign the output assembly\n" +
1521                                 "   -keyfile:FILE        The key file used to strongname the ouput assembly\n" +
1522                                 "   -langversion:TEXT    Specifies language version: ISO-1, ISO-2, 3, 4, 5, Default or Future\n" +
1523                                 "   -lib:PATH1[,PATHn]   Specifies the location of referenced assemblies\n" +
1524                                 "   -main:CLASS          Specifies the class with the Main method (short: -m)\n" +
1525                                 "   -noconfig            Disables implicitly referenced assemblies\n" +
1526                                 "   -nostdlib[+|-]       Does not reference mscorlib.dll library\n" +
1527                                 "   -nowarn:W1[,Wn]      Suppress one or more compiler warnings\n" +
1528                                 "   -optimize[+|-]       Enables advanced compiler optimizations (short: -o)\n" +
1529                                 "   -out:FILE            Specifies output assembly name\n" +
1530                                 "   -pkg:P1[,Pn]         References packages P1..Pn\n" +
1531                                 "   -platform:ARCH       Specifies the target platform of the output assembly\n" +
1532                                 "                        ARCH can be one of: anycpu, anycpu32bitpreferred, arm,\n" +
1533                                 "                        x86, x64 or itanium. The default is anycpu.\n" +
1534                                 "   -recurse:SPEC        Recursively compiles files according to SPEC pattern\n" +
1535                                 "   -reference:A1[,An]   Imports metadata from the specified assembly (short: -r)\n" +
1536                                 "   -reference:ALIAS=A   Imports metadata using specified extern alias (short: -r)\n" +
1537                                 "   -sdk:VERSION         Specifies SDK version of referenced assemblies\n" +
1538                                 "                        VERSION can be one of: 2, 4, 4.5 (default) or a custom value\n" +
1539                                 "   -target:KIND         Specifies the format of the output assembly (short: -t)\n" +
1540                                 "                        KIND can be one of: exe, winexe, library, module\n" +
1541                                 "   -unsafe[+|-]         Allows to compile code which uses unsafe keyword\n" +
1542                                 "   -warnaserror[+|-]    Treats all warnings as errors\n" +
1543                                 "   -warnaserror[+|-]:W1[,Wn] Treats one or more compiler warnings as errors\n" +
1544                                 "   -warn:0-4            Sets warning level, the default is 4 (short -w:)\n" +
1545                                 "   -helpinternal        Shows internal and advanced compiler options\n" +
1546                                 "\n" +
1547                                 "Resources:\n" +
1548                                 "   -linkresource:FILE[,ID] Links FILE as a resource (short: -linkres)\n" +
1549                                 "   -resource:FILE[,ID]     Embed FILE as a resource (short: -res)\n" +
1550                                 "   -win32res:FILE          Specifies Win32 resource file (.res)\n" +
1551                                 "   -win32icon:FILE         Use this icon for the output\n" +
1552                                                                 "   @file                   Read response file for more options\n\n" +
1553                                 "Options can be of the form -option or /option");
1554                 }
1555
1556                 void Version ()
1557                 {
1558                         string version = System.Reflection.MethodBase.GetCurrentMethod ().DeclaringType.Assembly.GetName ().Version.ToString ();
1559                         output.WriteLine ("Mono C# compiler version {0}", version);
1560                 }
1561         }
1562
1563         public class RootContext
1564         {
1565                 //
1566                 // Contains the parsed tree
1567                 //
1568                 static ModuleContainer root;
1569
1570                 static public ModuleContainer ToplevelTypes {
1571                         get { return root; }
1572                         set { root = value; }
1573                 }
1574         }
1575 }