diff --git a/mcs/tools/mono-xsd/ChangeLog b/mcs/tools/mono-xsd/ChangeLog index a1ec7b05c8043..9db45c35ea36b 100644 --- a/mcs/tools/mono-xsd/ChangeLog +++ b/mcs/tools/mono-xsd/ChangeLog @@ -1,3 +1,9 @@ +2004-08-16 Atsushi Enomoto + + * 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 * NewMonoXSD.cs : /generator (/g) option didn't work, since it usually diff --git a/mcs/tools/mono-xsd/NewMonoXSD.cs b/mcs/tools/mono-xsd/NewMonoXSD.cs index 61e77025bd417..9c5628c9d00aa 100755 --- a/mcs/tools/mono-xsd/NewMonoXSD.cs +++ b/mcs/tools/mono-xsd/NewMonoXSD.cs @@ -40,8 +40,10 @@ public class Driver " /e /element:NAME Element from schema to generate code for.\n" + " Multiple elements can be specified.\n" + " /u /uri:NAME Namespace uri of the elements to generate code for.\n" + - " /l /language:NAME The language to use for the generated code.\n" + - " Currently, the only supported language is CS (C#).\n" + + " /l /language:NAME The language, or type name of custom CodeDomProvider\n" + + " to use for the generated code.\n" + + " Shorthand specifiers are: \"CS\" (C#) and \"VB\" (VB.NET).\n" + + " For type name, assembly qualified name is required.\n" + " /g /generator:TYPE Code Generator type name, followed by ','\n" + " and assembly file name.\n" + " /o /outputdir:PATH The directory where to generate the code or schemas.\n" + @@ -220,6 +222,9 @@ public void Run (string[] args) if (outputDir == null) outputDir = "."; + string typename = null; + Type generatorType = null; + if (language != null) { switch (language) { case "CS": @@ -229,18 +234,20 @@ public void Run (string[] args) provider = new VBCodeProvider (); break; default: - Error (languageNotSupported, language); + typename = StripQuot (language); + + generatorType = Type.GetType (typename); + if (generatorType == null) + Error (generatorTypeNotFound, typename); break; } } if (providerOption != null) { string param = providerOption; - string typename; - Type generatorType; int comma = param.IndexOf (','); if (comma < 0) { - typename = param; + typename = StripQuot (param); generatorType = Type.GetType (param); } else { typename = param.Substring (0, comma); @@ -256,14 +263,16 @@ public void Run (string[] args) } if (generatorType == null) Error (generatorTypeNotFound, typename); + } + if (generatorType != null) { if (!generatorType.IsSubclassOf (typeof (CodeDomProvider))) Error (generatorTypeIsNotCodeGenerator, typename); try { provider = (CodeDomProvider) Activator.CreateInstance (generatorType, null); } catch (Exception ex) { - Error (generatorThrewException, param); + Error (generatorThrewException, generatorType.AssemblyQualifiedName.ToString () + " --> " + ex.Message); } - Console.WriteLine ("Loaded custom generator type " + param + " ."); + Console.WriteLine ("Loaded custom generator type " + generatorType + " ."); } if (provider == null) provider = new CSharpCodeProvider (); @@ -472,5 +481,16 @@ public void Error (string msg, string param) { throw new Exception (string.Format(msg,param)); } + + private string StripQuot (string input) + { + if (input.Length < 2) + return input; + if (input [0] == '"' && input [input.Length -1] == '"' || + input [0] == '\'' && input [input.Length - 1] == '\'') + return input.Substring (1, input.Length - 2); + else + return language; + } } }