Fixed string null constant conversion to object constant
[mono.git] / mcs / mcs / settings.cs
index 5c5a34b9ed39df581f3ed77368e3d23da6d43828..fa15cad9be6fad207d5bc87ea52262bbc92dc2fe 100644 (file)
@@ -159,6 +159,8 @@ namespace Mono.CSharp {
 
                public RuntimeVersion StdLibRuntimeVersion;
 
+               public bool WriteMetadataOnly;
+
                readonly List<string> conditional_symbols;
 
                readonly List<SourceFile> source_files;
@@ -180,10 +182,8 @@ namespace Mono.CSharp {
                        StdLibRuntimeVersion = RuntimeVersion.v4;
                        WarningLevel = 4;
 
-                       if (Environment.OSVersion.Platform == PlatformID.Win32NT)
-                               TabSize = 4;
-                       else
-                               TabSize = 8;
+                       // Default to 1 or mdb files would be platform speficic
+                       TabSize = 1;
 
                        AssemblyReferences = new List<string> ();
                        AssemblyReferencesAliases = new List<Tuple<string, string>> ();
@@ -350,6 +350,17 @@ namespace Mono.CSharp {
                public CompilerSettings ParseArguments (string[] args)
                {
                        CompilerSettings settings = new CompilerSettings ();
+                       if (!ParseArguments (settings, args))
+                               return null;
+
+                       return settings;
+               }
+
+               public bool ParseArguments (CompilerSettings settings, string[] args)
+               {
+                       if (settings == null)
+                               throw new ArgumentNullException ("settings");
+
                        List<string> response_file_list = null;
                        bool parsing_options = true;
                        stop_argument = false;
@@ -369,7 +380,7 @@ namespace Mono.CSharp {
 
                                        if (response_file_list.Contains (response_file)) {
                                                report.Error (1515, "Response file `{0}' specified multiple times", response_file);
-                                               return null;
+                                               return false;
                                        }
 
                                        response_file_list.Add (response_file);
@@ -377,7 +388,7 @@ namespace Mono.CSharp {
                                        extra_args = LoadArgs (response_file);
                                        if (extra_args == null) {
                                                report.Error (2011, "Unable to open response file: " + response_file);
-                                               return null;
+                                               return false;
                                        }
 
                                        args = AddArgs (args, extra_args);
@@ -399,7 +410,7 @@ namespace Mono.CSharp {
                                                        continue;
                                                case ParseResult.Stop:
                                                        stop_argument = true;
-                                                       return settings;
+                                                       return true;
                                                case ParseResult.UnknownOption:
                                                        if (UnknownOptionHandler != null) {
                                                                var ret = UnknownOptionHandler (args, i);
@@ -433,11 +444,11 @@ namespace Mono.CSharp {
                                                        }
 
                                                        Error_WrongOption (arg);
-                                                       return null;
+                                                       return false;
 
                                                case ParseResult.Stop:
                                                        stop_argument = true;
-                                                       return settings;
+                                                       return true;
                                                }
                                        }
                                }
@@ -445,10 +456,7 @@ namespace Mono.CSharp {
                                ProcessSourceFiles (arg, false, settings.SourceFiles);
                        }
 
-                       if (report.Errors > 0)
-                               return null;
-
-                       return settings;
+                       return report.Errors == 0;
                }
 
                void ProcessSourceFiles (string spec, bool recurse, List<SourceFile> sourceFiles)
@@ -600,24 +608,7 @@ namespace Mono.CSharp {
 
                static bool IsExternAliasValid (string identifier)
                {
-                       if (identifier.Length == 0)
-                               return false;
-                       if (identifier[0] != '_' && !char.IsLetter (identifier[0]))
-                               return false;
-
-                       for (int i = 1; i < identifier.Length; i++) {
-                               char c = identifier[i];
-                               if (char.IsLetter (c) || char.IsDigit (c))
-                                       continue;
-
-                               UnicodeCategory category = char.GetUnicodeCategory (c);
-                               if (category != UnicodeCategory.Format || category != UnicodeCategory.NonSpacingMark ||
-                                               category != UnicodeCategory.SpacingCombiningMark ||
-                                               category != UnicodeCategory.ConnectorPunctuation)
-                                       return false;
-                       }
-
-                       return true;
+                       return Tokenizer.IsValidIdentifier (identifier);
                }
 
                static string[] LoadArgs (string file)
@@ -670,8 +661,9 @@ namespace Mono.CSharp {
                {
                        output.WriteLine (
                                "Other flags in the compiler\n" +
-                               "   --fatal[=COUNT]    Makes errors after COUNT fatal\n" +
+                               "   --fatal[=COUNT]    Makes error after COUNT fatal\n" +
                                "   --lint             Enhanced warnings\n" +
+                               "   --metadata-only    Produced assembly will contain metadata only\n" +
                                "   --parse            Only parses the source file\n" +
                                "   --runtime:VERSION  Sets mscorlib.dll metadata version: v1, v2, v4\n" +
                                "   --stacktrace       Shows stack trace at error location\n" +
@@ -933,7 +925,7 @@ namespace Mono.CSharp {
                                return ParseResult.Success;
 
                        case "/debug":
-                               if (value == "full" || value == "pdbonly" || idx < 0) {
+                               if (value.Equals ("full", StringComparison.OrdinalIgnoreCase) || value.Equals ("pdbonly", StringComparison.OrdinalIgnoreCase) || idx < 0) {
                                        settings.GenerateDebugInfo = true;
                                        return ParseResult.Success;
                                }
@@ -1425,6 +1417,10 @@ namespace Mono.CSharp {
                                settings.LoadDefaultReferences = false;
                                return ParseResult.Success;
 
+                       case "--metadata-only":
+                               settings.WriteMetadataOnly = true;
+                               return ParseResult.Success;
+
                        default:
                                if (arg.StartsWith ("--fatal", StringComparison.Ordinal)){
                                        int fatal = 1;