// Author:
// Daniel Stodden (stodden@in.tum.de)
// Marek Safar (marek.safar@seznam.cz)
+// Ilker Cetinkaya (mail@ilker.de)
//
// (C) 2002 Ximian, Inc.
//
{
GenerateCompileUnitStart (compileUnit);
+ GenerateGlobalNamespace (compileUnit);
+
if (compileUnit.AssemblyCustomAttributes.Count > 0) {
OutputAttributes (compileUnit.AssemblyCustomAttributes,
"assembly: ", false);
Output.WriteLine ("");
}
- foreach (CodeNamespace ns in compileUnit.Namespaces)
- GenerateNamespace (ns);
+ GenerateLocalNamespaces (compileUnit);
GenerateCompileUnitEnd (compileUnit);
}
-#if NET_2_0
+ private void GenerateGlobalNamespace (CodeCompileUnit compileUnit) {
+ CodeNamespace globalNamespace = null;
+
+ foreach (CodeNamespace codeNamespace in compileUnit.Namespaces)
+ if (string.IsNullOrEmpty (codeNamespace.Name))
+ globalNamespace = codeNamespace;
+
+ if (globalNamespace != null)
+ GenerateNamespace (globalNamespace);
+ }
+
+ private void GenerateLocalNamespaces (CodeCompileUnit compileUnit) {
+ foreach (CodeNamespace codeNamespace in compileUnit.Namespaces)
+ if (!string.IsNullOrEmpty (codeNamespace.Name))
+ GenerateNamespace (codeNamespace);
+ }
+
protected override void GenerateDefaultValueExpression (CodeDefaultValueExpression e)
{
Output.Write ("default(");
OutputType (e.Type);
Output.Write (')');
}
-#endif
protected override void GenerateDelegateCreateExpression (CodeDelegateCreateExpression expression)
{
break;
}
+ if ((declaration.Attributes & MemberAttributes.New) != 0)
+ output.Write ("new ");
+
if (declaration.IsStruct) {
if (declaration.IsPartial) {
output.Write ("partial ");
break;
default:
StringBuilder sb = new StringBuilder (baseType.Length);
- if (type.Options == CodeTypeReferenceOptions.GlobalReference) {
+ if ((type.Options & CodeTypeReferenceOptions.GlobalReference) != 0) {
sb.Append ("global::");
}
}
static bool is_identifier_start_character (char c)
- {
- return (c >= 'a' && c <= 'z') || (c >= 'A' && c <= 'Z') || c == '_' || c == '@' || Char.IsLetter (c);
- }
-
- static bool is_identifier_part_character (char c)
- {
- return (c >= 'a' && c <= 'z') || (c >= 'A' && c <= 'Z') || c == '_' || (c >= '0' && c <= '9') || Char.IsLetter (c);
- }
+ {
+ return (c >= 'a' && c <= 'z') || (c >= 'A' && c <= 'Z') || c == '_' || c == '@' || Char.IsLetter (c);
+ }
+
+ static bool is_identifier_part_character (char c)
+ {
+ return (c >= 'a' && c <= 'z') || (c >= 'A' && c <= 'Z') || c == '_' || (c >= '0' && c <= '9') || Char.IsLetter (c);
+ }
protected override bool IsValidIdentifier (string identifier)
{
return false;
if (!is_identifier_start_character (identifier [0]))
- return false;
-
- for (int i = 1; i < identifier.Length; i ++)
- if (! is_identifier_part_character (identifier [i]))
- return false;
-
- return true;
+ return false;
+
+ for (int i = 1; i < identifier.Length; i ++)
+ if (! is_identifier_part_character (identifier [i]))
+ return false;
+
+ return true;
}
protected override bool Supports (GeneratorSupport supports)