diff options
author | Atsushi Eno <atsushieno@gmail.com> | 2004-08-16 11:15:29 +0400 |
---|---|---|
committer | Atsushi Eno <atsushieno@gmail.com> | 2004-08-16 11:15:29 +0400 |
commit | adc40a321ef7d2608196aafabb49157ad6141097 (patch) | |
tree | df82355638566cc442991356f8921a2ad6a4fb5a /mcs | |
parent | 0bbb93f17f89283094caf1725692b6f91f2f767c (diff) |
2004-08-16 Atsushi Enomoto <atsushi@ximian.com>
(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
Diffstat (limited to 'mcs')
-rw-r--r-- | mcs/tools/mono-xsd/ChangeLog | 15 | ||||
-rwxr-xr-x | mcs/tools/mono-xsd/NewMonoXSD.cs | 45 |
2 files changed, 49 insertions, 11 deletions
diff --git a/mcs/tools/mono-xsd/ChangeLog b/mcs/tools/mono-xsd/ChangeLog index af9eaa1f82c..9db45c35ea3 100644 --- a/mcs/tools/mono-xsd/ChangeLog +++ b/mcs/tools/mono-xsd/ChangeLog @@ -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. diff --git a/mcs/tools/mono-xsd/NewMonoXSD.cs b/mcs/tools/mono-xsd/NewMonoXSD.cs index 0ba6ac69584..9c5628c9d00 100755 --- a/mcs/tools/mono-xsd/NewMonoXSD.cs +++ b/mcs/tools/mono-xsd/NewMonoXSD.cs @@ -40,8 +40,10 @@ namespace Mono.Util { " /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" +
@@ -110,8 +112,11 @@ namespace Mono.Util { foreach (string arg in args)
{
- if (!arg.StartsWith ("--") && !arg.StartsWith ("/")) {
- if (arg.EndsWith (".dll") || arg.EndsWith (".exe"))
+ if (!arg.StartsWith ("--") && !arg.StartsWith ("/") ||
+ (arg.StartsWith ("/") && arg.IndexOfAny (Path.InvalidPathChars) == -1)
+ )
+ {
+ if ((arg.EndsWith (".dll") || arg.EndsWith (".exe")) && !arg.Substring (1).StartsWith ("generator:") && !arg.Substring (1).StartsWith ("g:"))
{
if (!readingFiles) throw new Exception (incorrectOrder);
assemblies.Add (arg);
@@ -132,7 +137,7 @@ namespace Mono.Util { inference = true;
continue;
}
- else //if (!arg.StartsWith ("/") && !arg.StartsWith ("-"))
+ else if (!arg.StartsWith ("/"))
{
if (!readingFiles) Error (incorrectOrder);
unknownFiles.Add (arg);
@@ -217,6 +222,9 @@ namespace Mono.Util { if (outputDir == null) outputDir = ".";
+ string typename = null;
+ Type generatorType = null;
+
if (language != null) {
switch (language) {
case "CS":
@@ -226,18 +234,20 @@ namespace Mono.Util { 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);
@@ -253,14 +263,16 @@ namespace Mono.Util { }
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 ();
@@ -469,5 +481,16 @@ namespace Mono.Util { {
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;
+ }
}
}
|