2004-08-16 Atsushi Enomoto <atsushi@ximian.com>
authorAtsushi Eno <atsushieno@gmail.com>
Mon, 16 Aug 2004 07:15:29 +0000 (07:15 -0000)
committerAtsushi Eno <atsushieno@gmail.com>
Mon, 16 Aug 2004 07:15:29 +0000 (07:15 -0000)
(up-to-date fixes that are applied to HEAD.)

* NewMonoXSD.cs : /language should support custom assembly qualified
  name specification. This fixes bug #63081.
  Also fixed usage message. "VB" is considered as valid.

2004-08-07  Atsushi Enomoto <atsushi@ximian.com>

* NewMonoXSD.cs : /generator (/g) option didn't work, since it usually
  ends with .dll (or .exe) and regarded as mere assembly filename.

2004-07-12  Lluis Sanchez Gual  <lluis@novell.com>

* NewMonoXSD.cs: Accept files with absolute paths.

svn path=/branches/mono-1-0/mcs/; revision=32363

mcs/tools/mono-xsd/ChangeLog
mcs/tools/mono-xsd/NewMonoXSD.cs

index af9eaa1f82ca3d34c032251296219c971aa45292..9db45c35ea36b73a1503bc1605ccc109837fc8b4 100644 (file)
@@ -1,3 +1,18 @@
+2004-08-16  Atsushi Enomoto <atsushi@ximian.com>
+
+       * NewMonoXSD.cs : /language should support custom assembly qualified
+         name specification. This fixes bug #63081.
+         Also fixed usage message. "VB" is considered as valid.
+
+2004-08-07  Atsushi Enomoto <atsushi@ximian.com>
+
+       * NewMonoXSD.cs : /generator (/g) option didn't work, since it usually
+         ends with .dll (or .exe) and regarded as mere assembly filename.
+
+2004-07-12  Lluis Sanchez Gual  <lluis@novell.com>
+
+       * NewMonoXSD.cs: Accept files with absolute paths.
+
 2004-05-07  Atsushi Enomoto <atsushi@ximian.com>
 
        * NewMonoXSD.cs : Previous change broke default C# code generation.
index 0ba6ac69584ba154b832f0bfe010b2cd82625c83..9c5628c9d00aab8be34709dba8b5780f49a65f88 100755 (executable)
@@ -40,8 +40,10 @@ namespace Mono.Util {
                        "   /e /element:NAME   Element from schema to generate code for.\n" +\r
                        "                      Multiple elements can be specified.\n" +\r
                        "   /u /uri:NAME       Namespace uri of the elements to generate code for.\n" +\r
-                       "   /l /language:NAME  The language to use for the generated code.\n" +\r
-                       "                      Currently, the only supported language is CS (C#).\n" +\r
+                       "   /l /language:NAME  The language, or type name of custom CodeDomProvider\n" +\r
+                       "                      to use for the generated code.\n" +\r
+                       "                      Shorthand specifiers are: \"CS\" (C#) and \"VB\" (VB.NET).\n" +\r
+                       "                      For type name, assembly qualified name is required.\n" +\r
                        "   /g /generator:TYPE Code Generator type name, followed by ','\n" + \r
                        "                      and assembly file name.\n" +\r
                        "   /o /outputdir:PATH The directory where to generate the code or schemas.\n" +\r
@@ -110,8 +112,11 @@ namespace Mono.Util {
 \r
                        foreach (string arg in args)\r
                        {\r
-                               if (!arg.StartsWith ("--") && !arg.StartsWith ("/")) {\r
-                                       if (arg.EndsWith (".dll") || arg.EndsWith (".exe"))\r
+                               if (!arg.StartsWith ("--") && !arg.StartsWith ("/") ||\r
+                                       (arg.StartsWith ("/") && arg.IndexOfAny (Path.InvalidPathChars) == -1)\r
+                                       ) \r
+                               {\r
+                                       if ((arg.EndsWith (".dll") || arg.EndsWith (".exe")) && !arg.Substring (1).StartsWith ("generator:") && !arg.Substring (1).StartsWith ("g:"))\r
                                        {\r
                                                if (!readingFiles) throw new Exception (incorrectOrder);\r
                                                assemblies.Add (arg);\r
@@ -132,7 +137,7 @@ namespace Mono.Util {
                                                inference = true;\r
                                                continue;\r
                                        }\r
-                                       else //if (!arg.StartsWith ("/") && !arg.StartsWith ("-"))\r
+                                       else if (!arg.StartsWith ("/"))\r
                                        {\r
                                                if (!readingFiles) Error (incorrectOrder);\r
                                                unknownFiles.Add (arg);\r
@@ -217,6 +222,9 @@ namespace Mono.Util {
 \r
                        if (outputDir == null) outputDir = ".";\r
 \r
+                       string typename = null;\r
+                       Type generatorType = null;\r
+\r
                        if (language != null) {\r
                                switch (language) {\r
                                case "CS":\r
@@ -226,18 +234,20 @@ namespace Mono.Util {
                                        provider = new VBCodeProvider ();\r
                                        break;\r
                                default:\r
-                                       Error (languageNotSupported, language);\r
+                                       typename = StripQuot (language);\r
+\r
+                                       generatorType = Type.GetType (typename);\r
+                                       if (generatorType == null)\r
+                                               Error (generatorTypeNotFound, typename);\r
                                        break;\r
                                }\r
                        }\r
 \r
                        if (providerOption != null) {\r
                                string param = providerOption;\r
-                               string typename;\r
-                               Type generatorType;\r
                                int comma = param.IndexOf (',');\r
                                if (comma < 0) {\r
-                                       typename = param;\r
+                                       typename = StripQuot (param);\r
                                        generatorType = Type.GetType (param);\r
                                } else {\r
                                        typename = param.Substring (0, comma);\r
@@ -253,14 +263,16 @@ namespace Mono.Util {
                                }\r
                                if (generatorType == null)\r
                                        Error (generatorTypeNotFound, typename);\r
+                       }\r
+                       if (generatorType != null) {\r
                                if (!generatorType.IsSubclassOf (typeof (CodeDomProvider)))\r
                                        Error (generatorTypeIsNotCodeGenerator, typename);\r
                                try {\r
                                        provider = (CodeDomProvider) Activator.CreateInstance (generatorType, null);\r
                                } catch (Exception ex) {\r
-                                       Error (generatorThrewException, param);\r
+                                       Error (generatorThrewException, generatorType.AssemblyQualifiedName.ToString () + " --> " + ex.Message);\r
                                }\r
-                               Console.WriteLine ("Loaded custom generator type " + param + " .");\r
+                               Console.WriteLine ("Loaded custom generator type " + generatorType + " .");\r
                        }\r
                        if (provider == null)\r
                                provider = new CSharpCodeProvider ();\r
@@ -469,5 +481,16 @@ namespace Mono.Util {
                {\r
                        throw new Exception (string.Format(msg,param));\r
                }\r
+\r
+               private string StripQuot (string input)\r
+               {\r
+                       if (input.Length < 2)\r
+                               return input;\r
+                       if (input [0] == '"' && input [input.Length -1] == '"' ||\r
+                               input [0] == '\'' && input [input.Length - 1] == '\'')\r
+                               return input.Substring (1, input.Length - 2);\r
+                       else\r
+                               return language;\r
+               }\r
        }\r
 }\r