Skip to content

Commit

Permalink
2004-08-16 Atsushi Enomoto <atsushi@ximian.com>
Browse files Browse the repository at this point in the history
	* NewMonoXSD.cs : /language should support custom assembly qualified
	  name specification. This fixes bug #63081.
	  Also fixed usage message. "VB" is considered as valid.

svn path=/trunk/mcs/; revision=32362
  • Loading branch information
atsushieno committed Aug 16, 2004
1 parent f47a3cd commit 45c04c2
Show file tree
Hide file tree
Showing 2 changed files with 34 additions and 8 deletions.
6 changes: 6 additions & 0 deletions mcs/tools/mono-xsd/ChangeLog
@@ -1,3 +1,9 @@
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
Expand Down
36 changes: 28 additions & 8 deletions mcs/tools/mono-xsd/NewMonoXSD.cs
Expand Up @@ -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" +
Expand Down Expand Up @@ -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":
Expand All @@ -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);
Expand All @@ -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 ();
Expand Down Expand Up @@ -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;
}
}
}

0 comments on commit 45c04c2

Please sign in to comment.