* CodeGeneratorFromTypeTest.cs: Added BaseTypes and TypeConstructor
authorGert Driesen <drieseng@users.sourceforge.net>
Sun, 24 Jul 2005 12:19:26 +0000 (12:19 -0000)
committerGert Driesen <drieseng@users.sourceforge.net>
Sun, 24 Jul 2005 12:19:26 +0000 (12:19 -0000)
tests. Added enum, interface and delegate tests.
* CodeTypeDelegateTest.cs: Added tests for BaseTypes and ReturnType.
* CodeGeneratorTest.cs: Removed duplicate import of NUNit.Framework namespace.
* CodeGeneratorFromTypeTestBase.cs: Added BaseTypes and TypeConstructor tests.
* CodeGeneratorFromTypeTest.cs: Added BaseTypes and TypeConstructor
tests. Enabled enum, interface and delegate tests.
* CSharpCodeGenerator.cs: Fixed generated code for enums, interfaces
and delegates to match MS.NET.
* CodeTypeReference.cs: Added internal IsInterface property.
* CodeTypeDelegate.cs: System.Delegate is base type, and make sure
ReturnType is initialized.
* System_test.dll.sources: Added CodeTypeDelegateTest.cs from System.CodeDom.
* CodeGenerator.cs: Threat delegates like any other type.
* VBCodeGenerator.cs: Fixed generated code for enums, interfaces and
delegates to match MS.NET.

svn path=/trunk/mcs/; revision=47604

20 files changed:
mcs/class/System/ChangeLog
mcs/class/System/Microsoft.CSharp/CSharpCodeGenerator.cs
mcs/class/System/Microsoft.CSharp/ChangeLog
mcs/class/System/Microsoft.VisualBasic/ChangeLog
mcs/class/System/Microsoft.VisualBasic/VBCodeGenerator.cs
mcs/class/System/System.CodeDom.Compiler/ChangeLog
mcs/class/System/System.CodeDom.Compiler/CodeGenerator.cs
mcs/class/System/System.CodeDom/ChangeLog
mcs/class/System/System.CodeDom/CodeTypeDelegate.cs
mcs/class/System/System.CodeDom/CodeTypeReference.cs
mcs/class/System/System_test.dll.sources
mcs/class/System/Test/Microsoft.CSharp/ChangeLog
mcs/class/System/Test/Microsoft.CSharp/CodeGeneratorFromTypeTest.cs
mcs/class/System/Test/Microsoft.VisualBasic/ChangeLog
mcs/class/System/Test/Microsoft.VisualBasic/CodeGeneratorFromTypeTest.cs
mcs/class/System/Test/System.CodeDom.Compiler/ChangeLog
mcs/class/System/Test/System.CodeDom.Compiler/CodeGeneratorFromTypeTestBase.cs
mcs/class/System/Test/System.CodeDom.Compiler/CodeGeneratorTest.cs
mcs/class/System/Test/System.CodeDom/ChangeLog
mcs/class/System/Test/System.CodeDom/CodeTypeDelegateTest.cs [new file with mode: 0644]

index 0bd7144a2ed72614f51eac0b46f5fc33509c4b90..dd8bc9be2fefc0fbf523821226571c6826772c67 100644 (file)
@@ -1,3 +1,8 @@
+2005-07-24 Gert Driesen <drieseng@users.sourceforge.net>
+
+       * System_test.dll.sources: Added CodeTypeDelegateTest.cs from
+       System.CodeDom.
+
 2005-07-21 Gert Driesen <drieseng@users.sourceforge.net>
 
        * System_test.dll.sources: Added CodeGeneratorTest.cs from
index 0e164e1c1f3dd8bfedbc8809ed612231f29d3dca..303b32c54709a452de03106b5629862b46a548b4 100644 (file)
@@ -43,10 +43,9 @@ namespace Mono.CSharp
        internal class CSharpCodeGenerator
                : CodeGenerator
        {
-            
                // It is used for beautiful "for" syntax
                bool dont_write_semicolon;
-            
+
                //
                // Constructors
                //
@@ -527,6 +526,10 @@ namespace Mono.CSharp
 
                protected override void GenerateEvent( CodeMemberEvent eventRef, CodeTypeDeclaration declaration )
                {
+                       if (IsCurrentDelegate || IsCurrentEnum) {
+                               return;
+                       }
+
                        OutputAttributes (eventRef.CustomAttributes, null, false);
 
                        if (eventRef.PrivateImplementationType == null) {
@@ -547,6 +550,10 @@ namespace Mono.CSharp
 
                protected override void GenerateField( CodeMemberField field )
                {
+                       if (IsCurrentDelegate || IsCurrentInterface) {
+                               return;
+                       }
+
                        TextWriter output = Output;
 
                        OutputAttributes (field.CustomAttributes, null, false);
@@ -588,6 +595,10 @@ namespace Mono.CSharp
                protected override void GenerateMethod( CodeMemberMethod method,
                                                        CodeTypeDeclaration declaration )
                {
+                       if (IsCurrentDelegate || IsCurrentEnum) {
+                               return;
+                       }
+
                        TextWriter output = Output;
 
                        OutputAttributes (method.CustomAttributes, null, false);
@@ -638,20 +649,26 @@ namespace Mono.CSharp
                protected override void GenerateProperty( CodeMemberProperty property,
                                                          CodeTypeDeclaration declaration )
                {
+                       if (IsCurrentDelegate || IsCurrentEnum) {
+                               return;
+                       }
+
                        TextWriter output = Output;
 
                        OutputAttributes (property.CustomAttributes, null, false);
 
-                       if (property.PrivateImplementationType == null) {
-                               MemberAttributes attributes = property.Attributes;
-                               OutputMemberAccessModifier (attributes);
-                               OutputMemberScopeModifier (attributes);
+                       if (!IsCurrentInterface) {
+                               if (property.PrivateImplementationType == null) {
+                                       MemberAttributes attributes = property.Attributes;
+                                       OutputMemberAccessModifier (attributes);
+                                       OutputMemberScopeModifier (attributes);
+                               }
                        }
 
                        OutputType (property.Type);
                        output.Write (' ');
 
-                       if (property.PrivateImplementationType != null) {
+                       if (!IsCurrentInterface && property.PrivateImplementationType != null) {
                                output.Write (property.PrivateImplementationType.BaseType);
                                output.Write ('.');
                        }
@@ -670,8 +687,8 @@ namespace Mono.CSharp
 
                        if (declaration.IsInterface)
                        {
-                               if (property.HasGet) output.WriteLine("get; ");
-                               if (property.HasSet) output.WriteLine("set; ");
+                               if (property.HasGet) output.WriteLine("get;");
+                               if (property.HasSet) output.WriteLine("set;");
                        }
                        else
                        {
@@ -702,9 +719,12 @@ namespace Mono.CSharp
                        output.WriteLine ('}');
                }
 
-               protected override void GenerateConstructor( CodeConstructor constructor,
-                                                            CodeTypeDeclaration declaration )
+               protected override void GenerateConstructor( CodeConstructor constructor, CodeTypeDeclaration declaration )
                {
+                       if (IsCurrentDelegate || IsCurrentEnum || IsCurrentInterface) {
+                               return;
+                       }
+
                        OutputAttributes (constructor.CustomAttributes, null, false);
 
                        OutputMemberAccessModifier (constructor.Attributes);
@@ -736,6 +756,14 @@ namespace Mono.CSharp
                
                protected override void GenerateTypeConstructor( CodeTypeConstructor constructor )
                {
+                       if (IsCurrentDelegate || IsCurrentEnum || IsCurrentInterface) {
+                               return;
+                       }
+
+#if NET_2_0
+                       OutputAttributes (constructor.CustomAttributes, null, false);
+#endif
+
                        Output.WriteLine ("static " + GetSafeName (CurrentTypeName) + "() {");
                        Indent++;
                        GenerateStatements (constructor.Statements);
@@ -743,65 +771,63 @@ namespace Mono.CSharp
                        Output.WriteLine ('}');
                }
 
-               protected override void GenerateTypeStart( CodeTypeDeclaration declaration )
+               protected override void GenerateTypeStart(CodeTypeDeclaration declaration)
                {
                        TextWriter output = Output;
-                       CodeTypeDelegate del = declaration as CodeTypeDelegate;
 
                        OutputAttributes (declaration.CustomAttributes, null, false);
 
-                       TypeAttributes attributes = declaration.TypeAttributes;
-                       OutputTypeAttributes( attributes,
-                                             declaration.IsStruct,
-                                             declaration.IsEnum );
-
-                       if (del != null) {
-                               if (del.ReturnType != null)
-                                       OutputType (del.ReturnType);
-                               else
-                                       Output.Write ("void");
-                               output.Write(' ');
-                       }
+                       if (!IsCurrentDelegate) {
+                               OutputTypeAttributes (declaration);
 
-                       output.Write( GetSafeName (declaration.Name) );
+                               output.Write (GetSafeName (declaration.Name));
 
 #if NET_2_0
-                       GenerateGenericsParameters (declaration.TypeParameters);
+                               GenerateGenericsParameters (declaration.TypeParameters);
 #endif
-                       
-                       IEnumerator enumerator = declaration.BaseTypes.GetEnumerator();
-                       if ( enumerator.MoveNext() ) {
-                               CodeTypeReference type = (CodeTypeReference)enumerator.Current;
-                       
-                               output.Write( ": " );
-                               OutputType( type );
-                               
-                               while ( enumerator.MoveNext() ) {
-                                       type = (CodeTypeReference)enumerator.Current;
-                               
-                                       output.Write( ", " );
-                                       OutputType( type );
+
+                               IEnumerator enumerator = declaration.BaseTypes.GetEnumerator ();
+                               if (enumerator.MoveNext ()) {
+                                       CodeTypeReference type = (CodeTypeReference) enumerator.Current;
+
+                                       output.Write (" : ");
+                                       OutputType (type);
+
+                                       while (enumerator.MoveNext ()) {
+                                               type = (CodeTypeReference) enumerator.Current;
+
+                                               output.Write (", ");
+                                               OutputType (type);
+                                       }
                                }
-                       }
 
-                       if (del != null)
-                               output.Write ( " (" );
-                       else {
 #if NET_2_0
                                GenerateGenericsConstraints (declaration.TypeParameters);
 #endif
-                               output.WriteLine ( " {" );
+                               output.WriteLine (" {");
+                               ++Indent;
+                       } else {
+                               if ((declaration.TypeAttributes & TypeAttributes.VisibilityMask) == TypeAttributes.Public) {
+                                       output.Write ("public ");
+                               }
+
+                               CodeTypeDelegate delegateDecl = (CodeTypeDelegate) declaration;
+                               output.Write ("delegate ");
+                               OutputType (delegateDecl.ReturnType);
+                               output.Write (" ");
+                               output.Write (GetSafeName (declaration.Name));
+                               output.Write ("(");
+                               OutputParameters (delegateDecl.Parameters);
+                               output.WriteLine (");");
                        }
-                       ++Indent;
                }
 
                protected override void GenerateTypeEnd( CodeTypeDeclaration declaration )
                {
-                       --Indent;
-                       if (declaration is CodeTypeDelegate)
-                               Output.WriteLine (");");
-                       else
+                       if (!IsCurrentDelegate) {
+                               --Indent;
                                Output.WriteLine ("}");
+                       }
                }
 
                protected override void GenerateNamespaceStart( CodeNamespace ns )
@@ -885,6 +911,66 @@ namespace Mono.CSharp
                        Output.Write( GetTypeOutput( type ) );
                }
 
+               private void OutputTypeAttributes (CodeTypeDeclaration declaration)
+               {
+                       TextWriter output = Output;
+                       TypeAttributes attributes = declaration.TypeAttributes;
+
+                       switch (attributes & TypeAttributes.VisibilityMask) {
+                               case TypeAttributes.Public:
+                               case TypeAttributes.NestedPublic:
+                                       output.Write ("public ");
+                                       break;
+                               case TypeAttributes.NestedPrivate:
+                                       output.Write ("private ");
+                                       break;
+#if NET_2_0
+                               case TypeAttributes.NotPublic:
+                               case TypeAttributes.NestedFamANDAssem:
+                               case TypeAttributes.NestedAssembly:
+                                       output.Write ("internal ");
+                                       break; 
+                               case TypeAttributes.NestedFamily:
+                                       output.Write ("protected ");
+                                       break;
+                               case TypeAttributes.NestedFamORAssem:
+                                       output.Write ("protected internal ");
+                                       break;
+#endif
+                       }
+
+                       if (declaration.IsStruct) {
+#if NET_2_0
+                               if (declaration.IsPartial) {
+                                       output.Write ("partial ");
+                               }
+#endif
+                               output.Write ("struct ");
+                       } else if (declaration.IsEnum) {
+                               output.Write ("enum ");
+                       } else {
+                               if ((attributes & TypeAttributes.Interface) != 0) {
+#if NET_2_0
+                                       if (declaration.IsPartial) {
+                                               output.Write ("partial ");
+                                       }
+#endif
+                                       output.Write ("interface ");
+                               } else {
+                                       if ((attributes & TypeAttributes.Sealed) != 0)
+                                               output.Write ("sealed ");
+                                       if ((attributes & TypeAttributes.Abstract) != 0)
+                                               output.Write ("abstract ");
+#if NET_2_0
+                                       if (declaration.IsPartial) {
+                                               output.Write ("partial ");
+                                       }
+#endif
+                                       output.Write ("class ");
+                               }
+                       }
+               }
+
                [MonoTODO ("Implement missing special characters")]
                protected override string QuoteSnippetString( string value )
                {
@@ -1138,15 +1224,8 @@ namespace Mono.CSharp
                        sb [sb.Length - 1] = '>';
                        return sb.ToString ();
                }
-
-               internal override void OutputExtraTypeAttribute (CodeTypeDeclaration type)
-               {
-                       if (type.IsPartial)
-                               Output.Write ("partial ");
-               }
 #endif
 
-
 #if false
                //[MonoTODO]
                public override void ValidateIdentifier( string identifier )
index 345d2c69e60f86580c61c6024f0950cab85d2e6c..644b6b2aea779758b05fd6fef3ceae2d40f82c7b 100644 (file)
@@ -1,3 +1,8 @@
+2005-07-24 Gert Driesen <drieseng@users.sourceforge.net>
+
+       * CSharpCodeGenerator.cs: Fixed generated code for enums, interfaces
+       and delegates to match MS.NET.
+
 2005-07-02 Gert Driesen <drieseng@users.sourceforge.net>
 
        * CSharpCodeGenerator.cs: Fixed output of ReturnTypeCustomAttributes.
index 670eafc5ab4e07f8551501ea7b3b58d7321d0b83..87c2fd6b806f2b8713f5379e34cc223714499de8 100644 (file)
@@ -1,3 +1,8 @@
+2005-07-24  Gert Driesen <drieseng@users.sourceforge.net>
+
+       * VBCodeGenerator.cs: Fixed generated code for enums, interfaces and
+       delegates to match MS.NET.
+
 2005-07-02  Gert Driesen <drieseng@users.sourceforge.net>
 
        * VBCodeGenerator.cs: Added support for ReturnTypeCustomAttributes.
index 089f9af14bad85061bbc40a907c1da4a7739b9a1..a5eea82643fbc01a9c6f0cc626b19998741390d8 100644 (file)
@@ -565,6 +565,10 @@ namespace Microsoft.VisualBasic
 \r
                protected override void GenerateEvent (CodeMemberEvent eventRef, CodeTypeDeclaration declaration)\r
                {\r
+                       if (IsCurrentDelegate || IsCurrentEnum) {\r
+                               return;\r
+                       }\r
+\r
                        TextWriter output = Output;\r
 \r
                        OutputAttributes (eventRef.CustomAttributes, null, \r
@@ -591,16 +595,23 @@ namespace Microsoft.VisualBasic
 \r
                protected override void GenerateField (CodeMemberField field)\r
                {\r
+                       if (IsCurrentDelegate || IsCurrentInterface) {\r
+                               return;\r
+                       }\r
+\r
                        TextWriter output = Output;\r
 \r
                        OutputAttributes (field.CustomAttributes, null, \r
                                LineHandling.ContinueLine);\r
 \r
-                       MemberAttributes attributes = field.Attributes;\r
-                       OutputMemberAccessModifier (attributes);\r
-                       OutputFieldScopeModifier (attributes);\r
-\r
-                       OutputTypeNamePair (field.Type, field.Name);\r
+                       if (IsCurrentEnum) {\r
+                               output.Write (field.Name);\r
+                       } else {\r
+                               MemberAttributes attributes = field.Attributes;\r
+                               OutputMemberAccessModifier (attributes);\r
+                               OutputFieldScopeModifier (attributes);\r
+                               OutputTypeNamePair (field.Type, field.Name);\r
+                       }\r
 \r
                        CodeExpression initExpression = field.InitExpression;\r
                        if (initExpression != null) {\r
@@ -625,6 +636,10 @@ namespace Microsoft.VisualBasic
                [MonoTODO ("partially implemented")]\r
                protected override void GenerateMethod (CodeMemberMethod method, CodeTypeDeclaration declaration)\r
                {\r
+                       if (IsCurrentDelegate || IsCurrentEnum) {\r
+                               return;\r
+                       }\r
+\r
                        bool isSub = method.ReturnType.BaseType == typeof(void).FullName;\r
 \r
                        TextWriter output = Output;\r
@@ -634,15 +649,16 @@ namespace Microsoft.VisualBasic
 \r
                        MemberAttributes attributes = method.Attributes;\r
 \r
-                       if (method.PrivateImplementationType == null) {\r
-                               OutputMemberAccessModifier (attributes);\r
-                               if (IsOverloaded (method, declaration)) {\r
-                                       output.Write ("Overloads ");\r
+                       if (!IsCurrentInterface) {\r
+                               if (method.PrivateImplementationType == null) {\r
+                                       OutputMemberAccessModifier (attributes);\r
+                                       if (IsOverloaded (method, declaration)) {\r
+                                               output.Write ("Overloads ");\r
+                                       }\r
                                }\r
+                               OutputMemberScopeModifier (attributes);\r
                        }\r
 \r
-                       OutputMemberScopeModifier (attributes);\r
-\r
                        if (isSub)\r
                                output.Write ("Sub ");\r
                        else\r
@@ -669,35 +685,41 @@ namespace Microsoft.VisualBasic
                                output.Write (method.Name);\r
                        }\r
 \r
-                       if ((attributes & MemberAttributes.ScopeMask) == MemberAttributes.Abstract)\r
-                               output.WriteLine ();\r
-                       else {\r
-                               output.WriteLine ();\r
-                               ++Indent;\r
-                               GenerateStatements (method.Statements);\r
-                               --Indent;\r
-                               if (isSub)\r
-                                       output.WriteLine ("End Sub");\r
-                               else\r
-                                       output.WriteLine ("End Function");\r
+                       output.WriteLine ();\r
+                       if (!IsCurrentInterface) {\r
+                               if ((attributes & MemberAttributes.ScopeMask) != MemberAttributes.Abstract) {\r
+                                       ++Indent;\r
+                                       GenerateStatements (method.Statements);\r
+                                       --Indent;\r
+                                       if (isSub)\r
+                                               output.WriteLine ("End Sub");\r
+                                       else\r
+                                               output.WriteLine ("End Function");\r
+                               }\r
                        }\r
                }\r
 \r
                protected override void GenerateProperty (CodeMemberProperty property, CodeTypeDeclaration declaration)\r
                {\r
+                       if (IsCurrentDelegate || IsCurrentEnum) {\r
+                               return;\r
+                       }\r
+\r
                        TextWriter output = Output;\r
 \r
                        OutputAttributes (property.CustomAttributes, null, \r
                                LineHandling.ContinueLine);\r
 \r
-                       MemberAttributes attributes = property.Attributes;\r
-                       if (property.PrivateImplementationType == null) {\r
-                               OutputMemberAccessModifier (attributes);\r
-                               if (IsOverloaded (property, declaration)) {\r
-                                       output.Write ("Overloads ");\r
+                       if (!IsCurrentInterface) {\r
+                               MemberAttributes attributes = property.Attributes;\r
+                               if (property.PrivateImplementationType == null) {\r
+                                       OutputMemberAccessModifier (attributes);\r
+                                       if (IsOverloaded (property, declaration)) {\r
+                                               output.Write ("Overloads ");\r
+                                       }\r
                                }\r
+                               OutputMemberScopeModifier (attributes);\r
                        }\r
-                       OutputMemberScopeModifier (attributes);\r
 \r
                        // mark property as default property if we're dealing with an indexer\r
                        if (string.Compare (GetPropertyName(property), "Item", true, CultureInfo.InvariantCulture) == 0 && property.Parameters.Count > 0) {\r
@@ -738,30 +760,36 @@ namespace Microsoft.VisualBasic
                        }\r
 \r
                        output.WriteLine ();\r
-                       ++Indent;\r
 \r
-                       if (property.HasGet) {\r
-                               output.WriteLine ("Get");\r
+                       if (!IsCurrentInterface) {\r
                                ++Indent;\r
-                               GenerateStatements (property.GetStatements);\r
-                               --Indent;\r
-                               output.WriteLine ("End Get");\r
-                       }\r
-                       \r
-                       if (property.HasSet) {\r
-                               output.WriteLine ("Set");\r
-                               ++Indent;\r
-                               GenerateStatements (property.SetStatements);\r
+                               if (property.HasGet) {\r
+                                       output.WriteLine ("Get");\r
+                                       ++Indent;\r
+                                       GenerateStatements (property.GetStatements);\r
+                                       --Indent;\r
+                                       output.WriteLine ("End Get");\r
+                               }\r
+\r
+                               if (property.HasSet) {\r
+                                       output.WriteLine ("Set");\r
+                                       ++Indent;\r
+                                       GenerateStatements (property.SetStatements);\r
+                                       --Indent;\r
+                                       output.WriteLine ("End Set");\r
+                               }\r
+\r
                                --Indent;\r
-                               output.WriteLine ("End Set");\r
+                               output.WriteLine ("End Property");\r
                        }\r
-\r
-                       --Indent;\r
-                       output.WriteLine ("End Property");\r
                }\r
 \r
                protected override void GenerateConstructor (CodeConstructor constructor, CodeTypeDeclaration declaration)\r
                {\r
+                       if (IsCurrentDelegate || IsCurrentEnum || IsCurrentInterface) {\r
+                               return;\r
+                       }\r
+\r
                        OutputAttributes (constructor.CustomAttributes, null,\r
                                LineHandling.ContinueLine);\r
                        OutputMemberAccessModifier (constructor.Attributes);\r
@@ -782,7 +810,11 @@ namespace Microsoft.VisualBasic
                                        Output.Write ("MyBase.New(");\r
                                        OutputExpressionList (ctorArgs);\r
                                        Output.WriteLine (")");\r
+#if NET_2_0\r
+                               } else if (IsCurrentClass) {\r
+#else\r
                                } else {\r
+#endif\r
                                        // call default base ctor\r
                                        Output.WriteLine ("MyBase.New");\r
                                }\r
@@ -794,6 +826,15 @@ namespace Microsoft.VisualBasic
                \r
                protected override void GenerateTypeConstructor (CodeTypeConstructor constructor)\r
                {\r
+                       if (IsCurrentDelegate || IsCurrentEnum || IsCurrentInterface) {\r
+                               return;\r
+                       }\r
+\r
+#if NET_2_0\r
+                       OutputAttributes (constructor.CustomAttributes, null,\r
+                               LineHandling.ContinueLine);\r
+#endif\r
+\r
                        Output.WriteLine ("Shared Sub New()");\r
                        Indent++;\r
                        GenerateStatements (constructor.Statements);\r
@@ -810,42 +851,76 @@ namespace Microsoft.VisualBasic
                                LineHandling.ContinueLine);\r
 \r
                        TypeAttributes attributes = declaration.TypeAttributes;\r
-                       OutputTypeAttributes (attributes,\r
-                               declaration.IsStruct,\r
-                               declaration.IsEnum);\r
 \r
-                       output.WriteLine (declaration.Name);\r
+                       if (IsCurrentDelegate) {\r
+                               CodeTypeDelegate delegateDecl = (CodeTypeDelegate) declaration;\r
 \r
-                       ++Indent;\r
-                       \r
-                       IEnumerator enumerator = declaration.BaseTypes.GetEnumerator();\r
-                       if (enumerator.MoveNext()) \r
-                       {\r
-                               CodeTypeReference type = (CodeTypeReference)enumerator.Current;\r
-                       \r
-                               if (type != null)\r
-                               {\r
-                                       output.Write ("Inherits ");\r
-                                       OutputType (type);\r
-                                       output.WriteLine ();\r
+                               if ((attributes & TypeAttributes.VisibilityMask) == TypeAttributes.Public) {\r
+                                       output.Write ("Public ");\r
                                }\r
-                               \r
-                               while (enumerator.MoveNext()) \r
-                               {\r
-                                       type = (CodeTypeReference)enumerator.Current;\r
-                               \r
-                                       if (type != null)\r
-                                       {\r
-                                               output.Write ("Implements ");\r
-                                               OutputType (type);\r
-                                               output.WriteLine ();\r
+\r
+                               bool isSub = delegateDecl.ReturnType.BaseType == typeof (void).FullName;\r
+                               if (isSub) {\r
+                                       output.Write ("Delegate Sub ");\r
+                               } else {\r
+                                       output.Write ("Delegate Function ");\r
+                               }\r
+\r
+                               output.Write (delegateDecl.Name);\r
+                               output.Write ("(");\r
+                               Output.Write (")");\r
+                               if (!isSub) {\r
+                                       Output.Write (" As ");\r
+                                       OutputType (delegateDecl.ReturnType);\r
+                               }\r
+                               Output.WriteLine ("");\r
+                       } else {\r
+                               OutputTypeAttributes (declaration);\r
+\r
+                               output.Write (declaration.Name);\r
+\r
+                               if (IsCurrentEnum) {\r
+                                       if (declaration.BaseTypes.Count > 0) {\r
+                                               output.Write (" As ");\r
+                                               OutputType (declaration.BaseTypes[0]);\r
+                                       }\r
+                                       output.WriteLine ();\r
+                                       ++Indent;\r
+                               } else {\r
+                                       ++Indent;\r
+\r
+                                       bool firstInherits = true;\r
+                                       bool firstImplements = true;\r
+\r
+                                       for (int i = 0; i < declaration.BaseTypes.Count; i++) {\r
+                                               // a struct can only implement interfaces\r
+                                               // an interface can only inherit from other interface\r
+\r
+                                               CodeTypeReference typeRef = declaration.BaseTypes[i];\r
+                                               \r
+                                               if (firstInherits && !declaration.IsStruct && !typeRef.IsInterface) {\r
+                                                       output.WriteLine ();\r
+                                                       output.Write ("Inherits ");\r
+                                                       firstInherits = false;\r
+                                               } else if (!declaration.IsInterface && firstImplements) {\r
+                                                       output.WriteLine ();\r
+                                                       output.Write ("Implements ");\r
+                                                       firstImplements = false;\r
+                                               } else {\r
+                                                       output.Write (", ");\r
+                                               }\r
+                                               OutputType (typeRef);\r
                                        }\r
+                                       output.WriteLine ();\r
                                }\r
                        }\r
                }\r
 \r
                protected override void GenerateTypeEnd (CodeTypeDeclaration declaration)\r
                {\r
+                       if (IsCurrentDelegate) {\r
+                               return;\r
+                       }\r
                        string output = string.Empty;\r
 \r
                        --Indent;\r
@@ -1079,11 +1154,12 @@ namespace Microsoft.VisualBasic
                        case MemberAttributes.Overloaded:\r
                                // based on http://gendotnet.com/Code%20Gen%20Articles/codedom.htm\r
                                Output.Write ("Overloads ");\r
-                                MemberAttributes access_ovl = attributes & MemberAttributes.AccessMask;\r
-                                if ( access_ovl == MemberAttributes.Public || \r
-                                        access_ovl == MemberAttributes.Family )\r
-                                        Output.Write ("Overridable ");\r
-                                break;\r
+\r
+                               MemberAttributes access_ovl = attributes & MemberAttributes.AccessMask;\r
+                               if (access_ovl == MemberAttributes.Public || access_ovl == MemberAttributes.Family) {\r
+                                       Output.Write ("Overridable ");\r
+                               }\r
+                               break;\r
                        default:\r
                                //\r
                                // FUNNY! if the scope value is\r
@@ -1167,55 +1243,48 @@ namespace Microsoft.VisualBasic
                        }\r
                }\r
 \r
-               protected override void OutputTypeAttributes (TypeAttributes attributes, bool isStruct, bool isEnum)\r
+               private void OutputTypeAttributes (CodeTypeDeclaration declaration)\r
                {\r
                        TextWriter output = Output;\r
+                       TypeAttributes attributes = declaration.TypeAttributes;\r
 \r
                        switch (attributes & TypeAttributes.VisibilityMask) {\r
-                       case TypeAttributes.NotPublic:\r
-                               // Does this mean friend access?\r
-                               output.Write ("Friend ");\r
-                               break; \r
-\r
-                       case TypeAttributes.Public:\r
-                       case TypeAttributes.NestedPublic:\r
-                               output.Write ("Public ");\r
-                               break;\r
-\r
-                       case TypeAttributes.NestedPrivate:\r
-                               output.Write ("Private ");\r
-                               break;\r
-                       case TypeAttributes.NestedAssembly:\r
-                               output.Write ("Friend ");\r
-                               break;\r
-                       case TypeAttributes.NestedFamily:\r
-                               output.Write ("Protected ");\r
-                               break;\r
-                       case TypeAttributes.NestedFamORAssem:\r
-                               output.Write ("Protected Friend ");\r
-                               break;\r
-                       case TypeAttributes.NestedFamANDAssem:\r
-                               output.Write ("Friend ");\r
-                               break;\r
+                               case TypeAttributes.Public:\r
+                               case TypeAttributes.NestedPublic:\r
+                                       output.Write ("Public ");\r
+                                       break;\r
+                               case TypeAttributes.NestedPrivate:\r
+                                       output.Write ("Private ");\r
+                                       break;\r
+#if NET_2_0\r
+                               case TypeAttributes.NotPublic:\r
+                               case TypeAttributes.NestedFamANDAssem:\r
+                               case TypeAttributes.NestedAssembly:\r
+                                       output.Write ("Friend ");\r
+                                       break; \r
+                               case TypeAttributes.NestedFamily:\r
+                                       output.Write ("Protected ");\r
+                                       break;\r
+                               case TypeAttributes.NestedFamORAssem:\r
+                                       output.Write ("Protected Friend ");\r
+                                       break;\r
+#endif\r
                        }\r
 \r
-                       if (isStruct)\r
+                       if (declaration.IsStruct) {\r
                                output.Write ("Structure ");\r
-\r
-                       else if (isEnum)\r
-                               output.Write ("Enumeration ");\r
-\r
-                       else {\r
-                               if ((attributes & TypeAttributes.Interface) != 0) \r
+                       } else if (declaration.IsEnum) {\r
+                               output.Write ("Enum ");\r
+                       } else {\r
+                               if ((attributes & TypeAttributes.Interface) != 0) {\r
                                        output.Write ("Interface ");\r
-\r
-                               else {\r
+                               } else {\r
                                        if ((attributes & TypeAttributes.Sealed) != 0)\r
                                                output.Write ("NotInheritable ");\r
 \r
                                        if ((attributes & TypeAttributes.Abstract) != 0)\r
                                                output.Write ("MustInherit ");\r
-                                       \r
+\r
                                        output.Write ("Class ");\r
                                }\r
                        }\r
index 92953c929c822212200113b9aa4a3f000fc554ae..46783586ab962a6c56c98550640d309528945cf4 100644 (file)
@@ -1,3 +1,7 @@
+2005-07-24 Gert Driesen <drieseng@users.sourceforge.net>
+
+       * CodeGenerator.cs: Threat delegates like any other type.
+
 2005-07-21 Gert Driesen <drieseng@users.sourceforge.net>
 
        * CodeGenerator.cs: Fixed IsCurrentClass to return false for delegate.
index 935ea341f9ea2512eced8b70be9cdff46a710683..20301061431e9170c1cf0212c328c2ee3d03b1dc 100644 (file)
@@ -927,9 +927,6 @@ namespace System.CodeDom.Compiler {
                                break;
                        }
 
-                       if (!IsCurrentClass)
-                               OutputExtraTypeAttribute (currentType);
-
                        if (isStruct)
                                output.Write ("struct ");
 
@@ -946,16 +943,11 @@ namespace System.CodeDom.Compiler {
                                        if ((attributes & TypeAttributes.Abstract) != 0)
                                                output.Write ("abstract ");
                                        
-                                       OutputExtraTypeAttribute (currentType);
                                        output.Write ("class ");
                                }
                        }
                }
 
-               internal virtual void OutputExtraTypeAttribute (CodeTypeDeclaration type)
-               {
-               }
-               
                protected virtual void OutputTypeNamePair (CodeTypeReference type,
                                                           string name)
                {
@@ -1037,6 +1029,8 @@ namespace System.CodeDom.Compiler {
 
                private void GenerateType (CodeTypeDeclaration type)
                {
+                       this.currentType = type;
+
 #if NET_2_0
                        if (type.StartDirectives.Count > 0)
                                GenerateDirectives (type.StartDirectives);
@@ -1047,56 +1041,27 @@ namespace System.CodeDom.Compiler {
                        if (type.LinePragma != null)
                                GenerateLinePragmaStart (type.LinePragma);
 
-                       CodeTypeDelegate del = type as CodeTypeDelegate;
-                       if (del != null)
-                               GenerateDelegate (del);
-                       else
-                               GenerateNonDelegateType (type);
-
-                       if (type.LinePragma != null)
-                               GenerateLinePragmaEnd (type.LinePragma);
-
-#if NET_2_0
-                       if (type.EndDirectives.Count > 0)
-                               GenerateDirectives (type.EndDirectives);
-#endif
-               }
-
-               private void GenerateDelegate (CodeTypeDelegate type)
-               {
-                       this.currentType = type;
-
-                       GenerateTypeStart (type);
-                       OutputParameters (type.Parameters);
-                       GenerateTypeEnd (type);
-               }
-               
-               private void GenerateNonDelegateType (CodeTypeDeclaration type)
-               {
-                       this.currentType = type;
-
                        GenerateTypeStart (type);
 
-                       CodeTypeMember [] members = new CodeTypeMember [type.Members.Count];
+                       CodeTypeMember[] members = new CodeTypeMember[type.Members.Count];
                        type.Members.CopyTo (members, 0);
 
 #if NET_2_0
                        if (!Options.VerbatimOrder)
 #endif
                      {
+ {
                                int[] order = new int[members.Length];
-                               for (int n=0; n<members.Length; n++)
-                                       order[n] = Array.IndexOf(memberTypes, members[n].GetType()) * members.Length + n;
+                               for (int n = 0; n < members.Length; n++)
+                                       order[n] = Array.IndexOf (memberTypes, members[n].GetType ()) * members.Length + n;
 
                                Array.Sort (order, members);
                        }
-                       
+
                        // WARNING: if anything is missing in the foreach loop and you add it, add the type in
                        // its corresponding place in CodeTypeMemberComparer class (below)
 
                        CodeTypeDeclaration subtype = null;
-                       foreach (CodeTypeMember member in members) 
-                       {
+                       foreach (CodeTypeMember member in members) {
                                CodeTypeMember prevMember = this.currentMember;
                                this.currentMember = member;
 
@@ -1130,54 +1095,46 @@ namespace System.CodeDom.Compiler {
                                        GenerateLinePragmaStart (member.LinePragma);
 
                                CodeMemberEvent eventm = member as CodeMemberEvent;
-                               if (eventm != null) 
-                               {
+                               if (eventm != null) {
                                        GenerateEvent (eventm, type);
                                        continue;
                                }
                                CodeMemberField field = member as CodeMemberField;
-                               if (field != null) 
-                               {
+                               if (field != null) {
                                        GenerateField (field);
                                        continue;
                                }
                                CodeEntryPointMethod epmethod = member as CodeEntryPointMethod;
-                               if (epmethod != null) 
-                               {
+                               if (epmethod != null) {
                                        GenerateEntryPointMethod (epmethod, type);
                                        continue;
                                }
                                CodeTypeConstructor typeCtor = member as CodeTypeConstructor;
-                               if (typeCtor != null) 
-                               {
+                               if (typeCtor != null) {
                                        GenerateTypeConstructor (typeCtor);
                                        continue;
                                }
                                CodeConstructor ctor = member as CodeConstructor;
-                               if (ctor != null) 
-                               {
+                               if (ctor != null) {
                                        GenerateConstructor (ctor, type);
                                        continue;
                                }
                                CodeMemberMethod method = member as CodeMemberMethod;
-                               if (method != null) 
-                               {
+                               if (method != null) {
                                        GenerateMethod (method, type);
                                        continue;
                                }
                                CodeMemberProperty property = member as CodeMemberProperty;
-                               if (property != null) 
-                               {
+                               if (property != null) {
                                        GenerateProperty (property, type);
                                        continue;
                                }
                                CodeSnippetTypeMember snippet = member as CodeSnippetTypeMember;
-                               if (snippet != null) 
-                               {
+                               if (snippet != null) {
                                        GenerateSnippetMember (snippet);
                                        continue;
                                }
-                               
+
                                this.currentMember = prevMember;
                        }
 
@@ -1190,8 +1147,17 @@ namespace System.CodeDom.Compiler {
                                        GenerateDirectives (currentMember.EndDirectives);
 #endif
                        }
+
                        this.currentType = type;
                        GenerateTypeEnd (type);
+
+                       if (type.LinePragma != null)
+                               GenerateLinePragmaEnd (type.LinePragma);
+
+#if NET_2_0
+                       if (type.EndDirectives.Count > 0)
+                               GenerateDirectives (type.EndDirectives);
+#endif
                }
 
                protected abstract string GetTypeOutput (CodeTypeReference type);
index a5605bc8379067ddc512c0c5777a57144c9cdb3e..9c5de3a1b1e501d5167ca7f7ef210c75ff861deb 100644 (file)
@@ -1,3 +1,9 @@
+2005-07-24 Gert Driesen <drieseng@users.sourceforge.net>
+
+       * CodeTypeReference.cs: Added internal IsInterface property.
+       * CodeTypeDelegate.cs: System.Delegate is base type, and make sure 
+       ReturnType is initialized.
+
 2005-06-28 Gert Driesen <drieseng@users.sourceforge.net>
 
        * CodeTypeReference.cs: Also consider null type name as void, throw
index 63a8b313df2a89270bf646ae96d6e542f1a6ec7d..dab98d148001162d4eaf0c0799c70f8692f18e9c 100644 (file)
@@ -35,10 +35,9 @@ namespace System.CodeDom
        [Serializable]
        [ClassInterface(ClassInterfaceType.AutoDispatch)]
        [ComVisible(true)]
-       public class CodeTypeDelegate
-               : CodeTypeDeclaration
+       public class CodeTypeDelegate : CodeTypeDeclaration
        {
-               private CodeParameterDeclarationExpressionCollection parameters;
+               private CodeParameterDeclarationExpressionCollection parameters;
                private CodeTypeReference returnType;
 
                //
@@ -46,9 +45,10 @@ namespace System.CodeDom
                //
                public CodeTypeDelegate()
                {
+                       base.BaseTypes.Add (new CodeTypeReference ("System.Delegate"));
                }
 
-               public CodeTypeDelegate( string name )
+               public CodeTypeDelegate(string name) : this()
                {
                        this.Name = name;
                }
@@ -58,14 +58,18 @@ namespace System.CodeDom
                //
                public CodeParameterDeclarationExpressionCollection Parameters {
                        get {
-                               if ( parameters == null )
-                                       parameters = new CodeParameterDeclarationExpressionCollection();
+                               if (parameters == null) {
+                                       parameters = new CodeParameterDeclarationExpressionCollection ();
+                               }
                                return parameters;
                        }
                }
 
                public CodeTypeReference ReturnType {
                        get {
+                               if (returnType == null) {
+                                       this.returnType = new CodeTypeReference(string.Empty);
+                               }
                                return returnType;
                        }
                        set {
index 7f70be2cb11ff6b8780143e7bd129a45e7cf99be..f76e0c1751d3a756f36c1ade78192d6f365781fd 100644 (file)
@@ -41,7 +41,8 @@ namespace System.CodeDom
        {
                private string baseType;
                private CodeTypeReference arrayType;
-               private int rank;
+               private int rank;\r
+               private bool isInterface;
 
 #if NET_2_0
                CodeTypeReferenceCollection typeArguments;
@@ -83,14 +84,15 @@ namespace System.CodeDom
                        if (baseType == null) {
                                throw new ArgumentNullException ("baseType");
                        }
-#endif
-                       if (baseType.IsArray) {
-                               this.rank = baseType.GetArrayRank ();
-                               this.arrayType = new CodeTypeReference (baseType.GetElementType ());
-                               this.baseType = arrayType.BaseType;
-                               return;
-                       }
-                       this.baseType = baseType.FullName;
+#endif\r
+                       if (baseType.IsArray) {\r
+                               this.rank = baseType.GetArrayRank ();\r
+                               this.arrayType = new CodeTypeReference (baseType.GetElementType ());\r
+                               this.baseType = arrayType.BaseType;\r
+                       } else {\r
+                               this.baseType = baseType.FullName;\r
+                       }\r
+                       this.isInterface = baseType.IsInterface;
                }
 
                public CodeTypeReference( CodeTypeReference arrayType, int rank )
@@ -163,6 +165,10 @@ namespace System.CodeDom
                        set {
                                baseType = value;
                        }
+               }\r
+\r
+               internal bool IsInterface {\r
+                       get { return isInterface; }\r
                }
 
 #if NET_2_0
index 824b999ccfa6fc34b003e421cff4755bf72a060e..a291149b069a2d4a9b4e1edcae59f1b3140aefd5 100644 (file)
@@ -16,6 +16,7 @@ System/UriTest.cs
 System/UriTest2.cs
 System.CodeDom/CodeMemberFieldTest.cs
 System.CodeDom/CodeMemberPropertyTest.cs
+System.CodeDom/CodeTypeDelegateTest.cs
 System.CodeDom/CodeTypeReferenceTest.cs
 System.CodeDom.Compiler/CodeGeneratorFromTypeTestBase.cs
 System.CodeDom.Compiler/CodeGeneratorTest.cs
index d82a62dd080e5e75fa6d1cf82fb68557a4d2ed36..f33cb8bebefc59db319717368aeee3f7ddf20ac2 100644 (file)
@@ -1,3 +1,8 @@
+2005-07-24  Gert Driesen <drieseng@users.sourceforge.net>
+
+       * CodeGeneratorFromTypeTest.cs: Added BaseTypes and TypeConstructor
+       tests. Added enum, interface and delegate tests.
+
 2005-07-02  Gert Driesen <drieseng@users.sourceforge.net>
 
        * CodeGeneratorFromTypeTest.cs: Added test for 
index 9fe64a5ffb9d741217911bdc26560cb459bc7ea6..18ee007f04f3512a87facee87fc177c44fc86d25 100644 (file)
 // Microsoft.CSharp.* Test Cases
 //
 // Authors:
-//     Erik LeBel (eriklebel@yahoo.ca)
+// Eric Lebel (ericlebel@yahoo.ca)
+// Gert Driesen (drieseng@users.sourceforge.net)
 //
-// (c) 2003 Erik LeBel
+// (c) Novell
 //
+
 using System;
-using System.Globalization;
-using System.Text;
 using System.CodeDom;
 using System.CodeDom.Compiler;
+using System.Globalization;
+
+using Microsoft.CSharp;
 
 using NUnit.Framework;
 
+using MonoTests.System.CodeDom.Compiler;
+
 namespace MonoTests.Microsoft.CSharp
 {
-       ///
-       /// <summary>
-       ///     Test ICodeGenerator's GenerateCodeFromType, along with a 
-       ///     minimal set CodeDom components.
-       /// </summary>
-       ///
        [TestFixture]
-       public class CodeGeneratorFromTypeTest: CodeGeneratorTestBase
+       public class CodeGeneratorFromTypeTest_Class : CodeGeneratorFromTypeTestBase
        {
-               CodeTypeDeclaration type = null;
+               private CodeTypeDeclaration _typeDeclaration;
+               private ICodeGenerator _codeGenerator;
+
+               #region Override implementation of CodeGeneratorTestBase
+
+               protected override ICodeGenerator CodeGenerator
+               {
+                       get { return _codeGenerator; }
+               }
 
                [SetUp]
-               public void Init ()
+               public override void SetUp ()
                {
-                       InitBase ();
-                       type = new CodeTypeDeclaration ();
+                       base.SetUp ();
+                       _typeDeclaration = new CodeTypeDeclaration ();
+
+                       CodeDomProvider provider = new CSharpCodeProvider ();
+                       _codeGenerator = provider.CreateGenerator ();
                }
-               
-               protected override void Generate ()
+
+               #endregion Override implementation of CodeGeneratorTestBase
+
+               #region Override implementation of CodeGeneratorFromTypeTestBase
+
+               protected override CodeTypeDeclaration TypeDeclaration
                {
-                       generator.GenerateCodeFromType (type, writer, options);
-                       writer.Close ();
+                       get { return _typeDeclaration; }
                }
-               
+
                [Test]
-               public void DefaultTypeTest ()
+               public override void DefaultTypeTest ()
                {
-                       Generate ();
-                       Assert.AreEqual ("public class  {\n}\n", Code);
+                       string code = GenerateDefaultType ();
+                       Assert.AreEqual (string.Format (CultureInfo.InvariantCulture,
+                               "public class  {{{0}" +
+                               "}}{0}", Writer.NewLine), code);
                }
 
                [Test]
                [ExpectedException (typeof (NullReferenceException))]
-               public void NullTypeTest ()
+               public override void NullTypeTest ()
                {
-                       type = null;
-                       Generate ();
+                       GenerateNullType ();
                }
 
                [Test]
-               public void SimpleTypeTest ()
+               public override void SimpleTypeTest ()
                {
-                       type.Name = "Test1";
-                       Generate ();
+                       string code = GenerateSimpleType ();
                        Assert.AreEqual (string.Format (CultureInfo.InvariantCulture,
-                               "public class Test1 {{{0}}}{0}", writer.NewLine), Code);
+                               "public class Test1 {{{0}" +
+                               "}}{0}", Writer.NewLine), code);
                }
 
                [Test]
-               public void AttributesAndTypeTest ()
+               public override void DerivedTypeTest ()
                {
-                       type.Name = "Test1";
-
-                       CodeAttributeDeclaration attrDec = new CodeAttributeDeclaration ();
-                       attrDec.Name = "A";
-                       type.CustomAttributes.Add (attrDec);
-
-                       attrDec = new CodeAttributeDeclaration ();
-                       attrDec.Name = "B";
-                       type.CustomAttributes.Add (attrDec);
-
-                       Generate ();
+                       string code = GenerateDerivedType ();
                        Assert.AreEqual (string.Format (CultureInfo.InvariantCulture,
-                               "[A()]{0}"
-                               + "[B()]{0}"
-                               + "public class Test1 {{{0}"
-                               + "}}{0}", writer.NewLine), Code);
+#if NET_2_0
+                               "internal abstract class Test1 : int, System.Security.Principal.IIdentity, string, System.Security.IPermission {{{0}" +
+#else
+                               "abstract class Test1 : int, System.Security.Principal.IIdentity, string, System.Security.IPermission {{{0}" +
+#endif
+                               "}}{0}", Writer.NewLine), code);
                }
 
                [Test]
-               public void EventMembersTypeTest1 ()
+               public override void AttributesAndTypeTest ()
                {
-                       type.Name = "Test1";
-
-                       CodeMemberEvent evt = new CodeMemberEvent ();
-
-                       CodeAttributeDeclaration attrDec = new CodeAttributeDeclaration ();
-                       attrDec.Name = "A";
-                       evt.CustomAttributes.Add (attrDec);
-
-                       attrDec = new CodeAttributeDeclaration ();
-                       attrDec.Name = "B";
-                       evt.CustomAttributes.Add (attrDec);
-
-                       type.Members.Add (evt);
-
-                       Generate ();
+                       string code = GenerateAttributesAndType ();
                        Assert.AreEqual (string.Format (CultureInfo.InvariantCulture,
-                               "public class Test1 {{{0}"
-                               + "    {0}"
-                               + "    [A()]{0}"
-                               + "    [B()]{0}"
-                               + "    private event void ;{0}"
-                               + "}}{0}", writer.NewLine), Code);
+                               "[A()]{0}" +
+                               "[B()]{0}" +
+                               "public class Test1 {{{0}" +
+                               "}}{0}", Writer.NewLine), code);
                }
 
                [Test]
-               public void EventMembersTypeTest2 ()
+               public override void EventMembersTypeTest1 ()
                {
-                       type.Name = "Test1";
-
-                       CodeMemberEvent evt = new CodeMemberEvent ();
-                       evt.Name = "OnClick";
-                       evt.Attributes = MemberAttributes.Public | MemberAttributes.Override
-                               | MemberAttributes.Static | MemberAttributes.Abstract |
-                               MemberAttributes.New;
-                       evt.Type = new CodeTypeReference (typeof (int));
-                       // C# does not support Implementation Types, so this should be ignored
-                       evt.ImplementationTypes.Add (new CodeTypeReference ("IPolicy"));
-                       type.Members.Add (evt);
+                       string code = GenerateEventMembersType1 ();
+                       Assert.AreEqual (string.Format (CultureInfo.InvariantCulture,
+                               "public class Test1 {{{0}" +
+                               "    {0}" +
+                               "    [A()]{0}" +
+                               "    [B()]{0}" +
+                               "    private event void ;{0}" +
+                               "}}{0}", Writer.NewLine), code);
+               }
 
-                       Generate ();
+               [Test]
+               public override void EventMembersTypeTest2 ()
+               {       
+                       string code = GenerateEventMembersType2 ();
                        Assert.AreEqual (string.Format (CultureInfo.InvariantCulture,
-                               "public class Test1 {{{0}"
-                               + "    {0}"
-                               + "    public event int OnClick;{0}"
-                               + "}}{0}", writer.NewLine), Code);
+                               "public class Test1 {{{0}" +
+                               "    {0}" +
+                               "    public event int Click;{0}" +
+                               "}}{0}", Writer.NewLine), code);
                }
 
                [Test]
-               public void EventImplementationTypes ()
+               public override void EventImplementationTypes ()
                {
-                       type.Name = "Test1";
-
-                       CodeMemberEvent evt = new CodeMemberEvent ();
-                       evt.Name = "Click";
-                       evt.Attributes = MemberAttributes.FamilyAndAssembly;
-                       evt.Type = new CodeTypeReference (typeof (int));
-                       evt.ImplementationTypes.Add (new CodeTypeReference ("IPolicy"));
-                       evt.ImplementationTypes.Add (new CodeTypeReference ("IWhatever"));
-                       type.Members.Add (evt);
-
-                       Generate ();
+                       string code = GenerateEventImplementationTypes ();
                        Assert.AreEqual (string.Format (CultureInfo.InvariantCulture,
-                               "public class Test1 {{{0}"
-                               + "    {0}"
+                               "public class Test1 {{{0}" +
+                               "    {0}" +
 #if NET_2_0
-                               + "    internal event int Click;{0}"
+                               "    internal event int Click;{0}" +
 #else
-                               + "    /*FamANDAssem*/ internal event int Click;{0}"
+                               "    /*FamANDAssem*/ internal event int Click;{0}" +
 #endif
-                               + "}}{0}", writer.NewLine), Code);
+                               "}}{0}", Writer.NewLine), code);
                }
 
                /// <summary>
@@ -165,778 +146,431 @@ namespace MonoTests.Microsoft.CSharp
                /// is set.
                /// </summary>
                [Test]
-               public void EventPrivateImplementationType ()
+               public override void EventPrivateImplementationType ()
                {
-                       type.Name = "Test1";
-
-                       CodeMemberEvent evt = new CodeMemberEvent ();
-                       evt.Name = "Click";
-                       evt.Attributes = MemberAttributes.Family | MemberAttributes.Overloaded;
-                       evt.Type = new CodeTypeReference (typeof (int));
-                       evt.PrivateImplementationType = new CodeTypeReference (typeof (int));
-                       type.Members.Add (evt);
-
-                       Generate ();
+                       string code = GenerateEventPrivateImplementationType ();
                        Assert.AreEqual (string.Format (CultureInfo.InvariantCulture,
-                               "public class Test1 {{{0}"
-                               + "    {0}"
-                               + "    event int System.Int32.Click;{0}"
-                               + "}}{0}", writer.NewLine), Code);
+                               "public class Test1 {{{0}" +
+                               "    {0}" +
+                               "    event int System.Int32.Click;{0}" +
+                               "}}{0}", Writer.NewLine), code);
                }
 
+               /// <summary>
+               /// If both ImplementationTypes and PrivateImplementationType are set,
+               /// then only ImplementationTypes are output.
+               /// </summary>
                [Test]
-               public void EventImplementationTypeOrder ()
+               public override void EventImplementationTypeOrder ()
                {
-                       type.Name = "Test1";
-
-                       CodeMemberEvent evt = new CodeMemberEvent ();
-                       evt.Name = "Click";
-                       evt.Attributes = MemberAttributes.Public | MemberAttributes.Overloaded;
-                       evt.Type = new CodeTypeReference (typeof (int));
-                       evt.PrivateImplementationType = new CodeTypeReference (typeof (int));
-                       evt.ImplementationTypes.Add (new CodeTypeReference ("IPolicy"));
-                       type.Members.Add (evt);
-
-                       Generate ();
+                       string code = GenerateEventImplementationTypeOrder ();
                        Assert.AreEqual (string.Format (CultureInfo.InvariantCulture,
-                               "public class Test1 {{{0}"
-                               + "    {0}"
-                               + "    event int System.Int32.Click;{0}"
-                               + "}}{0}", writer.NewLine), Code);
+                               "public class Test1 {{{0}" +
+                               "    {0}" +
+                               "    event int System.Int32.Click;{0}" +
+                               "}}{0}", Writer.NewLine), code);
                }
 
                [Test]
-               public void FieldMembersTypeTest1 ()
+               public override void FieldMembersTypeTest1 ()
                {
-                       type.Name = "Test1";
-
-                       CodeMemberField fld = new CodeMemberField ();
-
-                       CodeAttributeDeclaration attrDec = new CodeAttributeDeclaration ();
-                       attrDec.Name = "A";
-                       fld.CustomAttributes.Add (attrDec);
-
-                       attrDec = new CodeAttributeDeclaration ();
-                       attrDec.Name = "B";
-                       fld.CustomAttributes.Add (attrDec);
-
-                       type.Members.Add (fld);
-
-                       Generate ();
+                       string code = GenerateFieldMembersType1 ();
                        Assert.AreEqual (string.Format (CultureInfo.InvariantCulture,
-                               "public class Test1 {{{0}"
-                               + "    {0}"
-                               + "    [A()]{0}"
-                               + "    [B()]{0}"
-                               + "    private void ;{0}"
-                               + "}}{0}", writer.NewLine), Code);
+                               "public class Test1 {{{0}" +
+                               "    {0}" +
+                               "    [A()]{0}" +
+                               "    [B()]{0}" +
+                               "    private void ;{0}" +
+                               "}}{0}", Writer.NewLine), code);
                }
 
                [Test]
-               public void FieldMembersTypeTest2 ()
+               public override void FieldMembersTypeTest2 ()
                {
-                       type.Name = "Test1";
-
-                       CodeMemberField fld = new CodeMemberField ();
-                       fld.Name = "Name";
-                       fld.Attributes = MemberAttributes.Public;
-                       fld.Type = new CodeTypeReference (typeof (int));
-                       type.Members.Add (fld);
-
-                       Generate ();
+                       string code = GenerateFieldMembersType2 ();
                        Assert.AreEqual (string.Format (CultureInfo.InvariantCulture,
-                               "public class Test1 {{{0}"
-                               + "    {0}"
-                               + "    public int Name;{0}"
-                               + "}}{0}", writer.NewLine), Code);
+                               "public class Test1 {{{0}" +
+                               "    {0}" +
+                               "    public int Name = 2;{0}" +
+                               "}}{0}", Writer.NewLine), code);
                }
 
                [Test]
-               public void PropertyMembersTypeTest1 ()
+               public override void PropertyMembersTypeTest1 ()
                {
-                       type.Name = "Test1";
-
-                       CodeMemberProperty property = new CodeMemberProperty ();
-
-                       CodeAttributeDeclaration attrDec = new CodeAttributeDeclaration ();
-                       attrDec.Name = "A";
-                       property.CustomAttributes.Add (attrDec);
-
-                       attrDec = new CodeAttributeDeclaration ();
-                       attrDec.Name = "B";
-                       property.CustomAttributes.Add (attrDec);
-
-                       type.Members.Add (property);
-
-                       Generate ();
+                       string code = GeneratePropertyMembersAttributes ();
                        Assert.AreEqual (string.Format (CultureInfo.InvariantCulture,
-                               "public class Test1 {{{0}"
-                               + "    {0}"
-                               + "    [A()]{0}"
-                               + "    [B()]{0}"
-                               + "    private void  {{{0}"
-                               + "    }}{0}"
-                               + "}}{0}", writer.NewLine), Code);
+                               "public class Test1 {{{0}" +
+                               "    {0}" +
+                               "    [A()]{0}" +
+                               "    [B()]{0}" +
+                               "    private void  {{{0}" +
+                               "    }}{0}" +
+                               "}}{0}", Writer.NewLine), code);
                }
 
                [Test]
-               public void PropertyMembersTypeTest2 ()
+               public override void PropertyMembersTypeTest2 ()
                {
-                       type.Name = "Test1";
-
-                       CodeMemberProperty property = new CodeMemberProperty ();
-                       property.Name = "Name";
-                       property.Attributes = MemberAttributes.Public;
-                       property.Type = new CodeTypeReference (typeof (int));
-                       // C# does not support Implementation Types, so this should be ignored
-                       property.ImplementationTypes.Add (new CodeTypeReference ("IPolicy"));
-                       type.Members.Add (property);
-
-                       Generate ();
+                       string code = GeneratePropertyMembersType (MemberAttributes.Public,
+                               false, false);
                        Assert.AreEqual (string.Format (CultureInfo.InvariantCulture,
-                               "public class Test1 {{{0}"
-                               + "    {0}"
-                               + "    public virtual int Name {{{0}"
-                               + "    }}{0}"
-                               + "}}{0}", writer.NewLine), Code);
+                               "public class Test1 {{{0}" +
+                               "    {0}" +
+                               "    public virtual int Name {{{0}" +
+                               "    }}{0}" +
+                               "}}{0}", Writer.NewLine), code);
                }
 
                [Test]
-               public void PropertyMembersTypeGetOnly ()
+               public override void PropertyMembersTypeGetOnly ()
                {
-                       type.Name = "Test1";
-
-                       CodeMemberProperty property = new CodeMemberProperty ();
-                       property.Name = "Name";
-                       property.Attributes = MemberAttributes.Family;
-                       property.HasGet = true;
-                       property.Type = new CodeTypeReference (typeof (int));
-                       type.Members.Add (property);
-
-                       Generate ();
+                       string code = GeneratePropertyMembersType (MemberAttributes.Family,
+                               true, false);
                        Assert.AreEqual (string.Format (CultureInfo.InvariantCulture,
-                               "public class Test1 {{{0}"
-                               + "    {0}"
-                               + "    protected virtual int Name {{{0}"
-                               + "        get {{{0}"
-                               + "        }}{0}"
-                               + "    }}{0}"
-                               + "}}{0}", writer.NewLine), Code);
+                               "public class Test1 {{{0}" +
+                               "    {0}" +
+                               "    protected virtual int Name {{{0}" +
+                               "        get {{{0}" +
+                               "        }}{0}" +
+                               "    }}{0}" +
+                               "}}{0}", Writer.NewLine), code);
                }
 
                [Test]
-               public void PropertyMembersTypeSetOnly ()
+               public override void PropertyMembersTypeSetOnly ()
                {
-                       type.Name = "Test1";
-
-                       CodeMemberProperty property = new CodeMemberProperty ();
-                       property.Name = "Name";
-                       property.Attributes = MemberAttributes.FamilyOrAssembly;
-                       property.HasSet = true;
-                       property.Type = new CodeTypeReference (typeof (int));
-                       type.Members.Add (property);
-
-                       Generate ();
+                       string code = GeneratePropertyMembersType (MemberAttributes.Assembly,
+                               false, true);
                        Assert.AreEqual (string.Format (CultureInfo.InvariantCulture,
-                               "public class Test1 {{{0}"
-                               + "    {0}"
-                               + "    protected internal int Name {{{0}"
-                               + "        set {{{0}"
-                               + "        }}{0}"
-                               + "    }}{0}"
-                               + "}}{0}", writer.NewLine), Code);
+                               "public class Test1 {{{0}" +
+                               "    {0}" +
+#if NET_2_0
+                               "    internal virtual int Name {{{0}" +
+#else
+                               "    internal int Name {{{0}" +
+#endif
+                               "        set {{{0}" +
+                               "        }}{0}" +
+                               "    }}{0}" +
+                               "}}{0}", Writer.NewLine), code);
                }
 
                [Test]
-               public void PropertyMembersTypeGetSet ()
+               public override void PropertyMembersTypeGetSet ()
                {
-                       type.Name = "Test1";
-
-                       CodeMemberProperty property = new CodeMemberProperty ();
-                       property.Name = "Name";
-                       property.Attributes = MemberAttributes.Assembly;
-                       property.HasGet = true;
-                       property.HasSet = true;
-                       property.Type = new CodeTypeReference (typeof (int));
-                       type.Members.Add (property);
-
-                       Generate ();
+                       string code = GeneratePropertyMembersType (MemberAttributes.Family,
+                               true, true);
                        Assert.AreEqual (string.Format (CultureInfo.InvariantCulture,
-                               "public class Test1 {{{0}"
-                               + "    {0}"
-#if NET_2_0
-                               + "    internal virtual int Name {{{0}"
-#else
-                               + "    internal int Name {{{0}"
-#endif
-                               + "        get {{{0}"
-                               + "        }}{0}"
-                               + "        set {{{0}"
-                               + "        }}{0}"
-                               + "    }}{0}"
-                               + "}}{0}", writer.NewLine), Code);
+                               "public class Test1 {{{0}" +
+                               "    {0}" +
+                               "    protected virtual int Name {{{0}" +
+                               "        get {{{0}" +
+                               "        }}{0}" +
+                               "        set {{{0}" +
+                               "        }}{0}" +
+                               "    }}{0}" +
+                               "}}{0}", Writer.NewLine), code);
                }
 
                [Test]
-               public void PropertyMembersTypeFamilyAndAssembly ()
+               public override void PropertyMembersTypeFamilyOrAssembly ()
                {
-                       type.Name = "Test1";
-
-                       CodeMemberProperty property = new CodeMemberProperty ();
-                       property.Name = "Name";
-                       property.Attributes = MemberAttributes.FamilyAndAssembly;
-                       property.Type = new CodeTypeReference (typeof (int));
-
-                       type.Members.Add (property);
+                       string code = GeneratePropertyMembersType (MemberAttributes.FamilyOrAssembly,
+                               false, false);
+                       Assert.AreEqual (string.Format (CultureInfo.InvariantCulture,
+                               "public class Test1 {{{0}" +
+                               "    {0}" +
+                               "    protected internal int Name {{{0}" +
+                               "    }}{0}" +
+                               "}}{0}", Writer.NewLine), code);
+               }
 
-                       Generate ();
+               [Test]
+               public override void PropertyMembersTypeAssembly ()
+               {
+                       string code = GeneratePropertyMembersType (MemberAttributes.Assembly,
+                               false, false);
                        Assert.AreEqual (string.Format (CultureInfo.InvariantCulture,
-                               "public class Test1 {{{0}"
-                               + "    {0}"
+                               "public class Test1 {{{0}" +
+                               "    {0}" +
 #if NET_2_0
-                               + "    internal int Name {{{0}"
+                               "    internal virtual int Name {{{0}" +
 #else
-                               + "    /*FamANDAssem*/ internal int Name {{{0}"
+                               "    internal int Name {{{0}" +
 #endif
-                               + "    }}{0}"
-                               + "}}{0}", writer.NewLine), Code);
+                               "    }}{0}" +
+                               "}}{0}", Writer.NewLine), code);
                }
 
                /// <summary>
-               /// C# CodeDOM does not output parameters for properties that aren't
-               /// indexers.
+               /// Apparently VB.NET CodeDOM also allows properties that aren't indexers
+               /// to have parameters.
                /// </summary>
                [Test]
-               public void PropertyParametersTest ()
+               public override void PropertyParametersTest ()
                {
-                       type.Name = "Test1";
-
-                       CodeMemberProperty property = new CodeMemberProperty ();
-                       property.Name = "Name";
-                       property.Attributes = MemberAttributes.Public;
-                       property.Type = new CodeTypeReference (typeof (int));
-
-                       CodeParameterDeclarationExpression param = new CodeParameterDeclarationExpression (
-                               typeof (object), "value1");
-                       property.Parameters.Add (param);
-
-                       param = new CodeParameterDeclarationExpression (
-                               typeof (int), "value2");
-                       param.Direction = FieldDirection.Ref;
-                       property.Parameters.Add (param);
-
-                       type.Members.Add (property);
-
-                       Generate ();
+                       string code = GeneratePropertyParameters ();
                        Assert.AreEqual (string.Format (CultureInfo.InvariantCulture,
-                               "public class Test1 {{{0}"
-                               + "    {0}"
-                               + "    public virtual int Name {{{0}"
-                               + "    }}{0}"
-                               + "}}{0}", writer.NewLine), Code);
+                               "public class Test1 {{{0}" +
+                               "    {0}" +
+                               "    public virtual int Name {{{0}" +
+                               "    }}{0}" +
+                               "}}{0}", Writer.NewLine), code);
                }
 
                [Test]
-               public void PropertyIndexerTest1 ()
+               public override void PropertyIndexerTest1 ()
                {
-                       type.Name = "Test1";
-
-                       CodeMemberProperty property = new CodeMemberProperty ();
-                       // ensure case-insensitive comparison is done on name of property
-                       property.Name = "iTem";
-                       property.Attributes = MemberAttributes.Public;
-                       property.Type = new CodeTypeReference (typeof (int));
-
-                       CodeParameterDeclarationExpression param = new CodeParameterDeclarationExpression (
-                               typeof (object), "value1");
-                       property.Parameters.Add (param);
-
-                       param = new CodeParameterDeclarationExpression (
-                               typeof (int), "value2");
-                       param.Direction = FieldDirection.Ref;
-                       property.Parameters.Add (param);
-
-                       type.Members.Add (property);
-
-                       Generate ();
+                       string code = GeneratePropertyIndexer (MemberAttributes.Public,
+                               false, false, true);
                        Assert.AreEqual (string.Format (CultureInfo.InvariantCulture,
-                               "public class Test1 {{{0}"
-                               + "    {0}"
-                               + "    public virtual int this[object value1, ref int value2] {{{0}"
-                               + "    }}{0}"
-                               + "}}{0}", writer.NewLine), Code);
+                               "public class Test1 {{{0}" +
+                               "    {0}" +
+                               "    public virtual int this[object value1, ref int value2] {{{0}" +
+                               "    }}{0}" +
+                               "}}{0}", Writer.NewLine), code);
                }
 
-               /// <summary>
-               /// Ensures indexer code is only output if property is named "Item"
-               /// (case-insensitive comparison) AND parameters are defined.
-               /// </summary>
                [Test]
-               public void PropertyIndexerTest2 ()
+               public override void PropertyIndexerTest2 ()
                {
-                       type.Name = "Test1";
-
-                       CodeMemberProperty property = new CodeMemberProperty ();
-                       // ensure case-insensitive comparison is done on name of property
-                       property.Name = "iTem";
-                       property.Attributes = MemberAttributes.Public;
-                       property.Type = new CodeTypeReference (typeof (int));
-                       type.Members.Add (property);
-
-                       Generate ();
+                       string code = GeneratePropertyIndexer (MemberAttributes.Public,
+                               false, false, false);
                        Assert.AreEqual (string.Format (CultureInfo.InvariantCulture,
-                               "public class Test1 {{{0}"
-                               + "    {0}"
-                               + "    public virtual int iTem {{{0}"
-                               + "    }}{0}"
-                               + "}}{0}", writer.NewLine), Code);
+                               "public class Test1 {{{0}" +
+                               "    {0}" +
+                               "    public virtual int iTem {{{0}" +
+                               "    }}{0}" +
+                               "}}{0}", Writer.NewLine), code);
                }
 
                [Test]
-               public void PropertyIndexerGetOnly ()
+               public override void PropertyIndexerGetOnly ()
                {
-                       type.Name = "Test1";
-
-                       CodeMemberProperty property = new CodeMemberProperty ();
-                       // ensure case-insensitive comparison is done on name of property
-                       property.Name = "iTem";
-                       property.Attributes = MemberAttributes.Family;
-                       property.HasGet = true;
-                       property.Type = new CodeTypeReference (typeof (int));
-
-                       CodeParameterDeclarationExpression param = new CodeParameterDeclarationExpression (
-                               typeof (object), "value1");
-                       property.Parameters.Add (param);
-
-                       type.Members.Add (property);
-
-                       Generate ();
+                       string code = GeneratePropertyIndexer (MemberAttributes.Family,
+                               true, false, true);
                        Assert.AreEqual (string.Format (CultureInfo.InvariantCulture,
-                               "public class Test1 {{{0}"
-                               + "    {0}"
-                               + "    protected virtual int this[object value1] {{{0}"
-                               + "        get {{{0}"
-                               + "        }}{0}"
-                               + "    }}{0}"
-                               + "}}{0}", writer.NewLine), Code);
+                               "public class Test1 {{{0}" +
+                               "    {0}" +
+                               "    protected virtual int this[object value1, ref int value2] {{{0}" +
+                               "        get {{{0}" +
+                               "        }}{0}" +
+                               "    }}{0}" +
+                               "}}{0}", Writer.NewLine), code);
                }
 
                [Test]
-               public void PropertyIndexerSetOnly ()
+               public override void PropertyIndexerSetOnly ()
                {
-                       type.Name = "Test1";
-
-                       CodeMemberProperty property = new CodeMemberProperty ();
-                       // ensure case-insensitive comparison is done on name of property
-                       property.Name = "iTem";
-                       property.Attributes = MemberAttributes.Family;
-                       property.HasSet = true;
-                       property.Type = new CodeTypeReference (typeof (int));
-
-                       CodeParameterDeclarationExpression param = new CodeParameterDeclarationExpression (
-                               typeof (object), "value1");
-                       property.Parameters.Add (param);
-
-                       type.Members.Add (property);
-
-                       Generate ();
+                       string code = GeneratePropertyIndexer (MemberAttributes.Family,
+                               false, true, true);
                        Assert.AreEqual (string.Format (CultureInfo.InvariantCulture,
-                               "public class Test1 {{{0}"
-                               + "    {0}"
-                               + "    protected virtual int this[object value1] {{{0}"
-                               + "        set {{{0}"
-                               + "        }}{0}"
-                               + "    }}{0}"
-                               + "}}{0}", writer.NewLine), Code);
+                               "public class Test1 {{{0}" +
+                               "    {0}" +
+                               "    protected virtual int this[object value1, ref int value2] {{{0}" +
+                               "        set {{{0}" +
+                               "        }}{0}" +
+                               "    }}{0}" +
+                               "}}{0}", Writer.NewLine), code);
                }
 
                [Test]
-               public void PropertyImplementationTypes ()
+               public override void PropertyImplementationTypes ()
                {
-                       type.Name = "Test1";
-
-                       CodeMemberProperty property = new CodeMemberProperty ();
-                       property.Name = "Name";
-                       property.Attributes = MemberAttributes.Public;
-                       property.Type = new CodeTypeReference (typeof (int));
-                       property.ImplementationTypes.Add (new CodeTypeReference ("IPolicy"));
-                       property.ImplementationTypes.Add (new CodeTypeReference ("IWhatever"));
-                       type.Members.Add (property);
-
-                       Generate ();
+                       string code = GeneratePropertyImplementationTypes ();
                        Assert.AreEqual (string.Format (CultureInfo.InvariantCulture,
-                               "public class Test1 {{{0}"
-                               + "    {0}"
-                               + "    public virtual int Name {{{0}"
-                               + "    }}{0}"
-                               + "}}{0}", writer.NewLine), Code);
+                               "public class Test1 {{{0}" +
+                               "    {0}" +
+                               "    public virtual int Name {{{0}" +
+                               "    }}{0}" +
+                               "}}{0}", Writer.NewLine), code);
                }
 
+               /// <summary>
+               /// Ensure that Overloads keyword is output for a property which has
+               /// explicitly been marked as Overloaded.
+               /// </summary>
                [Test]
-               public void PropertyOverloadsTest1 ()
+               public override void PropertyOverloadsTest1 ()
                {
-                       type.Name = "Test1";
-
-                       CodeMemberProperty property = new CodeMemberProperty ();
-                       property.Name = "Name";
-                       property.Attributes = MemberAttributes.Public | MemberAttributes.Overloaded;
-                       property.Type = new CodeTypeReference (typeof (int));
-                       type.Members.Add (property);
-
-                       Generate ();
+                       string code = GeneratePropertyOverloads1 ();
                        Assert.AreEqual (string.Format (CultureInfo.InvariantCulture,
-                               "public class Test1 {{{0}"
-                               + "    {0}"
-                               + "    public virtual int Name {{{0}"
-                               + "    }}{0}"
-                               + "}}{0}", writer.NewLine), Code);
+                               "public class Test1 {{{0}" +
+                               "    {0}" +
+                               "    public virtual int Name {{{0}" +
+                               "    }}{0}" +
+                               "}}{0}", Writer.NewLine), code);
                }
 
+               /// <summary>
+               /// Ensure that Overloads keyword is output if multiple properties with
+               /// the same name are defined.
+               /// </summary>
                [Test]
-               public void PropertyOverloadsTest2 ()
+               public override void PropertyOverloadsTest2 ()
                {
-                       type.Name = "Test1";
-
-                       CodeMemberProperty property = new CodeMemberProperty ();
-                       property.Name = "Name";
-                       property.Attributes = MemberAttributes.Public;
-                       property.Type = new CodeTypeReference (typeof (int));
-                       type.Members.Add (property);
-
-                       property = new CodeMemberProperty ();
-                       property.Name = "Name";
-                       property.Attributes = MemberAttributes.Private;
-                       property.Type = new CodeTypeReference (typeof (int));
-                       CodeParameterDeclarationExpression param = new CodeParameterDeclarationExpression (
-                               typeof (object), "value1");
-                       property.Parameters.Add (param);
-                       type.Members.Add (property);
-
-                       Generate ();
+                       string code = GeneratePropertyOverloads2 ();
                        Assert.AreEqual (string.Format (CultureInfo.InvariantCulture,
-                               "public class Test1 {{{0}"
-                               + "    {0}"
-                               + "    public virtual int Name {{{0}"
-                               + "    }}{0}"
-                               + "    {0}"
-                               + "    private int Name {{{0}"
-                               + "    }}{0}"
-                               + "}}{0}", writer.NewLine), Code);
+                               "public class Test1 {{{0}" +
+                               "    {0}" +
+                               "    public virtual int Name {{{0}" +
+                               "    }}{0}" +
+                               "    {0}" +
+                               "    private int Name {{{0}" +
+                               "    }}{0}" +
+                               "}}{0}", Writer.NewLine), code);
                }
 
+               /// <summary>
+               /// Ensure that a property with a PrivateImplementationType and with 
+               /// the same name does not qualify as an overload.
+               /// </summary>
                [Test]
-               public void PropertyOverloadsTest3 ()
+               public override void PropertyOverloadsTest3 ()
                {
-                       type.Name = "Test1";
-
-                       CodeMemberProperty property = new CodeMemberProperty ();
-                       property.Name = "Name";
-                       property.Attributes = MemberAttributes.Public;
-                       property.Type = new CodeTypeReference (typeof (int));
-                       type.Members.Add (property);
-
-                       property = new CodeMemberProperty ();
-                       property.Name = "Name";
-                       property.Attributes = MemberAttributes.Private;
-                       property.Type = new CodeTypeReference (typeof (int));
-                       CodeParameterDeclarationExpression param = new CodeParameterDeclarationExpression (
-                               typeof (object), "value1");
-                       property.Parameters.Add (param);
-                       property.PrivateImplementationType = new CodeTypeReference (typeof (int));
-                       type.Members.Add (property);
-
-                       Generate ();
+                       string code = GeneratePropertyOverloads3 ();
                        Assert.AreEqual (string.Format (CultureInfo.InvariantCulture,
-                               "public class Test1 {{{0}"
-                               + "    {0}"
-                               + "    public virtual int Name {{{0}"
-                               + "    }}{0}"
-                               + "    {0}"
-                               + "    int System.Int32.Name {{{0}"
-                               + "    }}{0}"
-                               + "}}{0}", writer.NewLine), Code);
+                               "public class Test1 {{{0}" +
+                               "    {0}" +
+                               "    public virtual int Name {{{0}" +
+                               "    }}{0}" +
+                               "    {0}" +
+                               "    int System.Int32.Name {{{0}" +
+                               "    }}{0}" +
+                               "}}{0}", Writer.NewLine), code);
                }
 
                /// <summary>
                /// Ensure no access modifiers are output if PrivateImplementationType
-               /// is set.
+               /// is set. Default keyword is also not output in this case.
                /// </summary>
                [Test]
-               public void PropertyPrivateImplementationType ()
+               public override void PropertyPrivateImplementationType ()
                {
-                       type.Name = "Test1";
-
-                       CodeMemberProperty property = new CodeMemberProperty ();
-                       property.Name = "Item";
-                       property.Attributes = MemberAttributes.Public | MemberAttributes.Overloaded;
-                       property.Type = new CodeTypeReference (typeof (int));
-                       property.PrivateImplementationType = new CodeTypeReference (typeof (int));
-                       CodeParameterDeclarationExpression param = new CodeParameterDeclarationExpression (
-                               typeof (object), "value1");
-                       property.Parameters.Add (param);
-                       type.Members.Add (property);
-
-                       Generate ();
+                       string code = GeneratePropertyPrivateImplementationType ();
                        Assert.AreEqual (string.Format (CultureInfo.InvariantCulture,
-                               "public class Test1 {{{0}"
-                               + "    {0}"
-                               + "    int System.Int32.this[object value1] {{{0}"
-                               + "    }}{0}"
-                               + "}}{0}", writer.NewLine), Code);
+                               "public class Test1 {{{0}" +
+                               "    {0}" +
+                               "    int System.Int32.this[object value1] {{{0}" +
+                               "    }}{0}" +
+                               "}}{0}", Writer.NewLine), code);
                }
 
+               /// <summary>
+               /// If both ImplementationTypes and PrivateImplementationType are set,
+               /// then only ImplementationTypes are output.
+               /// </summary>
                [Test]
-               public void PropertyImplementationTypeOrder ()
+               public override void PropertyImplementationTypeOrder ()
                {
-                       type.Name = "Test1";
-
-                       CodeMemberProperty property = new CodeMemberProperty ();
-                       property.Name = "Item";
-                       property.Attributes = MemberAttributes.Public | MemberAttributes.Overloaded;
-                       property.Type = new CodeTypeReference (typeof (int));
-                       property.PrivateImplementationType = new CodeTypeReference (typeof (int));
-                       property.ImplementationTypes.Add (new CodeTypeReference ("IPolicy"));
-                       CodeParameterDeclarationExpression param = new CodeParameterDeclarationExpression (
-                               typeof (object), "value1");
-                       property.Parameters.Add (param);
-                       type.Members.Add (property);
-
-                       Generate ();
+                       string code = GeneratePropertyImplementationTypeOrder ();
                        Assert.AreEqual (string.Format (CultureInfo.InvariantCulture,
-                               "public class Test1 {{{0}"
-                               + "    {0}"
-                               + "    int System.Int32.this[object value1] {{{0}"
-                               + "    }}{0}"
-                               + "}}{0}", writer.NewLine), Code);
+                               "public class Test1 {{{0}" +
+                               "    {0}" +
+                               "    int System.Int32.this[object value1] {{{0}" +
+                               "    }}{0}" +
+                               "}}{0}", Writer.NewLine), code);
                }
 
                [Test]
-               public void MethodMembersTypeTest1 ()
+               public override void MethodMembersTypeTest1 ()
                {
-                       type.Name = "Test1";
-
-                       CodeMemberMethod method = new CodeMemberMethod ();
-
-                       CodeAttributeDeclaration attrDec = new CodeAttributeDeclaration ();
-                       attrDec.Name = "A";
-                       method.CustomAttributes.Add (attrDec);
-
-                       attrDec = new CodeAttributeDeclaration ();
-                       attrDec.Name = "B";
-                       method.CustomAttributes.Add (attrDec);
-
-                       // C# does not support Implementation Types, so this should be ignored
-                       method.ImplementationTypes.Add (new CodeTypeReference ("IPolicy"));
-
-                       type.Members.Add (method);
-
-                       Generate ();
+                       string code = GenerateMethodMembersType1 ();
                        Assert.AreEqual (string.Format (CultureInfo.InvariantCulture,
-                               "public class Test1 {{{0}"
-                               + "    {0}"
-                               + "    [A()]{0}"
-                               + "    [B()]{0}"
-                               + "    private void () {{{0}"
-                               + "    }}{0}"
-                               + "}}{0}", writer.NewLine), Code);
+                               "public class Test1 {{{0}" +
+                               "    {0}" +
+                               "    [A()]{0}" +
+                               "    [B()]{0}" +
+                               "    private void () {{{0}" +
+                               "    }}{0}" +
+                               "}}{0}", Writer.NewLine), code);
                }
 
                [Test]
-               public void MethodMembersTypeTest2 ()
+               public override void MethodMembersTypeTest2 ()
                {
-                       type.Name = "Test1";
-
-                       CodeMemberMethod method = new CodeMemberMethod ();
-                       method.Name = "Something";
-                       method.Attributes = MemberAttributes.Public;
-                       method.ReturnType = new CodeTypeReference (typeof (int));
-
-                       CodeParameterDeclarationExpression param = new CodeParameterDeclarationExpression (
-                               typeof (object), "value1");
-                       method.Parameters.Add (param);
-
-                       param = new CodeParameterDeclarationExpression (
-                               typeof (object), "value2");
-                       param.Direction = FieldDirection.In;
-                       method.Parameters.Add (param);
-
-                       param = new CodeParameterDeclarationExpression (typeof (int), "index");
-                       param.Direction = FieldDirection.Out;
-                       method.Parameters.Add (param);
-
-                       param = new CodeParameterDeclarationExpression (typeof (int), "count");
-                       param.Direction = FieldDirection.Ref;
-                       method.Parameters.Add (param);
-
-                       type.Members.Add (method);
-
-                       Generate ();
+                       string code = GenerateMethodMembersType2 ();
                        Assert.AreEqual (string.Format (CultureInfo.InvariantCulture,
-                               "public class Test1 {{{0}"
-                               + "    {0}"
-                               + "    public virtual int Something(object value1, object value2, out int index, ref int count) {{{0}"
-                               + "    }}{0}"
-                               + "}}{0}", writer.NewLine), Code);
+                               "public class Test1 {{{0}" +
+                               "    {0}" +
+                               "    public virtual int Something(object value1, object value2, out int index, ref int count) {{{0}" +
+                               "    }}{0}" +
+                               "}}{0}", Writer.NewLine), code);
                }
 
                [Test]
-               public void MethodMembersTypeTest3 ()
+               public override void MethodMembersTypeTest3 ()
                {
-                       type.Name = "Test1";
-
-                       CodeMemberMethod method = new CodeMemberMethod ();
-                       method.Name = "Something";
-                       method.Attributes = MemberAttributes.Public;
-                       method.ReturnType = new CodeTypeReference (typeof (int));
-
-                       // first parameter
-                       CodeParameterDeclarationExpression param = new CodeParameterDeclarationExpression (
-                               typeof (object), "value");
-                       method.Parameters.Add (param);
-
-                       CodeAttributeDeclaration attrDec = new CodeAttributeDeclaration ();
-                       attrDec.Name = "A";
-                       param.CustomAttributes.Add (attrDec);
-
-                       attrDec = new CodeAttributeDeclaration ();
-                       attrDec.Name = "B";
-                       param.CustomAttributes.Add (attrDec);
-
-                       // second parameter
-                       param = new CodeParameterDeclarationExpression (typeof (int), "index");
-                       param.Direction = FieldDirection.Out;
-                       method.Parameters.Add (param);
-
-                       attrDec = new CodeAttributeDeclaration ();
-                       attrDec.Name = "C";
-                       attrDec.Arguments.Add (new CodeAttributeArgument ("A1",
-                               new CodePrimitiveExpression (false)));
-                       attrDec.Arguments.Add (new CodeAttributeArgument ("A2",
-                               new CodePrimitiveExpression (true)));
-                       param.CustomAttributes.Add (attrDec);
-
-                       attrDec = new CodeAttributeDeclaration ();
-                       attrDec.Name = "D";
-                       param.CustomAttributes.Add (attrDec);
-
-                       type.Members.Add (method);
-
-                       Generate ();
+                       string code = GenerateMethodMembersType3 ();
                        Assert.AreEqual (string.Format (CultureInfo.InvariantCulture,
-                               "public class Test1 {{{0}"
-                               + "    {0}"
-                               + "    public virtual int Something([A()] [B()] object value, [C(A1=false, A2=true)] [D()] out int index) {{{0}"
-                               + "    }}{0}"
-                               + "}}{0}", writer.NewLine), Code);
+                               "public class Test1 {{{0}" +
+                               "    {0}" +
+                               "    public virtual int Something([A()] [B()] object value, [C(A1=false, A2=true)] [D()] out int index) {{{0}" +
+                               "    }}{0}" +
+                               "}}{0}", Writer.NewLine), code);
                }
 
                [Test]
-               public void MethodImplementationTypes ()
+               public override void MethodImplementationTypes ()
                {
-                       type.Name = "Test1";
-
-                       CodeMemberMethod method = new CodeMemberMethod ();
-                       method.Name = "Execute";
-                       method.Attributes = MemberAttributes.Assembly;
-                       method.ReturnType = new CodeTypeReference (typeof (int));
-                       method.ImplementationTypes.Add (new CodeTypeReference ("IPolicy"));
-                       method.ImplementationTypes.Add (new CodeTypeReference ("IWhatever"));
-                       type.Members.Add (method);
-
-                       Generate ();
+                       string code = GenerateMethodImplementationTypes ();
                        Assert.AreEqual (string.Format (CultureInfo.InvariantCulture,
-                               "public class Test1 {{{0}"
-                               + "    {0}"
+                               "public class Test1 {{{0}" +
+                               "    {0}" +
 #if NET_2_0
-                               + "    internal virtual int Execute() {{{0}"
+                               "    internal virtual int Execute() {{{0}" +
 #else
-                               + "    internal int Execute() {{{0}"
+                               "    internal int Execute() {{{0}" +
 #endif
-                               + "    }}{0}"
-                               + "}}{0}", writer.NewLine), Code);
+                               "    }}{0}" +
+                               "}}{0}", Writer.NewLine), code);
                }
 
                [Test]
-               public void MethodOverloadsTest1 ()
+               public override void MethodOverloadsTest1 ()
                {
-                       type.Name = "Test1";
-
-                       CodeMemberMethod method = new CodeMemberMethod ();
-                       method.Name = "Execute";
-                       method.Attributes = MemberAttributes.Public | MemberAttributes.Overloaded;
-                       method.ReturnType = new CodeTypeReference (typeof (int));
-                       type.Members.Add (method);
-
-                       Generate ();
+                       string code = GenerateMethodOverloads1 ();
                        Assert.AreEqual (string.Format (CultureInfo.InvariantCulture,
-                               "public class Test1 {{{0}"
-                               + "    {0}"
-                               + "    public virtual int Execute() {{{0}"
-                               + "    }}{0}"
-                               + "}}{0}", writer.NewLine), Code);
+                               "public class Test1 {{{0}" +
+                               "    {0}" +
+                               "    public virtual int Execute() {{{0}" +
+                               "    }}{0}" +
+                               "}}{0}", Writer.NewLine), code);
                }
 
                [Test]
-               public void MethodOverloadsTest2 ()
+               public override void MethodOverloadsTest2 ()
                {
-                       type.Name = "Test1";
-
-                       CodeMemberMethod method = new CodeMemberMethod ();
-                       method.Name = "Execute";
-                       method.Attributes = MemberAttributes.Public;
-                       type.Members.Add (method);
-
-                       method = new CodeMemberMethod ();
-                       method.Name = "Execute";
-                       method.Attributes = MemberAttributes.Private;
-                       method.ReturnType = new CodeTypeReference (typeof (int));
-                       CodeParameterDeclarationExpression param = new CodeParameterDeclarationExpression (
-                               typeof (object), "value1");
-                       method.Parameters.Add (param);
-                       type.Members.Add (method);
-
-                       Generate ();
+                       string code = GenerateMethodOverloads2 ();
                        Assert.AreEqual (string.Format (CultureInfo.InvariantCulture,
-                               "public class Test1 {{{0}"
-                               + "    {0}"
-                               + "    public virtual void Execute() {{{0}"
-                               + "    }}{0}"
-                               + "    {0}"
-                               + "    private int Execute(object value1) {{{0}"
-                               + "    }}{0}"
-                               + "}}{0}", writer.NewLine), Code);
+                               "public class Test1 {{{0}" +
+                               "    {0}" +
+                               "    public virtual void Execute() {{{0}" +
+                               "    }}{0}" +
+                               "    {0}" +
+                               "    private int Execute(object value1) {{{0}" +
+                               "    }}{0}" +
+                               "}}{0}", Writer.NewLine), code);
                }
 
+               /// <summary>
+               /// Ensure that a method with a PrivateImplementationType and with 
+               /// the same name does not qualify as an overload.
+               /// </summary>
                [Test]
-               public void MethodOverloadsTest3 ()
+               public override void MethodOverloadsTest3 ()
                {
-                       type.Name = "Test1";
-
-                       CodeMemberMethod method = new CodeMemberMethod ();
-                       method.Name = "Execute";
-                       method.Attributes = MemberAttributes.Public;
-                       type.Members.Add (method);
-
-                       method = new CodeMemberMethod ();
-                       method.Name = "Execute";
-                       method.Attributes = MemberAttributes.Private;
-                       method.ReturnType = new CodeTypeReference (typeof (int));
-                       CodeParameterDeclarationExpression param = new CodeParameterDeclarationExpression (
-                               typeof (object), "value1");
-                       method.Parameters.Add (param);
-                       method.PrivateImplementationType = new CodeTypeReference (typeof (int));
-                       type.Members.Add (method);
-
-                       Generate ();
+                       string code = GenerateMethodOverloads3 ();
                        Assert.AreEqual (string.Format (CultureInfo.InvariantCulture,
-                               "public class Test1 {{{0}"
-                               + "    {0}"
-                               + "    public virtual void Execute() {{{0}"
-                               + "    }}{0}"
-                               + "    {0}"
-                               + "    int System.Int32.Execute(object value1) {{{0}"
-                               + "    }}{0}"
-                               + "}}{0}", writer.NewLine), Code);
+                               "public class Test1 {{{0}" +
+                               "    {0}" +
+                               "    public virtual void Execute() {{{0}" +
+                               "    }}{0}" +
+                               "    {0}" +
+                               "    int System.Int32.Execute(object value1) {{{0}" +
+                               "    }}{0}" +
+                               "}}{0}", Writer.NewLine), code);
                }
 
                /// <summary>
@@ -944,403 +578,2407 @@ namespace MonoTests.Microsoft.CSharp
                /// is set.
                /// </summary>
                [Test]
-               public void MethodPrivateImplementationType ()
+               public override void MethodPrivateImplementationType ()
                {
-                       type.Name = "Test1";
-
-                       CodeMemberMethod method = new CodeMemberMethod ();
-                       method.Name = "Execute";
-                       method.Attributes = MemberAttributes.Public | MemberAttributes.Overloaded;
-                       method.ReturnType = new CodeTypeReference (typeof (int));
-                       method.PrivateImplementationType = new CodeTypeReference (typeof (int));
-                       CodeParameterDeclarationExpression param = new CodeParameterDeclarationExpression (
-                               typeof (object), "value1");
-                       method.Parameters.Add (param);
-                       type.Members.Add (method);
-
-                       Generate ();
+                       string code = GenerateMethodPrivateImplementationType ();
                        Assert.AreEqual (string.Format (CultureInfo.InvariantCulture,
-                               "public class Test1 {{{0}"
-                               + "    {0}"
-                               + "    int System.Int32.Execute(object value1) {{{0}"
-                               + "    }}{0}"
-                               + "}}{0}", writer.NewLine), Code);
+                               "public class Test1 {{{0}" +
+                               "    {0}" +
+                               "    int System.Int32.Execute(object value1) {{{0}" +
+                               "    }}{0}" +
+                               "}}{0}", Writer.NewLine), code);
                }
 
+               /// <summary>
+               /// If both ImplementationTypes and PrivateImplementationType are set,
+               /// then only ImplementationTypes are output.
+               /// </summary>
                [Test]
-               public void MethodImplementationTypeOrder ()
+               public override void MethodImplementationTypeOrder ()
                {
-                       type.Name = "Test1";
-
-                       CodeMemberMethod method = new CodeMemberMethod ();
-                       method.Name = "Execute";
-                       method.Attributes = MemberAttributes.Public;
-                       method.ReturnType = new CodeTypeReference (typeof (int));
-                       CodeParameterDeclarationExpression param = new CodeParameterDeclarationExpression (
-                               typeof (object), "value1");
-                       method.Parameters.Add (param);
-                       method.PrivateImplementationType = new CodeTypeReference (typeof (int));
-                       method.ImplementationTypes.Add (new CodeTypeReference ("IPolicy"));
-                       type.Members.Add (method);
-
-                       Generate ();
+                       string code = GenerateMethodImplementationTypeOrder ();
                        Assert.AreEqual (string.Format (CultureInfo.InvariantCulture,
-                               "public class Test1 {{{0}"
-                               + "    {0}"
-                               + "    int System.Int32.Execute(object value1) {{{0}"
-                               + "    }}{0}"
-                               + "}}{0}", writer.NewLine), Code);
+                               "public class Test1 {{{0}" +
+                               "    {0}" +
+                               "    int System.Int32.Execute(object value1) {{{0}" +
+                               "    }}{0}" +
+                               "}}{0}", Writer.NewLine), code);
                }
 
                [Test]
-               public void MethodReturnTypeAttributes ()
+               public override void MethodReturnTypeAttributes ()
                {
-                       type.Name = "Test1";
-
-                       CodeMemberMethod method = new CodeMemberMethod ();
-                       method.Name = "Execute";
-                       method.Attributes = MemberAttributes.Public;
-                       method.ReturnType = new CodeTypeReference (typeof (int));
-                       type.Members.Add (method);
-
-                       // method custom attributes
-                       CodeAttributeDeclaration attrDec = new CodeAttributeDeclaration ();
-                       attrDec.Name = "A";
-                       method.CustomAttributes.Add (attrDec);
-
-                       attrDec = new CodeAttributeDeclaration ();
-                       attrDec.Name = "B";
-                       method.CustomAttributes.Add (attrDec);
-
-                       // return type custom attributes
-                       attrDec = new CodeAttributeDeclaration ();
-                       attrDec.Name = "C";
-                       attrDec.Arguments.Add (new CodeAttributeArgument ("A1",
-                               new CodePrimitiveExpression (false)));
-                       attrDec.Arguments.Add (new CodeAttributeArgument ("A2",
-                               new CodePrimitiveExpression (true)));
-                       method.ReturnTypeCustomAttributes.Add (attrDec);
-
-                       attrDec = new CodeAttributeDeclaration ();
-                       attrDec.Name = "D";
-                       method.ReturnTypeCustomAttributes.Add (attrDec);
-
-                       Generate ();
+                       string code = GenerateMethodReturnTypeAttributes ();
                        Assert.AreEqual (string.Format (CultureInfo.InvariantCulture,
-                               "public class Test1 {{{0}"
-                               + "    {0}"
-                               + "    [A()]{0}"
-                               + "    [B()]{0}"
-                               + "    [return: C(A1=false, A2=true)]{0}"
-                               + "    [return: D()]{0}"
-                               + "    public virtual int Execute() {{{0}"
-                               + "    }}{0}"
-                               + "}}{0}", writer.NewLine), Code);
+                               "public class Test1 {{{0}" +
+                               "    {0}" +
+                               "    [A()]{0}" +
+                               "    [B()]{0}" +
+                               "    [return: C(A1=false, A2=true)]{0}" +
+                               "    [return: D()]{0}" +
+                               "    public virtual int Execute() {{{0}" +
+                               "    }}{0}" +
+                               "}}{0}", Writer.NewLine), code);
                }
 
                [Test]
-               public void ConstructorAttributesTest ()
+               public override void ConstructorAttributesTest ()
                {
-                       type.Name = "Test1";
-
-                       CodeConstructor ctor = new CodeConstructor ();
-
-                       CodeAttributeDeclaration attrDec = new CodeAttributeDeclaration ();
-                       attrDec.Name = "A";
-                       ctor.CustomAttributes.Add (attrDec);
-
-                       attrDec = new CodeAttributeDeclaration ();
-                       attrDec.Name = "B";
-                       ctor.CustomAttributes.Add (attrDec);
-
-                       // C# does not support Implementation Types, so this should be ignored
-                       ctor.ImplementationTypes.Add (new CodeTypeReference ("IPolicy"));
-
-                       type.Members.Add (ctor);
-
-                       Generate ();
+                       string code = GenerateConstructorAttributes ();
                        Assert.AreEqual (string.Format (CultureInfo.InvariantCulture,
-                               "public class Test1 {{{0}"
-                               + "    {0}"
-                               + "    [A()]{0}"
-                               + "    [B()]{0}"
-                               + "    private Test1() {{{0}"
-                               + "    }}{0}"
-                               + "}}{0}", writer.NewLine), Code);
+                               "public class Test1 {{{0}" +
+                               "    {0}" +
+                               "    [A()]{0}" +
+                               "    [B()]{0}" +
+                               "    private Test1() {{{0}" +
+                               "    }}{0}" +
+                               "}}{0}", Writer.NewLine), code);
                }
 
                [Test]
-               public void ConstructorParametersTest ()
+               public override void ConstructorParametersTest ()
                {
-                       type.Name = "Test1";
-
-                       CodeConstructor ctor = new CodeConstructor ();
-                       ctor.Name = "Whatever";
-                       ctor.Attributes = MemberAttributes.Public;
-
-                       CodeParameterDeclarationExpression param = new CodeParameterDeclarationExpression (
-                               typeof (object), "value1");
-                       ctor.Parameters.Add (param);
+                       string code = GenerateConstructorParameters ();
+                       Assert.AreEqual (string.Format (CultureInfo.InvariantCulture,
+                               "public class Test1 {{{0}" +
+                               "    {0}" +
+                               "    public Test1(object value1, object value2, out int index, ref int count) {{{0}" +
+                               "    }}{0}" +
+                               "}}{0}", Writer.NewLine), code);
+               }
 
-                       param = new CodeParameterDeclarationExpression (
-                               typeof (object), "value2");
-                       param.Direction = FieldDirection.In;
-                       ctor.Parameters.Add (param);
+               [Test]
+               public override void ConstructorParameterAttributesTest ()
+               {
+                       string code = GenerateConstructorParameterAttributes ();
+                       Assert.AreEqual (string.Format (CultureInfo.InvariantCulture,
+                               "public class Test1 {{{0}" +
+                               "    {0}" +
+                               "    public Test1([A()] [B()] object value, [C(A1=false, A2=true)] [D()] out int index) {{{0}" +
+                               "    }}{0}" +
+                               "}}{0}", Writer.NewLine), code);
+               }
 
-                       param = new CodeParameterDeclarationExpression (typeof (int), "index");
-                       param.Direction = FieldDirection.Out;
-                       ctor.Parameters.Add (param);
+               [Test]
+               public override void BaseConstructorSingleArg ()
+               {
+                       string code = GenerateBaseConstructor (false);
+                       Assert.AreEqual (string.Format (CultureInfo.InvariantCulture,
+                               "public class Test1 {{{0}" +
+                               "    {0}" +
+                               "    public Test1(object value1, out int value2) : {0}" +
+                               "            base(value1) {{{0}" +
+                               "    }}{0}" +
+                               "}}{0}", Writer.NewLine), code);
+               }
 
-                       param = new CodeParameterDeclarationExpression (typeof (int), "count");
-                       param.Direction = FieldDirection.Ref;
-                       ctor.Parameters.Add (param);
+               [Test]
+               public override void BaseConstructorMultipleArgs ()
+               {
+                       string code = GenerateBaseConstructor (true);
+                       Assert.AreEqual (string.Format (CultureInfo.InvariantCulture,
+                               "public class Test1 {{{0}" +
+                               "    {0}" +
+                               "    public Test1(object value1, out int value2) : {0}" +
+                               "            base(value1, value2) {{{0}" +
+                               "    }}{0}" +
+                               "}}{0}", Writer.NewLine), code);
+               }
 
-                       type.Members.Add (ctor);
+               [Test]
+               public override void ChainedConstructorSingleArg ()
+               {
+                       string code = GenerateChainedConstructor (false);
+                       Assert.AreEqual (string.Format (CultureInfo.InvariantCulture,
+                               "public class Test1 {{{0}" +
+                               "    {0}" +
+                               "    public Test1(object value1, out int value2) : {0}" +
+                               "            base(value3) : {0}" +
+                               "            this(value1) {{{0}" +
+                               "    }}{0}" +
+                               "}}{0}", Writer.NewLine), code);
+               }
 
-                       Generate ();
+               [Test]
+               public override void ChainedConstructorMultipleArgs ()
+               {
+                       string code = GenerateChainedConstructor (true);
                        Assert.AreEqual (string.Format (CultureInfo.InvariantCulture,
-                               "public class Test1 {{{0}"
-                               + "    {0}"
-                               + "    public Test1(object value1, object value2, out int index, ref int count) {{{0}"
-                               + "    }}{0}"
-                               + "}}{0}", writer.NewLine), Code);
+                               "public class Test1 {{{0}" +
+                               "    {0}" +
+                               "    public Test1(object value1, out int value2) : {0}" +
+                               "            base(value3) : {0}" +
+                               "            this(value1, value2) {{{0}" +
+                               "    }}{0}" +
+                               "}}{0}", Writer.NewLine), code);
                }
 
                [Test]
-               public void ConstructorParameterAttributesTest ()
+               public override void TypeConstructorTest ()
                {
-                       type.Name = "Test1";
+                       string code = GenerateTypeConstructor ();
+                       Assert.AreEqual (string.Format (CultureInfo.InvariantCulture,
+                               "public class Test1 {{{0}" +
+                               "    {0}" +
+#if NET_2_0
+                               "    [A()]{0}" +
+                               "    [B()]{0}" +
+#endif
+                               "    static Test1() {{{0}" +
+                               "    }}{0}" +
+                               "}}{0}", Writer.NewLine), code);
+               }
 
-                       CodeConstructor ctor = new CodeConstructor ();
-                       ctor.Name = "Something";
-                       ctor.Attributes = MemberAttributes.Public;
+               #endregion Override implementation of CodeGeneratorFromTypeTestBase
+       }
 
-                       // first parameter
-                       CodeParameterDeclarationExpression param = new CodeParameterDeclarationExpression (
-                               typeof (object), "value");
-                       ctor.Parameters.Add (param);
+       [TestFixture]
+       public class dCodeGeneratorFromTypeTest_Delegate : CodeGeneratorFromTypeTestBase
+       {
+               private CodeTypeDeclaration _typeDeclaration;
+               private ICodeGenerator _codeGenerator;
 
-                       CodeAttributeDeclaration attrDec = new CodeAttributeDeclaration ();
-                       attrDec.Name = "A";
-                       param.CustomAttributes.Add (attrDec);
+               #region Override implementation of CodeGeneratorTestBase
+               
+               protected override ICodeGenerator CodeGenerator
+               {
+                       get { return _codeGenerator; }
+               }
 
-                       attrDec = new CodeAttributeDeclaration ();
-                       attrDec.Name = "B";
-                       param.CustomAttributes.Add (attrDec);
+               [SetUp]
+               public override void SetUp ()
+               {
+                       base.SetUp ();
+                       _typeDeclaration = new CodeTypeDelegate ();
 
-                       // second parameter
-                       param = new CodeParameterDeclarationExpression (typeof (int), "index");
-                       param.Direction = FieldDirection.Out;
-                       ctor.Parameters.Add (param);
+                       CodeDomProvider provider = new CSharpCodeProvider ();
+                       _codeGenerator = provider.CreateGenerator ();
+               }
 
-                       attrDec = new CodeAttributeDeclaration ();
-                       attrDec.Name = "C";
-                       attrDec.Arguments.Add (new CodeAttributeArgument ("A1",
-                               new CodePrimitiveExpression (false)));
-                       attrDec.Arguments.Add (new CodeAttributeArgument ("A2",
-                               new CodePrimitiveExpression (true)));
-                       param.CustomAttributes.Add (attrDec);
+               #endregion Override implementation of CodeGeneratorTestBase
 
-                       attrDec = new CodeAttributeDeclaration ();
-                       attrDec.Name = "D";
-                       param.CustomAttributes.Add (attrDec);
+               #region Override implementation of CodeGeneratorFromTypeTestBase
 
-                       type.Members.Add (ctor);
+               protected override CodeTypeDeclaration TypeDeclaration
+               {
+                       get { return _typeDeclaration; }
+               }
 
-                       Generate ();
+               [Test]
+               public override void DefaultTypeTest ()
+               {
+                       string code = GenerateDefaultType ();
                        Assert.AreEqual (string.Format (CultureInfo.InvariantCulture,
-                               "public class Test1 {{{0}"
-                               + "    {0}"
-                               + "    public Test1([A()] [B()] object value, [C(A1=false, A2=true)] [D()] out int index) {{{0}"
-                               + "    }}{0}"
-                               + "}}{0}", writer.NewLine), Code);
+                               "public delegate void ();{0}", Writer.NewLine), code);
                }
 
                [Test]
-               public void BaseConstructorSingleArg ()
+               [ExpectedException (typeof (NullReferenceException))]
+               public override void NullTypeTest ()
                {
-                       type.Name = "Test1";
-
-                       CodeConstructor ctor = new CodeConstructor ();
-                       ctor.Name = "Something";
-                       ctor.Attributes = MemberAttributes.Public;
-
-                       // first parameter
-                       CodeParameterDeclarationExpression param = new CodeParameterDeclarationExpression (
-                               typeof (object), "value1");
-                       ctor.Parameters.Add (param);
-
-                       // second parameter
-                       param = new CodeParameterDeclarationExpression (typeof (int), "value2");
-                       param.Direction = FieldDirection.Out;
-                       ctor.Parameters.Add (param);
-
-                       // base ctor args
-                       ctor.BaseConstructorArgs.Add (new CodeVariableReferenceExpression ("value1"));
-
-                       type.Members.Add (ctor);
+                       GenerateNullType ();
+               }
 
-                       Generate ();
+               [Test]
+               public override void SimpleTypeTest ()
+               {
+                       string code = GenerateSimpleType ();
                        Assert.AreEqual (string.Format (CultureInfo.InvariantCulture,
-                               "public class Test1 {{{0}"
-                               + "    {0}"
-                               + "    public Test1(object value1, out int value2) : {0}"
-                               + "            base(value1) {{{0}"
-                               + "    }}{0}"
-                               + "}}{0}", writer.NewLine), Code);
+                               "public delegate void Test1();{0}", Writer.NewLine), code);
                }
 
                [Test]
-               public void BaseConstructorMultipleArgs ()
+               public override void DerivedTypeTest ()
                {
-                       type.Name = "Test1";
-
-                       CodeConstructor ctor = new CodeConstructor ();
-                       ctor.Name = "Something";
-                       ctor.Attributes = MemberAttributes.Public;
-
-                       // first parameter
-                       CodeParameterDeclarationExpression param = new CodeParameterDeclarationExpression (
-                               typeof (object), "value1");
-                       ctor.Parameters.Add (param);
-
-                       // second parameter
-                       param = new CodeParameterDeclarationExpression (typeof (int), "value2");
-                       param.Direction = FieldDirection.Out;
-                       ctor.Parameters.Add (param);
-
-                       // base ctor args
-                       ctor.BaseConstructorArgs.Add (new CodeVariableReferenceExpression ("value1"));
-                       ctor.BaseConstructorArgs.Add (new CodeVariableReferenceExpression ("value2"));
-
-                       type.Members.Add (ctor);
-
-                       Generate ();
+                       string code = GenerateDerivedType ();
                        Assert.AreEqual (string.Format (CultureInfo.InvariantCulture,
-                               "public class Test1 {{{0}"
-                               + "    {0}"
-                               + "    public Test1(object value1, out int value2) : {0}"
-                               + "            base(value1, value2) {{{0}"
-                               + "    }}{0}"
-                               + "}}{0}", writer.NewLine), Code);
+                               "delegate void Test1();{0}", Writer.NewLine), code);
                }
 
                [Test]
-               public void ChainedConstructorSingleArg ()
+               public override void AttributesAndTypeTest ()
                {
-                       type.Name = "Test1";
-
-                       CodeConstructor ctor = new CodeConstructor ();
-                       ctor.Name = "Something";
-                       ctor.Attributes = MemberAttributes.Public;
+                       CodeTypeDelegate delegateDecl = new CodeTypeDelegate ();
+                       delegateDecl.ReturnType = new CodeTypeReference (typeof (int));
 
-                       // first parameter
-                       CodeParameterDeclarationExpression param = new CodeParameterDeclarationExpression (
-                               typeof (object), "value1");
-                       ctor.Parameters.Add (param);
+                       _typeDeclaration = delegateDecl;
 
-                       // second parameter
-                       param = new CodeParameterDeclarationExpression (typeof (int), "value2");
-                       param.Direction = FieldDirection.Out;
-                       ctor.Parameters.Add (param);
-
-                       // chained ctor args
-                       ctor.ChainedConstructorArgs.Add (new CodeVariableReferenceExpression ("value1"));
-
-                       type.Members.Add (ctor);
-
-                       Generate ();
+                       string code = GenerateAttributesAndType ();
                        Assert.AreEqual (string.Format (CultureInfo.InvariantCulture,
-                               "public class Test1 {{{0}"
-                               + "    {0}"
-                               + "    public Test1(object value1, out int value2) : {0}"
-                               + "            this(value1) {{{0}"
-                               + "    }}{0}"
-                               + "}}{0}", writer.NewLine), Code);
+                               "[A()]{0}" +
+                               "[B()]{0}" +
+                               "public delegate int Test1();{0}", Writer.NewLine), code);
                }
 
                [Test]
-               public void ChainedConstructorMultipleArgs ()
+               public override void EventMembersTypeTest1 ()
                {
-                       type.Name = "Test1";
-
-                       CodeConstructor ctor = new CodeConstructor ();
-                       ctor.Name = "Something";
-                       ctor.Attributes = MemberAttributes.Public;
-
-                       // first parameter
-                       CodeParameterDeclarationExpression param = new CodeParameterDeclarationExpression (
-                               typeof (object), "value1");
-                       ctor.Parameters.Add (param);
-
-                       // second parameter
-                       param = new CodeParameterDeclarationExpression (typeof (int), "value2");
-                       param.Direction = FieldDirection.Out;
-                       ctor.Parameters.Add (param);
-
-                       // chained ctor args
-                       ctor.ChainedConstructorArgs.Add (new CodeVariableReferenceExpression ("value1"));
-                       ctor.ChainedConstructorArgs.Add (new CodeVariableReferenceExpression ("value2"));
-
-                       type.Members.Add (ctor);
-
-                       Generate ();
+                       string code = GenerateEventMembersType1 ();
                        Assert.AreEqual (string.Format (CultureInfo.InvariantCulture,
-                               "public class Test1 {{{0}"
-                               + "    {0}"
-                               + "    public Test1(object value1, out int value2) : {0}"
-                               + "            this(value1, value2) {{{0}"
-                               + "    }}{0}"
-                               + "}}{0}", writer.NewLine), Code);
+                               "public delegate void Test1();{0}{0}", Writer.NewLine), code);
                }
 
                [Test]
-               public void BaseAndChainedConstructorArg ()
+               public override void EventMembersTypeTest2 ()
                {
-                       type.Name = "Test1";
-
-                       CodeConstructor ctor = new CodeConstructor ();
-                       ctor.Name = "Something";
-                       ctor.Attributes = MemberAttributes.Public;
-
-                       // first parameter
-                       CodeParameterDeclarationExpression param = new CodeParameterDeclarationExpression (
-                               typeof (object), "value1");
-                       ctor.Parameters.Add (param);
-
-                       // second parameter
-                       param = new CodeParameterDeclarationExpression (typeof (int), "value2");
-                       param.Direction = FieldDirection.Out;
-                       ctor.Parameters.Add (param);
-
-                       // base ctor args
-                       ctor.BaseConstructorArgs.Add (new CodeVariableReferenceExpression ("value1"));
+                       string code = GenerateEventMembersType2 ();
+                       Assert.AreEqual (string.Format (CultureInfo.InvariantCulture,
+                               "public delegate void Test1();{0}{0}", Writer.NewLine), code);
+               }
 
-                       // chained ctor args
-                       ctor.ChainedConstructorArgs.Add (new CodeVariableReferenceExpression ("value1"));
-                       ctor.ChainedConstructorArgs.Add (new CodeVariableReferenceExpression ("value2"));
+               [Test]
+               public override void EventImplementationTypes ()
+               {
+                       string code = GenerateEventImplementationTypes ();
+                       Assert.AreEqual (string.Format (CultureInfo.InvariantCulture,
+                               "public delegate void Test1();{0}{0}", Writer.NewLine), code);
+               }
 
-                       type.Members.Add (ctor);
+               /// <summary>
+               /// Ensure no access modifiers are output if PrivateImplementationType
+               /// is set.
+               /// </summary>
+               [Test]
+               public override void EventPrivateImplementationType ()
+               {
+                       string code = GenerateEventPrivateImplementationType ();
+                       Assert.AreEqual (string.Format (CultureInfo.InvariantCulture,
+                               "public delegate void Test1();{0}{0}", Writer.NewLine), code);
+               }
 
-                       Generate ();
+               /// <summary>
+               /// If both ImplementationTypes and PrivateImplementationType are set,
+               /// then only ImplementationTypes are output.
+               /// </summary>
+               [Test]
+               public override void EventImplementationTypeOrder ()
+               {
+                       string code = GenerateEventImplementationTypeOrder ();
                        Assert.AreEqual (string.Format (CultureInfo.InvariantCulture,
-                               "public class Test1 {{{0}"
-                               + "    {0}"
-                               + "    public Test1(object value1, out int value2) : {0}"
-                               + "            base(value1) : {0}"
-                               + "            this(value1, value2) {{{0}"
-                               + "    }}{0}"
-                               + "}}{0}", writer.NewLine), Code);
+                               "public delegate void Test1();{0}{0}", Writer.NewLine), code);
                }
 
-               /*
                [Test]
-               public void ReferencedTest ()
+               public override void FieldMembersTypeTest1 ()
                {
-                       codeUnit.ReferencedAssemblies.Add ("System.dll");
-                       Generate ();
-                       Assertion.AssertEquals ("", Code);
+                       string code = GenerateFieldMembersType1 ();
+                       Assert.AreEqual (string.Format (CultureInfo.InvariantCulture,
+                               "public delegate void Test1();{0}{0}", Writer.NewLine), code);
                }
-               */
+
+               [Test]
+               public override void FieldMembersTypeTest2 ()
+               {
+                       string code = GenerateFieldMembersType2 ();
+                       Assert.AreEqual (string.Format (CultureInfo.InvariantCulture,
+                               "public delegate void Test1();{0}{0}", Writer.NewLine), code);
+               }
+
+               [Test]
+               public override void PropertyMembersTypeTest1 ()
+               {
+                       string code = GeneratePropertyMembersAttributes ();
+                       Assert.AreEqual (string.Format (CultureInfo.InvariantCulture,
+                               "public delegate void Test1();{0}{0}", Writer.NewLine), code);
+               }
+
+               [Test]
+               public override void PropertyMembersTypeTest2 ()
+               {
+                       string code = GeneratePropertyMembersType (MemberAttributes.Public,
+                               false, false);
+                       Assert.AreEqual (string.Format (CultureInfo.InvariantCulture,
+                               "public delegate void Test1();{0}{0}", Writer.NewLine), code);
+               }
+
+               [Test]
+               public override void PropertyMembersTypeGetOnly ()
+               {
+                       string code = GeneratePropertyMembersType (MemberAttributes.Family,
+                               true, false);
+                       Assert.AreEqual (string.Format (CultureInfo.InvariantCulture,
+                               "public delegate void Test1();{0}{0}", Writer.NewLine), code);
+               }
+
+               [Test]
+               public override void PropertyMembersTypeSetOnly ()
+               {
+                       string code = GeneratePropertyMembersType (MemberAttributes.Assembly,
+                               false, true);
+                       Assert.AreEqual (string.Format (CultureInfo.InvariantCulture,
+                               "public delegate void Test1();{0}{0}", Writer.NewLine), code);
+               }
+
+               [Test]
+               public override void PropertyMembersTypeGetSet ()
+               {
+                       string code = GeneratePropertyMembersType (MemberAttributes.Family,
+                               true, true);
+                       Assert.AreEqual (string.Format (CultureInfo.InvariantCulture,
+                               "public delegate void Test1();{0}{0}", Writer.NewLine), code);
+               }
+
+               [Test]
+               public override void PropertyMembersTypeFamilyOrAssembly ()
+               {
+                       string code = GeneratePropertyMembersType (MemberAttributes.FamilyOrAssembly,
+                               false, false);
+                       Assert.AreEqual (string.Format (CultureInfo.InvariantCulture,
+                               "public delegate void Test1();{0}{0}", Writer.NewLine), code);
+               }
+
+               [Test]
+               public override void PropertyMembersTypeAssembly ()
+               {
+                       string code = GeneratePropertyMembersType (MemberAttributes.Assembly,
+                               false, false);
+                       Assert.AreEqual (string.Format (CultureInfo.InvariantCulture,
+                               "public delegate void Test1();{0}{0}", Writer.NewLine), code);
+               }
+
+               [Test]
+               public override void PropertyParametersTest ()
+               {
+                       string code = GeneratePropertyParameters ();
+                       Assert.AreEqual (string.Format (CultureInfo.InvariantCulture,
+                               "public delegate void Test1();{0}{0}", Writer.NewLine), code);
+               }
+
+               [Test]
+               public override void PropertyIndexerTest1 ()
+               {
+                       string code = GeneratePropertyIndexer (MemberAttributes.Public,
+                               false, false, true);
+                       Assert.AreEqual (string.Format (CultureInfo.InvariantCulture,
+                               "public delegate void Test1();{0}{0}", Writer.NewLine), code);
+               }
+
+               [Test]
+               public override void PropertyIndexerTest2 ()
+               {
+                       string code = GeneratePropertyIndexer (MemberAttributes.Public,
+                               false, false, false);
+                       Assert.AreEqual (string.Format (CultureInfo.InvariantCulture,
+                               "public delegate void Test1();{0}{0}", Writer.NewLine), code);
+               }
+
+               [Test]
+               public override void PropertyIndexerGetOnly ()
+               {
+                       string code = GeneratePropertyIndexer (MemberAttributes.Family,
+                               true, false, true);
+                       Assert.AreEqual (string.Format (CultureInfo.InvariantCulture,
+                               "public delegate void Test1();{0}{0}", Writer.NewLine), code);
+               }
+
+               [Test]
+               public override void PropertyIndexerSetOnly ()
+               {
+                       string code = GeneratePropertyIndexer (MemberAttributes.Family,
+                               false, true, true);
+                       Assert.AreEqual (string.Format (CultureInfo.InvariantCulture,
+                               "public delegate void Test1();{0}{0}", Writer.NewLine), code);
+               }
+
+               [Test]
+               public override void PropertyImplementationTypes ()
+               {
+                       string code = GeneratePropertyImplementationTypes ();
+                       Assert.AreEqual (string.Format (CultureInfo.InvariantCulture,
+                               "public delegate void Test1();{0}{0}", Writer.NewLine), code);
+               }
+
+               [Test]
+               public override void PropertyOverloadsTest1 ()
+               {
+                       string code = GeneratePropertyOverloads1 ();
+                       Assert.AreEqual (string.Format (CultureInfo.InvariantCulture,
+                               "public delegate void Test1();{0}{0}", Writer.NewLine), code);
+               }
+
+               [Test]
+               public override void PropertyOverloadsTest2 ()
+               {
+                       string code = GeneratePropertyOverloads2 ();
+                       Assert.AreEqual (string.Format (CultureInfo.InvariantCulture,
+                               "public delegate void Test1();{0}{0}{0}", Writer.NewLine), code);
+               }
+
+               [Test]
+               public override void PropertyOverloadsTest3 ()
+               {
+                       string code = GeneratePropertyOverloads3 ();
+                       Assert.AreEqual (string.Format (CultureInfo.InvariantCulture,
+                               "public delegate void Test1();{0}{0}{0}", Writer.NewLine), code);
+               }
+
+               [Test]
+               public override void PropertyPrivateImplementationType ()
+               {
+                       string code = GeneratePropertyPrivateImplementationType ();
+                       Assert.AreEqual (string.Format (CultureInfo.InvariantCulture,
+                               "public delegate void Test1();{0}{0}", Writer.NewLine), code);
+               }
+
+               [Test]
+               public override void PropertyImplementationTypeOrder ()
+               {
+                       string code = GeneratePropertyImplementationTypeOrder ();
+                       Assert.AreEqual (string.Format (CultureInfo.InvariantCulture,
+                               "public delegate void Test1();{0}{0}", Writer.NewLine), code);
+               }
+
+               [Test]
+               public override void MethodMembersTypeTest1 ()
+               {
+                       string code = GenerateMethodMembersType1 ();
+                       Assert.AreEqual (string.Format (CultureInfo.InvariantCulture,
+                               "public delegate void Test1();{0}{0}", Writer.NewLine), code);
+               }
+
+               [Test]
+               public override void MethodMembersTypeTest2 ()
+               {
+                       string code = GenerateMethodMembersType2 ();
+                       Assert.AreEqual (string.Format (CultureInfo.InvariantCulture,
+                               "public delegate void Test1();{0}{0}", Writer.NewLine), code);
+               }
+
+               [Test]
+               public override void MethodMembersTypeTest3 ()
+               {
+                       string code = GenerateMethodMembersType3 ();
+                       Assert.AreEqual (string.Format (CultureInfo.InvariantCulture,
+                               "public delegate void Test1();{0}{0}", Writer.NewLine), code);
+               }
+
+               [Test]
+               public override void MethodImplementationTypes ()
+               {
+                       string code = GenerateMethodImplementationTypes ();
+                       Assert.AreEqual (string.Format (CultureInfo.InvariantCulture,
+                               "public delegate void Test1();{0}{0}", Writer.NewLine), code);
+               }
+
+               [Test]
+               public override void MethodOverloadsTest1 ()
+               {
+                       string code = GenerateMethodOverloads1 ();
+                       Assert.AreEqual (string.Format (CultureInfo.InvariantCulture,
+                               "public delegate void Test1();{0}{0}", Writer.NewLine), code);
+               }
+
+               [Test]
+               public override void MethodOverloadsTest2 ()
+               {
+                       string code = GenerateMethodOverloads2 ();
+                       Assert.AreEqual (string.Format (CultureInfo.InvariantCulture,
+                               "public delegate void Test1();{0}{0}{0}", Writer.NewLine), code);
+               }
+
+               [Test]
+               public override void MethodOverloadsTest3 ()
+               {
+                       string code = GenerateMethodOverloads3 ();
+                       Assert.AreEqual (string.Format (CultureInfo.InvariantCulture,
+                               "public delegate void Test1();{0}{0}{0}", Writer.NewLine), code);
+               }
+
+               [Test]
+               public override void MethodPrivateImplementationType ()
+               {
+                       string code = GenerateMethodPrivateImplementationType ();
+                       Assert.AreEqual (string.Format (CultureInfo.InvariantCulture,
+                               "public delegate void Test1();{0}{0}", Writer.NewLine), code);
+               }
+
+               [Test]
+               public override void MethodImplementationTypeOrder ()
+               {
+                       string code = GenerateMethodImplementationTypeOrder ();
+                       Assert.AreEqual (string.Format (CultureInfo.InvariantCulture,
+                               "public delegate void Test1();{0}{0}", Writer.NewLine), code);
+               }
+
+               [Test]
+               public override void MethodReturnTypeAttributes ()
+               {
+                       string code = GenerateMethodReturnTypeAttributes ();
+                       Assert.AreEqual (string.Format (CultureInfo.InvariantCulture,
+                               "public delegate void Test1();{0}{0}", Writer.NewLine), code);
+               }
+
+               [Test]
+               public override void ConstructorAttributesTest ()
+               {
+                       string code = GenerateConstructorAttributes ();
+                       Assert.AreEqual (string.Format (CultureInfo.InvariantCulture,
+                               "public delegate void Test1();{0}{0}", Writer.NewLine), code);
+               }
+
+               [Test]
+               public override void ConstructorParametersTest ()
+               {
+                       string code = GenerateConstructorParameters ();
+                       Assert.AreEqual (string.Format (CultureInfo.InvariantCulture,
+                               "public delegate void Test1();{0}{0}", Writer.NewLine), code);
+               }
+
+               [Test]
+               public override void ConstructorParameterAttributesTest ()
+               {
+                       string code = GenerateConstructorParameterAttributes ();
+                       Assert.AreEqual (string.Format (CultureInfo.InvariantCulture,
+                               "public delegate void Test1();{0}{0}", Writer.NewLine), code);
+               }
+
+               [Test]
+               public override void BaseConstructorSingleArg ()
+               {
+                       string code = GenerateBaseConstructor (false);
+                       Assert.AreEqual (string.Format (CultureInfo.InvariantCulture,
+                               "public delegate void Test1();{0}{0}", Writer.NewLine), code);
+               }
+
+               [Test]
+               public override void BaseConstructorMultipleArgs ()
+               {
+                       string code = GenerateBaseConstructor (true);
+                       Assert.AreEqual (string.Format (CultureInfo.InvariantCulture,
+                               "public delegate void Test1();{0}{0}", Writer.NewLine), code);
+               }
+
+               [Test]
+               public override void ChainedConstructorSingleArg ()
+               {
+                       string code = GenerateChainedConstructor (false);
+                       Assert.AreEqual (string.Format (CultureInfo.InvariantCulture,
+                               "public delegate void Test1();{0}{0}", Writer.NewLine), code);
+               }
+
+               [Test]
+               public override void ChainedConstructorMultipleArgs ()
+               {
+                       string code = GenerateChainedConstructor (true);
+                       Assert.AreEqual (string.Format (CultureInfo.InvariantCulture,
+                               "public delegate void Test1();{0}{0}", Writer.NewLine), code);
+               }
+
+               [Test]
+               public override void TypeConstructorTest ()
+               {
+                       string code = GenerateTypeConstructor ();
+                       Assert.AreEqual (string.Format (CultureInfo.InvariantCulture,
+                               "public delegate void Test1();{0}{0}", Writer.NewLine), code);
+               }
+
+               #endregion Override implementation of CodeGeneratorFromTypeTestBase
+       }
+
+       [TestFixture]
+       public class CodeGeneratorFromTypeTest_Interface : CodeGeneratorFromTypeTestBase
+       {
+               private CodeTypeDeclaration _typeDeclaration;
+               private ICodeGenerator _codeGenerator;
+
+               #region Override implementation of CodeGeneratorTestBase
+
+               protected override ICodeGenerator CodeGenerator
+               {
+                       get { return _codeGenerator; }
+               }
+
+               [SetUp]
+               public override void SetUp ()
+               {
+                       base.SetUp ();
+                       _typeDeclaration = new CodeTypeDeclaration ();
+                       _typeDeclaration.IsInterface = true;
+
+                       CodeDomProvider provider = new CSharpCodeProvider ();
+                       _codeGenerator = provider.CreateGenerator ();
+               }
+
+               #endregion Override implementation of CodeGeneratorTestBase
+
+               #region Override implementation of CodeGeneratorFromTypeTestBase
+
+               protected override CodeTypeDeclaration TypeDeclaration
+               {
+                       get { return _typeDeclaration; }
+               }
+
+               [Test]
+               public override void DefaultTypeTest ()
+               {
+                       string code = GenerateDefaultType ();
+                       Assert.AreEqual (string.Format (CultureInfo.InvariantCulture,
+                               "public interface  {{{0}" +
+                               "}}{0}", Writer.NewLine), code);
+               }
+
+               [Test]
+               [ExpectedException (typeof (NullReferenceException))]
+               public override void NullTypeTest ()
+               {
+                       GenerateNullType ();
+               }
+
+               [Test]
+               public override void SimpleTypeTest ()
+               {
+                       string code = GenerateSimpleType ();
+                       Assert.AreEqual (string.Format (CultureInfo.InvariantCulture,
+                               "public interface Test1 {{{0}" +
+                               "}}{0}", Writer.NewLine), code);
+               }
+
+               [Test]
+               public override void DerivedTypeTest ()
+               {
+                       string code = GenerateDerivedType ();
+                       Assert.AreEqual (string.Format (CultureInfo.InvariantCulture,
+#if NET_2_0
+                               "internal interface Test1 : int, System.Security.Principal.IIdentity, string, System.Security.IPermission {{{0}" +
+#else
+                               "interface Test1 : int, System.Security.Principal.IIdentity, string, System.Security.IPermission {{{0}" +
+#endif
+                               "}}{0}", Writer.NewLine), code);
+               }
+
+               [Test]
+               public override void AttributesAndTypeTest ()
+               {
+                       string code = GenerateAttributesAndType ();
+                       Assert.AreEqual (string.Format (CultureInfo.InvariantCulture,
+                               "[A()]{0}" +
+                               "[B()]{0}" +
+                               "public interface Test1 {{{0}" +
+                               "}}{0}", Writer.NewLine), code);
+               }
+
+               [Test]
+               public override void EventMembersTypeTest1 ()
+               {
+                       string code = GenerateEventMembersType1 ();
+                       Assert.AreEqual (string.Format (CultureInfo.InvariantCulture,
+                               "public interface Test1 {{{0}" +
+                               "    {0}" +
+                               "    [A()]{0}" +
+                               "    [B()]{0}" +
+                               "    private event void ;{0}" +
+                               "}}{0}", Writer.NewLine), code);
+               }
+
+               [Test]
+               public override void EventMembersTypeTest2 ()
+               {
+                       string code = GenerateEventMembersType2 ();
+                       Assert.AreEqual (string.Format (CultureInfo.InvariantCulture,
+                               "public interface Test1 {{{0}" +
+                               "    {0}" +
+                               "    public event int Click;{0}" +
+                               "}}{0}", Writer.NewLine), code);
+               }
+
+               [Test]
+               public override void EventImplementationTypes ()
+               {
+                       string code = GenerateEventImplementationTypes ();
+                       Assert.AreEqual (string.Format (CultureInfo.InvariantCulture,
+                               "public interface Test1 {{{0}" +
+                               "    {0}" +
+#if NET_2_0
+                               "    internal event int Click;{0}" +
+#else
+                               "    /*FamANDAssem*/ internal event int Click;{0}" +
+#endif
+                               "}}{0}", Writer.NewLine), code);
+               }
+
+               [Test]
+               public override void EventPrivateImplementationType ()
+               {
+                       string code = GenerateEventPrivateImplementationType ();
+                       Assert.AreEqual (string.Format (CultureInfo.InvariantCulture,
+                               "public interface Test1 {{{0}" +
+                               "    {0}" +
+                               "    event int System.Int32.Click;{0}" +
+                               "}}{0}", Writer.NewLine), code);
+               }
+
+               [Test]
+               public override void EventImplementationTypeOrder ()
+               {
+                       string code = GenerateEventImplementationTypeOrder ();
+                       Assert.AreEqual (string.Format (CultureInfo.InvariantCulture,
+                               "public interface Test1 {{{0}" +
+                               "    {0}" +
+                               "    event int System.Int32.Click;{0}" +
+                               "}}{0}", Writer.NewLine), code);
+               }
+
+               [Test]
+               public override void FieldMembersTypeTest1 ()
+               {
+                       string code = GenerateFieldMembersType1 ();
+                       Assert.AreEqual (string.Format (CultureInfo.InvariantCulture,
+                               "public interface Test1 {{{0}" +
+                               "    {0}" +
+                               "}}{0}", Writer.NewLine), code);
+               }
+
+               [Test]
+               public override void FieldMembersTypeTest2 ()
+               {
+                       string code = GenerateFieldMembersType2 ();
+                       Assert.AreEqual (string.Format (CultureInfo.InvariantCulture,
+                               "public interface Test1 {{{0}" +
+                               "    {0}" +
+                               "}}{0}", Writer.NewLine), code);
+               }
+
+               [Test]
+               public override void PropertyMembersTypeTest1 ()
+               {
+                       string code = GeneratePropertyMembersAttributes ();
+                       Assert.AreEqual (string.Format (CultureInfo.InvariantCulture,
+                               "public interface Test1 {{{0}" +
+                               "    {0}" +
+                               "    [A()]{0}" +
+                               "    [B()]{0}" +
+                               "    void  {{{0}" +
+                               "    }}{0}" +
+                               "}}{0}", Writer.NewLine), code);
+               }
+
+               [Test]
+               public override void PropertyMembersTypeTest2 ()
+               {
+                       string code = GeneratePropertyMembersType (MemberAttributes.Public,
+                               false, false);
+                       Assert.AreEqual (string.Format (CultureInfo.InvariantCulture,
+                               "public interface Test1 {{{0}" +
+                               "    {0}" +
+                               "    int Name {{{0}" +
+                               "    }}{0}" +
+                               "}}{0}", Writer.NewLine), code);
+               }
+
+               [Test]
+               public override void PropertyMembersTypeGetOnly ()
+               {
+                       string code = GeneratePropertyMembersType (MemberAttributes.Family,
+                               true, false);
+                       Assert.AreEqual (string.Format (CultureInfo.InvariantCulture,
+                               "public interface Test1 {{{0}" +
+                               "    {0}" +
+                               "    int Name {{{0}" +
+                               "        get;{0}" +
+                               "    }}{0}" +
+                               "}}{0}", Writer.NewLine), code);
+               }
+
+               [Test]
+               public override void PropertyMembersTypeSetOnly ()
+               {
+                       string code = GeneratePropertyMembersType (MemberAttributes.Assembly,
+                               false, true);
+                       Assert.AreEqual (string.Format (CultureInfo.InvariantCulture,
+                               "public interface Test1 {{{0}" +
+                               "    {0}" +
+                               "    int Name {{{0}" +
+                               "        set;{0}" +
+                               "    }}{0}" +
+                               "}}{0}", Writer.NewLine), code);
+               }
+
+               [Test]
+               public override void PropertyMembersTypeGetSet ()
+               {
+                       string code = GeneratePropertyMembersType (MemberAttributes.Family,
+                               true, true);
+                       Assert.AreEqual (string.Format (CultureInfo.InvariantCulture,
+                               "public interface Test1 {{{0}" +
+                               "    {0}" +
+                               "    int Name {{{0}" +
+                               "        get;{0}" +
+                               "        set;{0}" +
+                               "    }}{0}" +
+                               "}}{0}", Writer.NewLine), code);
+               }
+
+               [Test]
+               public override void PropertyMembersTypeFamilyOrAssembly ()
+               {
+                       string code = GeneratePropertyMembersType (MemberAttributes.FamilyOrAssembly,
+                               false, false);
+                       Assert.AreEqual (string.Format (CultureInfo.InvariantCulture,
+                               "public interface Test1 {{{0}" +
+                               "    {0}" +
+                               "    int Name {{{0}" +
+                               "    }}{0}" +
+                               "}}{0}", Writer.NewLine), code);
+               }
+
+               [Test]
+               public override void PropertyMembersTypeAssembly ()
+               {
+                       string code = GeneratePropertyMembersType (MemberAttributes.Assembly,
+                               false, false);
+                       Assert.AreEqual (string.Format (CultureInfo.InvariantCulture,
+                               "public interface Test1 {{{0}" +
+                               "    {0}" +
+                               "    int Name {{{0}" +
+                               "    }}{0}" +
+                               "}}{0}", Writer.NewLine), code);
+               }
+
+               [Test]
+               public override void PropertyParametersTest ()
+               {
+                       string code = GeneratePropertyParameters ();
+                       Assert.AreEqual (string.Format (CultureInfo.InvariantCulture,
+                               "public interface Test1 {{{0}" +
+                               "    {0}" +
+                               "    int Name {{{0}" +
+                               "    }}{0}" +
+                               "}}{0}", Writer.NewLine), code);
+               }
+
+               [Test]
+               public override void PropertyIndexerTest1 ()
+               {
+                       string code = GeneratePropertyIndexer (MemberAttributes.Public,
+                               false, false, true);
+                       Assert.AreEqual (string.Format (CultureInfo.InvariantCulture,
+                               "public interface Test1 {{{0}" +
+                               "    {0}" +
+                               "    int this[object value1, ref int value2] {{{0}" +
+                               "    }}{0}" +
+                               "}}{0}", Writer.NewLine), code);
+               }
+
+               [Test]
+               public override void PropertyIndexerTest2 ()
+               {
+                       string code = GeneratePropertyIndexer (MemberAttributes.Public,
+                               false, false, false);
+                       Assert.AreEqual (string.Format (CultureInfo.InvariantCulture,
+                               "public interface Test1 {{{0}" +
+                               "    {0}" +
+                               "    int iTem {{{0}" +
+                               "    }}{0}" +
+                               "}}{0}", Writer.NewLine), code);
+               }
+
+               [Test]
+               public override void PropertyIndexerGetOnly ()
+               {
+                       string code = GeneratePropertyIndexer (MemberAttributes.Family,
+                               true, false, true);
+                       Assert.AreEqual (string.Format (CultureInfo.InvariantCulture,
+                               "public interface Test1 {{{0}" +
+                               "    {0}" +
+                               "    int this[object value1, ref int value2] {{{0}" +
+                               "        get;{0}" +
+                               "    }}{0}" +
+                               "}}{0}", Writer.NewLine), code);
+               }
+
+               [Test]
+               public override void PropertyIndexerSetOnly ()
+               {
+                       string code = GeneratePropertyIndexer (MemberAttributes.Family,
+                               false, true, true);
+                       Assert.AreEqual (string.Format (CultureInfo.InvariantCulture,
+                               "public interface Test1 {{{0}" +
+                               "    {0}" +
+                               "    int this[object value1, ref int value2] {{{0}" +
+                               "        set;{0}" +
+                               "    }}{0}" +
+                               "}}{0}", Writer.NewLine), code);
+               }
+
+               [Test]
+               public override void PropertyImplementationTypes ()
+               {
+                       string code = GeneratePropertyImplementationTypes ();
+                       Assert.AreEqual (string.Format (CultureInfo.InvariantCulture,
+                               "public interface Test1 {{{0}" +
+                               "    {0}" +
+                               "    int Name {{{0}" +
+                               "    }}{0}" +
+                               "}}{0}", Writer.NewLine), code);
+               }
+
+               [Test]
+               public override void PropertyOverloadsTest1 ()
+               {
+                       string code = GeneratePropertyOverloads1 ();
+                       Assert.AreEqual (string.Format (CultureInfo.InvariantCulture,
+                               "public interface Test1 {{{0}" +
+                               "    {0}" +
+                               "    int Name {{{0}" +
+                               "    }}{0}" +
+                               "}}{0}", Writer.NewLine), code);
+               }
+
+               [Test]
+               public override void PropertyOverloadsTest2 ()
+               {
+                       string code = GeneratePropertyOverloads2 ();
+                       Assert.AreEqual (string.Format (CultureInfo.InvariantCulture,
+                               "public interface Test1 {{{0}" +
+                               "    {0}" +
+                               "    int Name {{{0}" +
+                               "    }}{0}" +
+                               "    {0}" +
+                               "    int Name {{{0}" +
+                               "    }}{0}" +
+                               "}}{0}", Writer.NewLine), code);
+               }
+
+               [Test]
+               public override void PropertyOverloadsTest3 ()
+               {
+                       string code = GeneratePropertyOverloads3 ();
+                       Assert.AreEqual (string.Format (CultureInfo.InvariantCulture,
+                               "public interface Test1 {{{0}" +
+                               "    {0}" +
+                               "    int Name {{{0}" +
+                               "    }}{0}" +
+                               "    {0}" +
+                               "    int Name {{{0}" +
+                               "    }}{0}" +
+                               "}}{0}", Writer.NewLine), code);
+               }
+
+               [Test]
+               public override void PropertyPrivateImplementationType ()
+               {
+                       string code = GeneratePropertyPrivateImplementationType ();
+                       Assert.AreEqual (string.Format (CultureInfo.InvariantCulture,
+                               "public interface Test1 {{{0}" +
+                               "    {0}" +
+                               "    int this[object value1] {{{0}" +
+                               "    }}{0}" +
+                               "}}{0}", Writer.NewLine), code);
+               }
+
+               [Test]
+               public override void PropertyImplementationTypeOrder ()
+               {
+                       string code = GeneratePropertyImplementationTypeOrder ();
+                       Assert.AreEqual (string.Format (CultureInfo.InvariantCulture,
+                               "public interface Test1 {{{0}" +
+                               "    {0}" +
+                               "    int this[object value1] {{{0}" +
+                               "    }}{0}" +
+                               "}}{0}", Writer.NewLine), code);
+               }
+
+               [Test]
+               public override void MethodMembersTypeTest1 ()
+               {
+                       string code = GenerateMethodMembersType1 ();
+                       Assert.AreEqual (string.Format (CultureInfo.InvariantCulture,
+                               "public interface Test1 {{{0}" +
+                               "    {0}" +
+                               "    [A()]{0}" +
+                               "    [B()]{0}" +
+                               "    void ();{0}" +
+                               "}}{0}", Writer.NewLine), code);
+               }
+
+               [Test]
+               public override void MethodMembersTypeTest2 ()
+               {
+                       string code = GenerateMethodMembersType2 ();
+                       Assert.AreEqual (string.Format (CultureInfo.InvariantCulture,
+                               "public interface Test1 {{{0}" +
+                               "    {0}" +
+                               "    int Something(object value1, object value2, out int index, ref int count);{0}" +
+                               "}}{0}", Writer.NewLine), code);
+               }
+
+               [Test]
+               public override void MethodMembersTypeTest3 ()
+               {
+                       string code = GenerateMethodMembersType3 ();
+                       Assert.AreEqual (string.Format (CultureInfo.InvariantCulture,
+                               "public interface Test1 {{{0}" +
+                               "    {0}" +
+                               "    int Something([A()] [B()] object value, [C(A1=false, A2=true)] [D()] out int index);{0}" +
+                               "}}{0}", Writer.NewLine), code);
+               }
+
+               [Test]
+               public override void MethodImplementationTypes ()
+               {
+                       string code = GenerateMethodImplementationTypes ();
+                       Assert.AreEqual (string.Format (CultureInfo.InvariantCulture,
+                               "public interface Test1 {{{0}" +
+                               "    {0}" +
+                               "    int Execute();{0}" +
+                               "}}{0}", Writer.NewLine), code);
+               }
+
+               [Test]
+               public override void MethodOverloadsTest1 ()
+               {
+                       string code = GenerateMethodOverloads1 ();
+                       Assert.AreEqual (string.Format (CultureInfo.InvariantCulture,
+                               "public interface Test1 {{{0}" +
+                               "    {0}" +
+                               "    int Execute();{0}" +
+                               "}}{0}", Writer.NewLine), code);
+               }
+
+               [Test]
+               public override void MethodOverloadsTest2 ()
+               {
+                       string code = GenerateMethodOverloads2 ();
+                       Assert.AreEqual (string.Format (CultureInfo.InvariantCulture,
+                               "public interface Test1 {{{0}" +
+                               "    {0}" +
+                               "    void Execute();{0}" +
+                               "    {0}" +
+                               "    int Execute(object value1);{0}" +
+                               "}}{0}", Writer.NewLine), code);
+               }
+
+               [Test]
+               public override void MethodOverloadsTest3 ()
+               {
+                       string code = GenerateMethodOverloads3 ();
+                       Assert.AreEqual (string.Format (CultureInfo.InvariantCulture,
+                               "public interface Test1 {{{0}" +
+                               "    {0}" +
+                               "    void Execute();{0}" +
+                               "    {0}" +
+                               "    int System.Int32.Execute(object value1);{0}" +
+                               "}}{0}", Writer.NewLine), code);
+               }
+
+               [Test]
+               public override void MethodPrivateImplementationType ()
+               {
+                       string code = GenerateMethodPrivateImplementationType ();
+                       Assert.AreEqual (string.Format (CultureInfo.InvariantCulture,
+                               "public interface Test1 {{{0}" +
+                               "    {0}" +
+                               "    int System.Int32.Execute(object value1);{0}" +
+                               "}}{0}", Writer.NewLine), code);
+               }
+
+               [Test]
+               public override void MethodImplementationTypeOrder ()
+               {
+                       string code = GenerateMethodImplementationTypeOrder ();
+                       Assert.AreEqual (string.Format (CultureInfo.InvariantCulture,
+                               "public interface Test1 {{{0}" +
+                               "    {0}" +
+                               "    int System.Int32.Execute(object value1);{0}" +
+                               "}}{0}", Writer.NewLine), code);
+               }
+
+               [Test]
+               public override void MethodReturnTypeAttributes ()
+               {
+                       string code = GenerateMethodReturnTypeAttributes ();
+                       Assert.AreEqual (string.Format (CultureInfo.InvariantCulture,
+                               "public interface Test1 {{{0}" +
+                               "    {0}" +
+                               "    [A()]{0}" +
+                               "    [B()]{0}" +
+                               "    [return: C(A1=false, A2=true)]{0}" +
+                               "    [return: D()]{0}" +
+                               "    int Execute();{0}" +
+                               "}}{0}", Writer.NewLine), code);
+               }
+
+               [Test]
+               public override void ConstructorAttributesTest ()
+               {
+                       string code = GenerateConstructorAttributes ();
+                       Assert.AreEqual (string.Format (CultureInfo.InvariantCulture,
+                               "public interface Test1 {{{0}" +
+                               "    {0}" +
+                               "}}{0}", Writer.NewLine), code);
+               }
+
+               [Test]
+               public override void ConstructorParametersTest ()
+               {
+                       string code = GenerateConstructorParameters ();
+                       Assert.AreEqual (string.Format (CultureInfo.InvariantCulture,
+                               "public interface Test1 {{{0}" +
+                               "    {0}" +
+                               "}}{0}", Writer.NewLine), code);
+               }
+
+               [Test]
+               public override void ConstructorParameterAttributesTest ()
+               {
+                       string code = GenerateConstructorParameterAttributes ();
+                       Assert.AreEqual (string.Format (CultureInfo.InvariantCulture,
+                               "public interface Test1 {{{0}" +
+                               "    {0}" +
+                               "}}{0}", Writer.NewLine), code);
+               }
+
+               [Test]
+               public override void BaseConstructorSingleArg ()
+               {
+                       string code = GenerateBaseConstructor (false);
+                       Assert.AreEqual (string.Format (CultureInfo.InvariantCulture,
+                               "public interface Test1 {{{0}" +
+                               "    {0}" +
+                               "}}{0}", Writer.NewLine), code);
+               }
+
+               [Test]
+               public override void BaseConstructorMultipleArgs ()
+               {
+                       string code = GenerateBaseConstructor (true);
+                       Assert.AreEqual (string.Format (CultureInfo.InvariantCulture,
+                               "public interface Test1 {{{0}" +
+                               "    {0}" +
+                               "}}{0}", Writer.NewLine), code);
+               }
+
+               [Test]
+               public override void ChainedConstructorSingleArg ()
+               {
+                       string code = GenerateChainedConstructor (false);
+                       Assert.AreEqual (string.Format (CultureInfo.InvariantCulture,
+                               "public interface Test1 {{{0}" +
+                               "    {0}" +
+                               "}}{0}", Writer.NewLine), code);
+               }
+
+               [Test]
+               public override void ChainedConstructorMultipleArgs ()
+               {
+                       string code = GenerateChainedConstructor (true);
+                       Assert.AreEqual (string.Format (CultureInfo.InvariantCulture,
+                               "public interface Test1 {{{0}" +
+                               "    {0}" +
+                               "}}{0}", Writer.NewLine), code);
+               }
+
+               [Test]
+               public override void TypeConstructorTest ()
+               {
+                       string code = GenerateTypeConstructor ();
+                       Assert.AreEqual (string.Format (CultureInfo.InvariantCulture,
+                               "public interface Test1 {{{0}" +
+                               "    {0}" +
+                               "}}{0}", Writer.NewLine), code);
+               }
+
+               #endregion Override implementation of CodeGeneratorFromTypeTestBase
+       }
+
+       [TestFixture]
+       public class CodeGeneratorFromTypeTest_Struct : CodeGeneratorFromTypeTestBase
+       {
+               private CodeTypeDeclaration _typeDeclaration;
+               private ICodeGenerator _codeGenerator;
+
+               #region Override implementation of CodeGeneratorTestBase
+
+               protected override ICodeGenerator CodeGenerator
+               {
+                       get { return _codeGenerator; }
+               }
+
+               [SetUp]
+               public override void SetUp ()
+               {
+                       base.SetUp ();
+                       _typeDeclaration = new CodeTypeDeclaration ();
+                       _typeDeclaration.IsStruct = true;
+
+                       CodeDomProvider provider = new CSharpCodeProvider ();
+                       _codeGenerator = provider.CreateGenerator ();
+               }
+
+               #endregion Override implementation of CodeGeneratorTestBase
+
+               #region Override implementation of CodeGeneratorFromTypeTestBase
+
+               protected override CodeTypeDeclaration TypeDeclaration
+               {
+                       get { return _typeDeclaration; }
+               }
+
+               [Test]
+               public override void DefaultTypeTest ()
+               {
+                       string code = GenerateDefaultType ();
+                       Assert.AreEqual (string.Format (CultureInfo.InvariantCulture,
+                               "public struct  {{{0}" +
+                               "}}{0}", Writer.NewLine), code);
+               }
+
+               [Test]
+               [ExpectedException (typeof (NullReferenceException))]
+               public override void NullTypeTest ()
+               {
+                       GenerateNullType ();
+               }
+
+               [Test]
+               public override void SimpleTypeTest ()
+               {
+                       string code = GenerateSimpleType ();
+                       Assert.AreEqual (string.Format (CultureInfo.InvariantCulture,
+                               "public struct Test1 {{{0}" +
+                               "}}{0}", Writer.NewLine), code);
+               }
+
+               [Test]
+               public override void DerivedTypeTest ()
+               {
+                       string code = GenerateDerivedType ();
+                       Assert.AreEqual (string.Format (CultureInfo.InvariantCulture,
+#if NET_2_0
+                               "internal struct Test1 : int, System.Security.Principal.IIdentity, string, System.Security.IPermission {{{0}" +
+#else
+                               "struct Test1 : int, System.Security.Principal.IIdentity, string, System.Security.IPermission {{{0}" +
+#endif
+                               "}}{0}", Writer.NewLine), code);
+               }
+
+               [Test]
+               public override void AttributesAndTypeTest ()
+               {
+                       string code = GenerateAttributesAndType ();
+                       Assert.AreEqual (string.Format (CultureInfo.InvariantCulture,
+                               "[A()]{0}" +
+                               "[B()]{0}" +
+                               "public struct Test1 {{{0}" +
+                               "}}{0}", Writer.NewLine), code);
+               }
+
+               [Test]
+               public override void EventMembersTypeTest1 ()
+               {
+                       string code = GenerateEventMembersType1 ();
+                       Assert.AreEqual (string.Format (CultureInfo.InvariantCulture,
+                               "public struct Test1 {{{0}" +
+                               "    {0}" +
+                               "    [A()]{0}" +
+                               "    [B()]{0}" +
+                               "    private event void ;{0}" +
+                               "}}{0}", Writer.NewLine), code);
+               }
+
+               [Test]
+               public override void EventMembersTypeTest2 ()
+               {
+                       string code = GenerateEventMembersType2 ();
+                       Assert.AreEqual (string.Format (CultureInfo.InvariantCulture,
+                               "public struct Test1 {{{0}" +
+                               "    {0}" +
+                               "    public event int Click;{0}" +
+                               "}}{0}", Writer.NewLine), code);
+               }
+
+               [Test]
+               public override void EventImplementationTypes ()
+               {
+                       string code = GenerateEventImplementationTypes ();
+                       Assert.AreEqual (string.Format (CultureInfo.InvariantCulture,
+                               "public struct Test1 {{{0}" +
+                               "    {0}" +
+#if NET_2_0
+                               "    internal event int Click;{0}" +
+#else
+                               "    /*FamANDAssem*/ internal event int Click;{0}" +
+#endif
+                               "}}{0}", Writer.NewLine), code);
+               }
+
+               [Test]
+               public override void EventPrivateImplementationType ()
+               {
+                       string code = GenerateEventPrivateImplementationType ();
+                       Assert.AreEqual (string.Format (CultureInfo.InvariantCulture,
+                               "public struct Test1 {{{0}" +
+                               "    {0}" +
+                               "    event int System.Int32.Click;{0}" +
+                               "}}{0}", Writer.NewLine), code);
+               }
+
+               [Test]
+               public override void EventImplementationTypeOrder ()
+               {
+                       string code = GenerateEventImplementationTypeOrder ();
+                       Assert.AreEqual (string.Format (CultureInfo.InvariantCulture,
+                               "public struct Test1 {{{0}" +
+                               "    {0}" +
+                               "    event int System.Int32.Click;{0}" +
+                               "}}{0}", Writer.NewLine), code);
+               }
+
+               [Test]
+               public override void FieldMembersTypeTest1 ()
+               {
+                       string code = GenerateFieldMembersType1 ();
+                       Assert.AreEqual (string.Format (CultureInfo.InvariantCulture,
+                               "public struct Test1 {{{0}" +
+                               "    {0}" +
+                               "    [A()]{0}" +
+                               "    [B()]{0}" +
+                               "    private void ;{0}" +
+                               "}}{0}", Writer.NewLine), code);
+               }
+
+               [Test]
+               public override void FieldMembersTypeTest2 ()
+               {
+                       string code = GenerateFieldMembersType2 ();
+                       Assert.AreEqual (string.Format (CultureInfo.InvariantCulture,
+                               "public struct Test1 {{{0}" +
+                               "    {0}" +
+                               "    public int Name = 2;{0}" +
+                               "}}{0}", Writer.NewLine), code);
+               }
+
+               [Test]
+               public override void PropertyMembersTypeTest1 ()
+               {
+                       string code = GeneratePropertyMembersAttributes ();
+                       Assert.AreEqual (string.Format (CultureInfo.InvariantCulture,
+                               "public struct Test1 {{{0}" +
+                               "    {0}" +
+                               "    [A()]{0}" +
+                               "    [B()]{0}" +
+                               "    private void  {{{0}" +
+                               "    }}{0}" +
+                               "}}{0}", Writer.NewLine), code);
+               }
+
+               [Test]
+               public override void PropertyMembersTypeTest2 ()
+               {
+                       string code = GeneratePropertyMembersType (MemberAttributes.Public,
+                               false, false);
+                       Assert.AreEqual (string.Format (CultureInfo.InvariantCulture,
+                               "public struct Test1 {{{0}" +
+                               "    {0}" +
+                               "    public virtual int Name {{{0}" +
+                               "    }}{0}" +
+                               "}}{0}", Writer.NewLine), code);
+               }
+
+               [Test]
+               public override void PropertyMembersTypeGetOnly ()
+               {
+                       string code = GeneratePropertyMembersType (MemberAttributes.Family,
+                               true, false);
+                       Assert.AreEqual (string.Format (CultureInfo.InvariantCulture,
+                               "public struct Test1 {{{0}" +
+                               "    {0}" +
+                               "    protected virtual int Name {{{0}" +
+                               "        get {{{0}" +
+                               "        }}{0}" +
+                               "    }}{0}" +
+                               "}}{0}", Writer.NewLine), code);
+               }
+
+               [Test]
+               public override void PropertyMembersTypeSetOnly ()
+               {
+                       string code = GeneratePropertyMembersType (MemberAttributes.Assembly,
+                               false, true);
+                       Assert.AreEqual (string.Format (CultureInfo.InvariantCulture,
+                               "public struct Test1 {{{0}" +
+                               "    {0}" +
+#if NET_2_0
+                               "    internal virtual int Name {{{0}" +
+#else
+                               "    internal int Name {{{0}" +
+#endif
+                               "        set {{{0}" +
+                               "        }}{0}" +
+                               "    }}{0}" +
+                               "}}{0}", Writer.NewLine), code);
+               }
+
+               [Test]
+               public override void PropertyMembersTypeGetSet ()
+               {
+                       string code = GeneratePropertyMembersType (MemberAttributes.Family,
+                               true, true);
+                       Assert.AreEqual (string.Format (CultureInfo.InvariantCulture,
+                               "public struct Test1 {{{0}" +
+                               "    {0}" +
+                               "    protected virtual int Name {{{0}" +
+                               "        get {{{0}" +
+                               "        }}{0}" +
+                               "        set {{{0}" +
+                               "        }}{0}" +
+                               "    }}{0}" +
+                               "}}{0}", Writer.NewLine), code);
+               }
+
+               [Test]
+               public override void PropertyMembersTypeFamilyOrAssembly ()
+               {
+                       string code = GeneratePropertyMembersType (MemberAttributes.FamilyOrAssembly,
+                               false, false);
+                       Assert.AreEqual (string.Format (CultureInfo.InvariantCulture,
+                               "public struct Test1 {{{0}" +
+                               "    {0}" +
+                               "    protected internal int Name {{{0}" +
+                               "    }}{0}" +
+                               "}}{0}", Writer.NewLine), code);
+               }
+
+               [Test]
+               public override void PropertyMembersTypeAssembly ()
+               {
+                       string code = GeneratePropertyMembersType (MemberAttributes.Assembly,
+                               false, false);
+                       Assert.AreEqual (string.Format (CultureInfo.InvariantCulture,
+                               "public struct Test1 {{{0}" +
+                               "    {0}" +
+#if NET_2_0
+                               "    internal virtual int Name {{{0}" +
+#else
+                               "    internal int Name {{{0}" +
+#endif
+                               "    }}{0}" +
+                               "}}{0}", Writer.NewLine), code);
+               }
+
+               [Test]
+               public override void PropertyParametersTest ()
+               {
+                       string code = GeneratePropertyParameters ();
+                       Assert.AreEqual (string.Format (CultureInfo.InvariantCulture,
+                               "public struct Test1 {{{0}" +
+                               "    {0}" +
+                               "    public virtual int Name {{{0}" +
+                               "    }}{0}" +
+                               "}}{0}", Writer.NewLine), code);
+               }
+
+               [Test]
+               public override void PropertyIndexerTest1 ()
+               {
+                       string code = GeneratePropertyIndexer (MemberAttributes.Public,
+                               false, false, true);
+                       Assert.AreEqual (string.Format (CultureInfo.InvariantCulture,
+                               "public struct Test1 {{{0}" +
+                               "    {0}" +
+                               "    public virtual int this[object value1, ref int value2] {{{0}" +
+                               "    }}{0}" +
+                               "}}{0}", Writer.NewLine), code);
+               }
+
+               [Test]
+               public override void PropertyIndexerTest2 ()
+               {
+                       string code = GeneratePropertyIndexer (MemberAttributes.Public,
+                               false, false, false);
+                       Assert.AreEqual (string.Format (CultureInfo.InvariantCulture,
+                               "public struct Test1 {{{0}" +
+                               "    {0}" +
+                               "    public virtual int iTem {{{0}" +
+                               "    }}{0}" +
+                               "}}{0}", Writer.NewLine), code);
+               }
+
+               [Test]
+               public override void PropertyIndexerGetOnly ()
+               {
+                       string code = GeneratePropertyIndexer (MemberAttributes.Family,
+                               true, false, true);
+                       Assert.AreEqual (string.Format (CultureInfo.InvariantCulture,
+                               "public struct Test1 {{{0}" +
+                               "    {0}" +
+                               "    protected virtual int this[object value1, ref int value2] {{{0}" +
+                               "        get {{{0}" +
+                               "        }}{0}" +
+                               "    }}{0}" +
+                               "}}{0}", Writer.NewLine), code);
+               }
+
+               [Test]
+               public override void PropertyIndexerSetOnly ()
+               {
+                       string code = GeneratePropertyIndexer (MemberAttributes.Family,
+                               false, true, true);
+                       Assert.AreEqual (string.Format (CultureInfo.InvariantCulture,
+                               "public struct Test1 {{{0}" +
+                               "    {0}" +
+                               "    protected virtual int this[object value1, ref int value2] {{{0}" +
+                               "        set {{{0}" +
+                               "        }}{0}" +
+                               "    }}{0}" +
+                               "}}{0}", Writer.NewLine), code);
+               }
+
+               [Test]
+               public override void PropertyImplementationTypes ()
+               {
+                       string code = GeneratePropertyImplementationTypes ();
+                       Assert.AreEqual (string.Format (CultureInfo.InvariantCulture,
+                               "public struct Test1 {{{0}" +
+                               "    {0}" +
+                               "    public virtual int Name {{{0}" +
+                               "    }}{0}" +
+                               "}}{0}", Writer.NewLine), code);
+               }
+
+               [Test]
+               public override void PropertyOverloadsTest1 ()
+               {
+                       string code = GeneratePropertyOverloads1 ();
+                       Assert.AreEqual (string.Format (CultureInfo.InvariantCulture,
+                               "public struct Test1 {{{0}" +
+                               "    {0}" +
+                               "    public virtual int Name {{{0}" +
+                               "    }}{0}" +
+                               "}}{0}", Writer.NewLine), code);
+               }
+
+               [Test]
+               public override void PropertyOverloadsTest2 ()
+               {
+                       string code = GeneratePropertyOverloads2 ();
+                       Assert.AreEqual (string.Format (CultureInfo.InvariantCulture,
+                               "public struct Test1 {{{0}" +
+                               "    {0}" +
+                               "    public virtual int Name {{{0}" +
+                               "    }}{0}" +
+                               "    {0}" +
+                               "    private int Name {{{0}" +
+                               "    }}{0}" +
+                               "}}{0}", Writer.NewLine), code);
+               }
+
+               [Test]
+               public override void PropertyOverloadsTest3 ()
+               {
+                       string code = GeneratePropertyOverloads3 ();
+                       Assert.AreEqual (string.Format (CultureInfo.InvariantCulture,
+                               "public struct Test1 {{{0}" +
+                               "    {0}" +
+                               "    public virtual int Name {{{0}" +
+                               "    }}{0}" +
+                               "    {0}" +
+                               "    int System.Int32.Name {{{0}" +
+                               "    }}{0}" +
+                               "}}{0}", Writer.NewLine), code);
+               }
+
+               [Test]
+               public override void PropertyPrivateImplementationType ()
+               {
+                       string code = GeneratePropertyPrivateImplementationType ();
+                       Assert.AreEqual (string.Format (CultureInfo.InvariantCulture,
+                               "public struct Test1 {{{0}" +
+                               "    {0}" +
+                               "    int System.Int32.this[object value1] {{{0}" +
+                               "    }}{0}" +
+                               "}}{0}", Writer.NewLine), code);
+               }
+
+               [Test]
+               public override void PropertyImplementationTypeOrder ()
+               {
+                       string code = GeneratePropertyImplementationTypeOrder ();
+                       Assert.AreEqual (string.Format (CultureInfo.InvariantCulture,
+                               "public struct Test1 {{{0}" +
+                               "    {0}" +
+                               "    int System.Int32.this[object value1] {{{0}" +
+                               "    }}{0}" +
+                               "}}{0}", Writer.NewLine), code);
+               }
+
+               [Test]
+               public override void MethodMembersTypeTest1 ()
+               {
+                       string code = GenerateMethodMembersType1 ();
+                       Assert.AreEqual (string.Format (CultureInfo.InvariantCulture,
+                               "public struct Test1 {{{0}" +
+                               "    {0}" +
+                               "    [A()]{0}" +
+                               "    [B()]{0}" +
+                               "    private void () {{{0}" +
+                               "    }}{0}" +
+                               "}}{0}", Writer.NewLine), code);
+               }
+
+               [Test]
+               public override void MethodMembersTypeTest2 ()
+               {
+                       string code = GenerateMethodMembersType2 ();
+                       Assert.AreEqual (string.Format (CultureInfo.InvariantCulture,
+                               "public struct Test1 {{{0}" +
+                               "    {0}" +
+                               "    public virtual int Something(object value1, object value2, out int index, ref int count) {{{0}" +
+                               "    }}{0}" +
+                               "}}{0}", Writer.NewLine), code);
+               }
+
+               [Test]
+               public override void MethodMembersTypeTest3 ()
+               {
+                       string code = GenerateMethodMembersType3 ();
+                       Assert.AreEqual (string.Format (CultureInfo.InvariantCulture,
+                               "public struct Test1 {{{0}" +
+                               "    {0}" +
+                               "    public virtual int Something([A()] [B()] object value, [C(A1=false, A2=true)] [D()] out int index) {{{0}" +
+                               "    }}{0}" +
+                               "}}{0}", Writer.NewLine), code);
+               }
+
+               [Test]
+               public override void MethodImplementationTypes ()
+               {
+                       string code = GenerateMethodImplementationTypes ();
+                       Assert.AreEqual (string.Format (CultureInfo.InvariantCulture,
+                               "public struct Test1 {{{0}" +
+                               "    {0}" +
+#if NET_2_0
+                               "    internal virtual int Execute() {{{0}" +
+#else
+                               "    internal int Execute() {{{0}" +
+#endif
+                               "    }}{0}" +
+                               "}}{0}", Writer.NewLine), code);
+               }
+
+               [Test]
+               public override void MethodOverloadsTest1 ()
+               {
+                       string code = GenerateMethodOverloads1 ();
+                       Assert.AreEqual (string.Format (CultureInfo.InvariantCulture,
+                               "public struct Test1 {{{0}" +
+                               "    {0}" +
+                               "    public virtual int Execute() {{{0}" +
+                               "    }}{0}" +
+                               "}}{0}", Writer.NewLine), code);
+               }
+
+               [Test]
+               public override void MethodOverloadsTest2 ()
+               {
+                       string code = GenerateMethodOverloads2 ();
+                       Assert.AreEqual (string.Format (CultureInfo.InvariantCulture,
+                               "public struct Test1 {{{0}" +
+                               "    {0}" +
+                               "    public virtual void Execute() {{{0}" +
+                               "    }}{0}" +
+                               "    {0}" +
+                               "    private int Execute(object value1) {{{0}" +
+                               "    }}{0}" +
+                               "}}{0}", Writer.NewLine), code);
+               }
+
+               [Test]
+               public override void MethodOverloadsTest3 ()
+               {
+                       string code = GenerateMethodOverloads3 ();
+                       Assert.AreEqual (string.Format (CultureInfo.InvariantCulture,
+                               "public struct Test1 {{{0}" +
+                               "    {0}" +
+                               "    public virtual void Execute() {{{0}" +
+                               "    }}{0}" +
+                               "    {0}" +
+                               "    int System.Int32.Execute(object value1) {{{0}" +
+                               "    }}{0}" +
+                               "}}{0}", Writer.NewLine), code);
+               }
+
+               [Test]
+               public override void MethodPrivateImplementationType ()
+               {
+                       string code = GenerateMethodPrivateImplementationType ();
+                       Assert.AreEqual (string.Format (CultureInfo.InvariantCulture,
+                               "public struct Test1 {{{0}" +
+                               "    {0}" +
+                               "    int System.Int32.Execute(object value1) {{{0}" +
+                               "    }}{0}" +
+                               "}}{0}", Writer.NewLine), code);
+               }
+
+               [Test]
+               public override void MethodImplementationTypeOrder ()
+               {
+                       string code = GenerateMethodImplementationTypeOrder ();
+                       Assert.AreEqual (string.Format (CultureInfo.InvariantCulture,
+                               "public struct Test1 {{{0}" +
+                               "    {0}" +
+                               "    int System.Int32.Execute(object value1) {{{0}" +
+                               "    }}{0}" +
+                               "}}{0}", Writer.NewLine), code);
+               }
+
+               [Test]
+               public override void MethodReturnTypeAttributes ()
+               {
+                       string code = GenerateMethodReturnTypeAttributes ();
+                       Assert.AreEqual (string.Format (CultureInfo.InvariantCulture,
+                               "public struct Test1 {{{0}" +
+                               "    {0}" +
+                               "    [A()]{0}" +
+                               "    [B()]{0}" +
+                               "    [return: C(A1=false, A2=true)]{0}" +
+                               "    [return: D()]{0}" +
+                               "    public virtual int Execute() {{{0}" +
+                               "    }}{0}" +
+                               "}}{0}", Writer.NewLine), code);
+               }
+
+               [Test]
+               public override void ConstructorAttributesTest ()
+               {
+                       string code = GenerateConstructorAttributes ();
+                       Assert.AreEqual (string.Format (CultureInfo.InvariantCulture,
+                               "public struct Test1 {{{0}" +
+                               "    {0}" +
+                               "    [A()]{0}" +
+                               "    [B()]{0}" +
+                               "    private Test1() {{{0}" +
+                               "    }}{0}" +
+                               "}}{0}", Writer.NewLine), code);
+               }
+
+               [Test]
+               public override void ConstructorParametersTest ()
+               {
+                       string code = GenerateConstructorParameters ();
+                       Assert.AreEqual (string.Format (CultureInfo.InvariantCulture,
+                               "public struct Test1 {{{0}" +
+                               "    {0}" +
+                               "    public Test1(object value1, object value2, out int index, ref int count) {{{0}" +
+                               "    }}{0}" +
+                               "}}{0}", Writer.NewLine), code);
+               }
+
+               [Test]
+               public override void ConstructorParameterAttributesTest ()
+               {
+                       string code = GenerateConstructorParameterAttributes ();
+                       Assert.AreEqual (string.Format (CultureInfo.InvariantCulture,
+                               "public struct Test1 {{{0}" +
+                               "    {0}" +
+                               "    public Test1([A()] [B()] object value, [C(A1=false, A2=true)] [D()] out int index) {{{0}" +
+                               "    }}{0}" +
+                               "}}{0}", Writer.NewLine), code);
+               }
+
+               [Test]
+               public override void BaseConstructorSingleArg ()
+               {
+                       string code = GenerateBaseConstructor (false);
+                       Assert.AreEqual (string.Format (CultureInfo.InvariantCulture,
+                               "public struct Test1 {{{0}" +
+                               "    {0}" +
+                               "    public Test1(object value1, out int value2) : {0}" +
+                               "            base(value1) {{{0}" +
+                               "    }}{0}" +
+                               "}}{0}", Writer.NewLine), code);
+               }
+
+               [Test]
+               public override void BaseConstructorMultipleArgs ()
+               {
+                       string code = GenerateBaseConstructor (true);
+                       Assert.AreEqual (string.Format (CultureInfo.InvariantCulture,
+                               "public struct Test1 {{{0}" +
+                               "    {0}" +
+                               "    public Test1(object value1, out int value2) : {0}" +
+                               "            base(value1, value2) {{{0}" +
+                               "    }}{0}" +
+                               "}}{0}", Writer.NewLine), code);
+               }
+
+               [Test]
+               public override void ChainedConstructorSingleArg ()
+               {
+                       string code = GenerateChainedConstructor (false);
+                       Assert.AreEqual (string.Format (CultureInfo.InvariantCulture,
+                               "public struct Test1 {{{0}" +
+                               "    {0}" +
+                               "    public Test1(object value1, out int value2) : {0}" +
+                               "            base(value3) : {0}" +
+                               "            this(value1) {{{0}" +
+                               "    }}{0}" +
+                               "}}{0}", Writer.NewLine), code);
+               }
+
+               [Test]
+               public override void ChainedConstructorMultipleArgs ()
+               {
+                       string code = GenerateChainedConstructor (true);
+                       Assert.AreEqual (string.Format (CultureInfo.InvariantCulture,
+                               "public struct Test1 {{{0}" +
+                               "    {0}" +
+                               "    public Test1(object value1, out int value2) : {0}" +
+                               "            base(value3) : {0}" +
+                               "            this(value1, value2) {{{0}" +
+                               "    }}{0}" +
+                               "}}{0}", Writer.NewLine), code);
+               }
+
+               [Test]
+               public override void TypeConstructorTest ()
+               {
+                       string code = GenerateTypeConstructor ();
+                       Assert.AreEqual (string.Format (CultureInfo.InvariantCulture,
+                               "public struct Test1 {{{0}" +
+                               "    {0}" +
+#if NET_2_0
+                               "    [A()]{0}" +
+                               "    [B()]{0}" +
+#endif
+                               "    static Test1() {{{0}" +
+                               "    }}{0}" +
+                               "}}{0}", Writer.NewLine), code);
+               }
+
+               #endregion Override implementation of CodeGeneratorFromTypeTestBase
+       }
+
+       [TestFixture]
+       public class CodeGeneratorFromTypeTest_Enum : CodeGeneratorFromTypeTestBase
+       {
+               private CodeTypeDeclaration _typeDeclaration;
+               private ICodeGenerator _codeGenerator;
+
+               #region Override implementation of CodeGeneratorTestBase
+
+               protected override ICodeGenerator CodeGenerator
+               {
+                       get { return _codeGenerator; }
+               }
+
+               [SetUp]
+               public override void SetUp ()
+               {
+                       base.SetUp ();
+                       _typeDeclaration = new CodeTypeDeclaration ();
+                       _typeDeclaration.IsEnum = true;
+
+                       CodeDomProvider provider = new CSharpCodeProvider ();
+                       _codeGenerator = provider.CreateGenerator ();
+               }
+
+               #endregion Override implementation of CodeGeneratorTestBase
+
+               #region Override implementation of CodeGeneratorFromTypeTestBase
+
+               protected override CodeTypeDeclaration TypeDeclaration
+               {
+                       get { return _typeDeclaration; }
+               }
+
+               [Test]
+               public override void DefaultTypeTest ()
+               {
+                       string code = GenerateDefaultType ();
+                       Assert.AreEqual (string.Format (CultureInfo.InvariantCulture,
+                               "public enum  {{{0}" +
+                               "}}{0}", Writer.NewLine), code);
+               }
+
+               [Test]
+               [ExpectedException (typeof (NullReferenceException))]
+               public override void NullTypeTest ()
+               {
+                       GenerateNullType ();
+               }
+
+               [Test]
+               public override void SimpleTypeTest ()
+               {
+                       string code = GenerateSimpleType ();
+                       Assert.AreEqual (string.Format (CultureInfo.InvariantCulture,
+                               "public enum Test1 {{{0}" +
+                               "}}{0}", Writer.NewLine), code);
+               }
+
+               [Test]
+               public override void DerivedTypeTest ()
+               {
+                       string code = GenerateDerivedType ();
+                       Assert.AreEqual (string.Format (CultureInfo.InvariantCulture,
+#if NET_2_0
+                               "internal enum Test1 : int, System.Security.Principal.IIdentity, string, System.Security.IPermission {{{0}" +
+#else
+                               "enum Test1 : int, System.Security.Principal.IIdentity, string, System.Security.IPermission {{{0}" +
+#endif
+                               "}}{0}", Writer.NewLine), code);
+               }
+
+               [Test]
+               public override void AttributesAndTypeTest ()
+               {
+                       string code = GenerateAttributesAndType ();
+                       Assert.AreEqual (string.Format (CultureInfo.InvariantCulture,
+                               "[A()]{0}" +
+                               "[B()]{0}" +
+                               "public enum Test1 {{{0}" +
+                               "}}{0}", Writer.NewLine), code);
+               }
+
+               [Test]
+               public override void EventMembersTypeTest1 ()
+               {
+                       string code = GenerateEventMembersType1 ();
+                       Assert.AreEqual (string.Format (CultureInfo.InvariantCulture,
+                               "public enum Test1 {{{0}" +
+                               "    {0}" +
+                               "}}{0}", Writer.NewLine), code);
+               }
+
+               [Test]
+               public override void EventMembersTypeTest2 ()
+               {
+                       string code = GenerateEventMembersType2 ();
+                       Assert.AreEqual (string.Format (CultureInfo.InvariantCulture,
+                               "public enum Test1 {{{0}" +
+                               "    {0}" +
+                               "}}{0}", Writer.NewLine), code);
+               }
+
+               [Test]
+               public override void EventImplementationTypes ()
+               {
+                       string code = GenerateEventImplementationTypes ();
+                       Assert.AreEqual (string.Format (CultureInfo.InvariantCulture,
+                               "public enum Test1 {{{0}" +
+                               "    {0}" +
+                               "}}{0}", Writer.NewLine), code);
+               }
+
+               [Test]
+               public override void EventPrivateImplementationType ()
+               {
+                       string code = GenerateEventPrivateImplementationType ();
+                       Assert.AreEqual (string.Format (CultureInfo.InvariantCulture,
+                               "public enum Test1 {{{0}" +
+                               "    {0}" +
+                               "}}{0}", Writer.NewLine), code);
+               }
+
+               [Test]
+               public override void EventImplementationTypeOrder ()
+               {
+                       string code = GenerateEventImplementationTypeOrder ();
+                       Assert.AreEqual (string.Format (CultureInfo.InvariantCulture,
+                               "public enum Test1 {{{0}" +
+                               "    {0}" +
+                               "}}{0}", Writer.NewLine), code);
+               }
+
+               [Test]
+               public override void FieldMembersTypeTest1 ()
+               {
+                       string code = GenerateFieldMembersType1 ();
+                       Assert.AreEqual (string.Format (CultureInfo.InvariantCulture,
+                               "public enum Test1 {{{0}" +
+                               "    {0}" +
+                               "    [A()]{0}" +
+                               "    [B()]{0}" +
+                               "    ,{0}" +
+                               "}}{0}", Writer.NewLine), code);
+               }
+
+               [Test]
+               public override void FieldMembersTypeTest2 ()
+               {
+                       string code = GenerateFieldMembersType2 ();
+                       Assert.AreEqual (string.Format (CultureInfo.InvariantCulture,
+                               "public enum Test1 {{{0}" +
+                               "    {0}" +
+                               "    Name = 2,{0}" +
+                               "}}{0}", Writer.NewLine), code);
+               }
+
+               [Test]
+               public override void PropertyMembersTypeTest1 ()
+               {
+                       string code = GeneratePropertyMembersAttributes ();
+                       Assert.AreEqual (string.Format (CultureInfo.InvariantCulture,
+                               "public enum Test1 {{{0}" +
+                               "    {0}" +
+                               "}}{0}", Writer.NewLine), code);
+               }
+
+               [Test]
+               public override void PropertyMembersTypeTest2 ()
+               {
+                       string code = GeneratePropertyMembersType (MemberAttributes.Public,
+                               false, false);
+                       Assert.AreEqual (string.Format (CultureInfo.InvariantCulture,
+                               "public enum Test1 {{{0}" +
+                               "    {0}" +
+                               "}}{0}", Writer.NewLine), code);
+               }
+
+               [Test]
+               public override void PropertyMembersTypeGetOnly ()
+               {
+                       string code = GeneratePropertyMembersType (MemberAttributes.Family,
+                               true, false);
+                       Assert.AreEqual (string.Format (CultureInfo.InvariantCulture,
+                               "public enum Test1 {{{0}" +
+                               "    {0}" +
+                               "}}{0}", Writer.NewLine), code);
+               }
+
+               [Test]
+               public override void PropertyMembersTypeSetOnly ()
+               {
+                       string code = GeneratePropertyMembersType (MemberAttributes.Assembly,
+                               false, true);
+                       Assert.AreEqual (string.Format (CultureInfo.InvariantCulture,
+                               "public enum Test1 {{{0}" +
+                               "    {0}" +
+                               "}}{0}", Writer.NewLine), code);
+               }
+
+               [Test]
+               public override void PropertyMembersTypeGetSet ()
+               {
+                       string code = GeneratePropertyMembersType (MemberAttributes.Family,
+                               true, true);
+                       Assert.AreEqual (string.Format (CultureInfo.InvariantCulture,
+                               "public enum Test1 {{{0}" +
+                               "    {0}" +
+                               "}}{0}", Writer.NewLine), code);
+               }
+
+               [Test]
+               public override void PropertyMembersTypeFamilyOrAssembly ()
+               {
+                       string code = GeneratePropertyMembersType (MemberAttributes.FamilyOrAssembly,
+                               false, false);
+                       Assert.AreEqual (string.Format (CultureInfo.InvariantCulture,
+                               "public enum Test1 {{{0}" +
+                               "    {0}" +
+                               "}}{0}", Writer.NewLine), code);
+               }
+
+               [Test]
+               public override void PropertyMembersTypeAssembly ()
+               {
+                       string code = GeneratePropertyMembersType (MemberAttributes.Assembly,
+                               false, false);
+                       Assert.AreEqual (string.Format (CultureInfo.InvariantCulture,
+                               "public enum Test1 {{{0}" +
+                               "    {0}" +
+                               "}}{0}", Writer.NewLine), code);
+               }
+
+               [Test]
+               public override void PropertyParametersTest ()
+               {
+                       string code = GeneratePropertyParameters ();
+                       Assert.AreEqual (string.Format (CultureInfo.InvariantCulture,
+                               "public enum Test1 {{{0}" +
+                               "    {0}" +
+                               "}}{0}", Writer.NewLine), code);
+               }
+
+               [Test]
+               public override void PropertyIndexerTest1 ()
+               {
+                       string code = GeneratePropertyIndexer (MemberAttributes.Public,
+                               false, false, true);
+                       Assert.AreEqual (string.Format (CultureInfo.InvariantCulture,
+                               "public enum Test1 {{{0}" +
+                               "    {0}" +
+                               "}}{0}", Writer.NewLine), code);
+               }
+
+               [Test]
+               public override void PropertyIndexerTest2 ()
+               {
+                       string code = GeneratePropertyIndexer (MemberAttributes.Public,
+                               false, false, false);
+                       Assert.AreEqual (string.Format (CultureInfo.InvariantCulture,
+                               "public enum Test1 {{{0}" +
+                               "    {0}" +
+                               "}}{0}", Writer.NewLine), code);
+               }
+
+               [Test]
+               public override void PropertyIndexerGetOnly ()
+               {
+                       string code = GeneratePropertyIndexer (MemberAttributes.Family,
+                               true, false, true);
+                       Assert.AreEqual (string.Format (CultureInfo.InvariantCulture,
+                               "public enum Test1 {{{0}" +
+                               "    {0}" +
+                               "}}{0}", Writer.NewLine), code);
+               }
+
+               [Test]
+               public override void PropertyIndexerSetOnly ()
+               {
+                       string code = GeneratePropertyIndexer (MemberAttributes.Family,
+                               false, true, true);
+                       Assert.AreEqual (string.Format (CultureInfo.InvariantCulture,
+                               "public enum Test1 {{{0}" +
+                               "    {0}" +
+                               "}}{0}", Writer.NewLine), code);
+               }
+
+               [Test]
+               public override void PropertyImplementationTypes ()
+               {
+                       string code = GeneratePropertyImplementationTypes ();
+                       Assert.AreEqual (string.Format (CultureInfo.InvariantCulture,
+                               "public enum Test1 {{{0}" +
+                               "    {0}" +
+                               "}}{0}", Writer.NewLine), code);
+               }
+
+               [Test]
+               public override void PropertyOverloadsTest1 ()
+               {
+                       string code = GeneratePropertyOverloads1 ();
+                       Assert.AreEqual (string.Format (CultureInfo.InvariantCulture,
+                               "public enum Test1 {{{0}" +
+                               "    {0}" +
+                               "}}{0}", Writer.NewLine), code);
+               }
+
+               [Test]
+               public override void PropertyOverloadsTest2 ()
+               {
+                       string code = GeneratePropertyOverloads2 ();
+                       Assert.AreEqual (string.Format (CultureInfo.InvariantCulture,
+                               "public enum Test1 {{{0}" +
+                               "    {0}" +
+                               "    {0}" +
+                               "}}{0}", Writer.NewLine), code);
+               }
+
+               [Test]
+               public override void PropertyOverloadsTest3 ()
+               {
+                       string code = GeneratePropertyOverloads3 ();
+                       Assert.AreEqual (string.Format (CultureInfo.InvariantCulture,
+                               "public enum Test1 {{{0}" +
+                               "    {0}" +
+                               "    {0}" +
+                               "}}{0}", Writer.NewLine), code);
+               }
+
+               [Test]
+               public override void PropertyPrivateImplementationType ()
+               {
+                       string code = GeneratePropertyPrivateImplementationType ();
+                       Assert.AreEqual (string.Format (CultureInfo.InvariantCulture,
+                               "public enum Test1 {{{0}" +
+                               "    {0}" +
+                               "}}{0}", Writer.NewLine), code);
+               }
+
+               [Test]
+               public override void PropertyImplementationTypeOrder ()
+               {
+                       string code = GeneratePropertyImplementationTypeOrder ();
+                       Assert.AreEqual (string.Format (CultureInfo.InvariantCulture,
+                               "public enum Test1 {{{0}" +
+                               "    {0}" +
+                               "}}{0}", Writer.NewLine), code);
+               }
+
+               [Test]
+               public override void MethodMembersTypeTest1 ()
+               {
+                       string code = GenerateMethodMembersType1 ();
+                       Assert.AreEqual (string.Format (CultureInfo.InvariantCulture,
+                               "public enum Test1 {{{0}" +
+                               "    {0}" +
+                               "}}{0}", Writer.NewLine), code);
+               }
+
+               [Test]
+               public override void MethodMembersTypeTest2 ()
+               {
+                       string code = GenerateMethodMembersType2 ();
+                       Assert.AreEqual (string.Format (CultureInfo.InvariantCulture,
+                               "public enum Test1 {{{0}" +
+                               "    {0}" +
+                               "}}{0}", Writer.NewLine), code);
+               }
+
+               [Test]
+               public override void MethodMembersTypeTest3 ()
+               {
+                       string code = GenerateMethodMembersType3 ();
+                       Assert.AreEqual (string.Format (CultureInfo.InvariantCulture,
+                               "public enum Test1 {{{0}" +
+                               "    {0}" +
+                               "}}{0}", Writer.NewLine), code);
+               }
+
+               [Test]
+               public override void MethodImplementationTypes ()
+               {
+                       string code = GenerateMethodImplementationTypes ();
+                       Assert.AreEqual (string.Format (CultureInfo.InvariantCulture,
+                               "public enum Test1 {{{0}" +
+                               "    {0}" +
+                               "}}{0}", Writer.NewLine), code);
+               }
+
+               [Test]
+               public override void MethodOverloadsTest1 ()
+               {
+                       string code = GenerateMethodOverloads1 ();
+                       Assert.AreEqual (string.Format (CultureInfo.InvariantCulture,
+                               "public enum Test1 {{{0}" +
+                               "    {0}" +
+                               "}}{0}", Writer.NewLine), code);
+               }
+
+               [Test]
+               public override void MethodOverloadsTest2 ()
+               {
+                       string code = GenerateMethodOverloads2 ();
+                       Assert.AreEqual (string.Format (CultureInfo.InvariantCulture,
+                               "public enum Test1 {{{0}" +
+                               "    {0}" +
+                               "    {0}" +
+                               "}}{0}", Writer.NewLine), code);
+               }
+
+               [Test]
+               public override void MethodOverloadsTest3 ()
+               {
+                       string code = GenerateMethodOverloads3 ();
+                       Assert.AreEqual (string.Format (CultureInfo.InvariantCulture,
+                               "public enum Test1 {{{0}" +
+                               "    {0}" +
+                               "    {0}" +
+                               "}}{0}", Writer.NewLine), code);
+               }
+
+               [Test]
+               public override void MethodPrivateImplementationType ()
+               {
+                       string code = GenerateMethodPrivateImplementationType ();
+                       Assert.AreEqual (string.Format (CultureInfo.InvariantCulture,
+                               "public enum Test1 {{{0}" +
+                               "    {0}" +
+                               "}}{0}", Writer.NewLine), code);
+               }
+
+               [Test]
+               public override void MethodImplementationTypeOrder ()
+               {
+                       string code = GenerateMethodImplementationTypeOrder ();
+                       Assert.AreEqual (string.Format (CultureInfo.InvariantCulture,
+                               "public enum Test1 {{{0}" +
+                               "    {0}" +
+                               "}}{0}", Writer.NewLine), code);
+               }
+
+               [Test]
+               public override void MethodReturnTypeAttributes ()
+               {
+                       string code = GenerateMethodReturnTypeAttributes ();
+                       Assert.AreEqual (string.Format (CultureInfo.InvariantCulture,
+                               "public enum Test1 {{{0}" +
+                               "    {0}" +
+                               "}}{0}", Writer.NewLine), code);
+               }
+
+               [Test]
+               public override void ConstructorAttributesTest ()
+               {
+                       string code = GenerateConstructorAttributes ();
+                       Assert.AreEqual (string.Format (CultureInfo.InvariantCulture,
+                               "public enum Test1 {{{0}" +
+                               "    {0}" +
+                               "}}{0}", Writer.NewLine), code);
+               }
+
+               [Test]
+               public override void ConstructorParametersTest ()
+               {
+                       string code = GenerateConstructorParameters ();
+                       Assert.AreEqual (string.Format (CultureInfo.InvariantCulture,
+                               "public enum Test1 {{{0}" +
+                               "    {0}" +
+                               "}}{0}", Writer.NewLine), code);
+               }
+
+               [Test]
+               public override void ConstructorParameterAttributesTest ()
+               {
+                       string code = GenerateConstructorParameterAttributes ();
+                       Assert.AreEqual (string.Format (CultureInfo.InvariantCulture,
+                               "public enum Test1 {{{0}" +
+                               "    {0}" +
+                               "}}{0}", Writer.NewLine), code);
+               }
+
+               [Test]
+               public override void BaseConstructorSingleArg ()
+               {
+                       string code = GenerateBaseConstructor (false);
+                       Assert.AreEqual (string.Format (CultureInfo.InvariantCulture,
+                               "public enum Test1 {{{0}" +
+                               "    {0}" +
+                               "}}{0}", Writer.NewLine), code);
+               }
+
+               [Test]
+               public override void BaseConstructorMultipleArgs ()
+               {
+                       string code = GenerateBaseConstructor (true);
+                       Assert.AreEqual (string.Format (CultureInfo.InvariantCulture,
+                               "public enum Test1 {{{0}" +
+                               "    {0}" +
+                               "}}{0}", Writer.NewLine), code);
+               }
+
+               [Test]
+               public override void ChainedConstructorSingleArg ()
+               {
+                       string code = GenerateChainedConstructor (false);
+                       Assert.AreEqual (string.Format (CultureInfo.InvariantCulture,
+                               "public enum Test1 {{{0}" +
+                               "    {0}" +
+                               "}}{0}", Writer.NewLine), code);
+               }
+
+               [Test]
+               public override void ChainedConstructorMultipleArgs ()
+               {
+                       string code = GenerateChainedConstructor (true);
+                       Assert.AreEqual (string.Format (CultureInfo.InvariantCulture,
+                               "public enum Test1 {{{0}" +
+                               "    {0}" +
+                               "}}{0}", Writer.NewLine), code);
+               }
+
+               [Test]
+               public override void TypeConstructorTest ()
+               {
+                       string code = GenerateTypeConstructor ();
+                       Assert.AreEqual (string.Format (CultureInfo.InvariantCulture,
+                               "public enum Test1 {{{0}" +
+                               "    {0}" +
+                               "}}{0}", Writer.NewLine), code);
+               }
+
+               #endregion Override implementation of CodeGeneratorFromTypeTestBase
        }
 }
index b10643b7260acced2b2c3847d352e7dab454f1bf..b1b683b87eb6206b5d7728bb0127d1c079b6857e 100644 (file)
@@ -1,3 +1,8 @@
+2005-07-24  Gert Driesen <drieseng@users.sourceforge.net>
+
+       * CodeGeneratorFromTypeTest.cs: Added BaseTypes and TypeConstructor
+       tests. Enabled enum, interface and delegate tests.
+
 2005-07-21  Gert Driesen <drieseng@users.sourceforge.net>
 
        * CodeGeneratorFromTypeTest.cs: Inherit from
index 7acc69540d45092587eb4c08107c0703758ede78..670f966fa0711dc6bf4e972d427cdd28e6b84d3b 100644 (file)
@@ -71,6 +71,21 @@ namespace MonoTests.Microsoft.VisualBasic
                                "End Class{0}", Writer.NewLine), code);
                }
 
+               [Test]
+               public override void DerivedTypeTest ()
+               {
+                       string code = GenerateDerivedType ();
+                       Assert.AreEqual (string.Format (CultureInfo.InvariantCulture,
+#if NET_2_0
+                               "Friend MustInherit Class Test1{0}" +
+#else
+                               "MustInherit Class Test1{0}" +
+#endif
+                               "    Inherits Integer{0}" +
+                               "    Implements System.Security.Principal.IIdentity, String, System.Security.IPermission{0}" +
+                               "End Class{0}", Writer.NewLine), code);
+               }
+
                [Test]
                public override void AttributesAndTypeTest ()
                {
@@ -179,7 +194,7 @@ namespace MonoTests.Microsoft.VisualBasic
                        Assert.AreEqual (string.Format (CultureInfo.InvariantCulture,
                                "Public Class Test1{0}" +
                                "    {0}" +
-                               "    Public Name As Integer{0}" +
+                               "    Public Name As Integer = 2{0}" +
                                "End Class{0}", Writer.NewLine), code);
                }
 
@@ -767,10 +782,25 @@ namespace MonoTests.Microsoft.VisualBasic
                                "    End Sub{0}" +
                                "End Class{0}", Writer.NewLine), code);
                }
+
+               [Test]
+               public override void TypeConstructorTest ()
+               {
+                       string code = GenerateTypeConstructor ();
+                       Assert.AreEqual (string.Format (CultureInfo.InvariantCulture,
+                               "Public Class Test1{0}" +
+                               "    {0}" +
+#if NET_2_0
+                               "    <A(),  _{0}" +
+                               "     B()>  _{0}" +
+#endif
+                               "    Shared Sub New(){0}" +
+                               "    End Sub{0}" +
+                               "End Class{0}", Writer.NewLine), code);
+               }
        }
 
        [TestFixture]
-       [Category ("NotWorking")]
        public class CodeGeneratorFromTypeTest_Delegate : CodeGeneratorFromTypeTestBase
        {
                private CodeTypeDeclaration _typeDeclaration;
@@ -819,14 +849,27 @@ namespace MonoTests.Microsoft.VisualBasic
                                "Public Delegate Sub Test1(){0}", Writer.NewLine), code);
                }
 
+               [Test]
+               public override void DerivedTypeTest ()
+               {
+                       string code = GenerateDerivedType ();
+                       Assert.AreEqual (string.Format (CultureInfo.InvariantCulture,
+                               "Delegate Sub Test1(){0}", Writer.NewLine), code);
+               }
+
                [Test]
                public override void AttributesAndTypeTest ()
                {
+                       CodeTypeDelegate delegateDecl = new CodeTypeDelegate ();
+                       delegateDecl.ReturnType = new CodeTypeReference (typeof (int));
+
+                       _typeDeclaration = delegateDecl;
+
                        string code = GenerateAttributesAndType ();
                        Assert.AreEqual (string.Format (CultureInfo.InvariantCulture,
                                "<A(),  _{0}" +
                                " B()>  _{0}" +
-                               "Public Delegate Sub Test1(){0}", Writer.NewLine), code);
+                               "Public Delegate Function Test1() As Integer{0}", Writer.NewLine), code);
                }
 
                [Test]
@@ -1182,10 +1225,17 @@ namespace MonoTests.Microsoft.VisualBasic
                        Assert.AreEqual (string.Format (CultureInfo.InvariantCulture,
                                "Public Delegate Sub Test1(){0}{0}", Writer.NewLine), code);
                }
+
+               [Test]
+               public override void TypeConstructorTest ()
+               {
+                       string code = GenerateTypeConstructor ();
+                       Assert.AreEqual (string.Format (CultureInfo.InvariantCulture,
+                               "Public Delegate Sub Test1(){0}{0}", Writer.NewLine), code);
+               }
        }
 
        [TestFixture]
-       [Category ("NotWorking")]
        public class CodeGeneratorFromTypeTest_Interface : CodeGeneratorFromTypeTestBase
        {
                private CodeTypeDeclaration _typeDeclaration;
@@ -1237,6 +1287,20 @@ namespace MonoTests.Microsoft.VisualBasic
                                "End Interface{0}", Writer.NewLine), code);
                }
 
+               [Test]
+               public override void DerivedTypeTest ()
+               {
+                       string code = GenerateDerivedType ();
+                       Assert.AreEqual (string.Format (CultureInfo.InvariantCulture,
+#if NET_2_0
+                               "Friend Interface Test1{0}" +
+#else
+                               "Interface Test1{0}" +
+#endif
+                               "    Inherits Integer, System.Security.Principal.IIdentity, String, System.Security.IPermission{0}" +
+                               "End Interface{0}", Writer.NewLine), code);
+               }
+
                [Test]
                public override void AttributesAndTypeTest ()
                {
@@ -1786,10 +1850,19 @@ namespace MonoTests.Microsoft.VisualBasic
                                "    {0}" +
                                "End Interface{0}", Writer.NewLine), code);
                }
+
+               [Test]
+               public override void TypeConstructorTest ()
+               {
+                       string code = GenerateTypeConstructor ();
+                       Assert.AreEqual (string.Format (CultureInfo.InvariantCulture,
+                               "Public Interface Test1{0}" +
+                               "    {0}" +
+                               "End Interface{0}", Writer.NewLine), code);
+               }
        }
 
        [TestFixture]
-       [Category ("NotWorking")]
        public class CodeGeneratorFromTypeTest_Struct : CodeGeneratorFromTypeTestBase
        {
                private CodeTypeDeclaration _typeDeclaration;
@@ -1841,6 +1914,20 @@ namespace MonoTests.Microsoft.VisualBasic
                                "End Structure{0}", Writer.NewLine), code);
                }
 
+               [Test]
+               public override void DerivedTypeTest ()
+               {
+                       string code = GenerateDerivedType ();
+                       Assert.AreEqual (string.Format (CultureInfo.InvariantCulture,
+#if NET_2_0
+                               "Friend Structure Test1{0}" +
+#else
+                               "Structure Test1{0}" +
+#endif
+                               "    Implements Integer, System.Security.Principal.IIdentity, String, System.Security.IPermission{0}" +
+                               "End Structure{0}", Writer.NewLine), code);
+               }
+
                [Test]
                public override void AttributesAndTypeTest ()
                {
@@ -1941,7 +2028,7 @@ namespace MonoTests.Microsoft.VisualBasic
                        Assert.AreEqual (string.Format (CultureInfo.InvariantCulture,
                                "Public Structure Test1{0}" +
                                "    {0}" +
-                               "    Public Name As Integer{0}" +
+                               "    Public Name As Integer = 2{0}" +
                                "End Structure{0}", Writer.NewLine), code);
                }
 
@@ -2476,10 +2563,25 @@ namespace MonoTests.Microsoft.VisualBasic
                                "    End Sub{0}" +
                                "End Structure{0}", Writer.NewLine), code);
                }
+
+               [Test]
+               public override void TypeConstructorTest ()
+               {
+                       string code = GenerateTypeConstructor ();
+                       Assert.AreEqual (string.Format (CultureInfo.InvariantCulture,
+                               "Public Structure Test1{0}" +
+                               "    {0}" +
+#if NET_2_0
+                               "    <A(),  _{0}" +
+                               "     B()>  _{0}" +
+#endif
+                               "    Shared Sub New(){0}" +
+                               "    End Sub{0}" +
+                               "End Structure{0}", Writer.NewLine), code);
+               }
        }
 
        [TestFixture]
-       [Category ("NotWorking")]
        public class CodeGeneratorFromTypeTest_Enum : CodeGeneratorFromTypeTestBase
        {
                private CodeTypeDeclaration _typeDeclaration;
@@ -2531,6 +2633,19 @@ namespace MonoTests.Microsoft.VisualBasic
                                "End Enum{0}", Writer.NewLine), code);
                }
 
+               [Test]
+               public override void DerivedTypeTest ()
+               {
+                       string code = GenerateDerivedType ();
+                       Assert.AreEqual (string.Format (CultureInfo.InvariantCulture,
+#if NET_2_0
+                               "Friend Enum Test1 As Integer{0}" +
+#else
+                               "Enum Test1 As Integer{0}" +
+#endif
+                               "End Enum{0}", Writer.NewLine), code);
+               }
+
                [Test]
                public override void AttributesAndTypeTest ()
                {
@@ -2612,7 +2727,7 @@ namespace MonoTests.Microsoft.VisualBasic
                        Assert.AreEqual (string.Format (CultureInfo.InvariantCulture,
                                "Public Enum Test1{0}" +
                                "    {0}" +
-                               "    Name{0}" +
+                               "    Name = 2{0}" +
                                "End Enum{0}", Writer.NewLine), code);
                }
 
@@ -2979,5 +3094,15 @@ namespace MonoTests.Microsoft.VisualBasic
                                "    {0}" +
                                "End Enum{0}", Writer.NewLine), code);
                }
+
+               [Test]
+               public override void TypeConstructorTest ()
+               {
+                       string code = GenerateTypeConstructor ();
+                       Assert.AreEqual (string.Format (CultureInfo.InvariantCulture,
+                               "Public Enum Test1{0}" +
+                               "    {0}" +
+                               "End Enum{0}", Writer.NewLine), code);
+               }
        }
 }
index 0eb51e679da3060f5ab3ae4b26a1f4fac0e4ebaa..969eb2e1e72d9288109899f7809628f311198562 100644 (file)
@@ -1,3 +1,10 @@
+2005-07-24  Gert Driesen <drieseng@users.sourceforge.net>
+
+       * CodeGeneratorTest.cs: Removed duplicate import of NUNit.Framework
+       namespace.
+       * CodeGeneratorFromTypeTestBase.cs: Added BaseTypes and 
+       TypeConstructor tests.
+
 2005-07-21  Gert Driesen <drieseng@users.sourceforge.net>
 
        * CodeGeneratorTest.cs: Added unit tests for CodeGenerator.IsCurrent*.
index 1988e565355794fd4345c0fccc4ff9a693cc100e..ca32a134d218b47d2d76fb4c50f5930ae4ab6fc5 100644 (file)
@@ -8,6 +8,9 @@
 //
 
 using System.CodeDom;
+using System.Reflection;
+using System.Security;
+using System.Security.Principal;
 
 using NUnit.Framework;
 
@@ -29,6 +32,9 @@ namespace MonoTests.System.CodeDom.Compiler
                [Test]
                public abstract void SimpleTypeTest ();
 
+               [Test]
+               public abstract void DerivedTypeTest ();
+
                [Test]
                public abstract void AttributesAndTypeTest ();
 
@@ -158,6 +164,9 @@ namespace MonoTests.System.CodeDom.Compiler
                [Test]
                public abstract void ChainedConstructorMultipleArgs ();
 
+               [Test]
+               public abstract void TypeConstructorTest ();
+
                protected string GenerateDefaultType ()
                {
                        return GenerateCodeFromType (TypeDeclaration);
@@ -174,6 +183,18 @@ namespace MonoTests.System.CodeDom.Compiler
                        return GenerateCodeFromType (TypeDeclaration);
                }
 
+               protected string GenerateDerivedType ()
+               {
+                       TypeDeclaration.Name = "Test1";
+                       TypeDeclaration.TypeAttributes |= TypeAttributes.NestedFamily | 
+                               TypeAttributes.Abstract;
+                       TypeDeclaration.BaseTypes.Add (new CodeTypeReference (typeof (int)));
+                       TypeDeclaration.BaseTypes.Add (new CodeTypeReference (typeof (IIdentity)));
+                       TypeDeclaration.BaseTypes.Add (new CodeTypeReference (typeof (string)));
+                       TypeDeclaration.BaseTypes.Add (new CodeTypeReference (typeof (IPermission)));
+                       return GenerateCodeFromType (TypeDeclaration);
+               }
+
                protected string GenerateAttributesAndType ()
                {
                        TypeDeclaration.Name = "Test1";
@@ -294,6 +315,7 @@ namespace MonoTests.System.CodeDom.Compiler
                        fld.Name = "Name";
                        fld.Attributes = MemberAttributes.Public;
                        fld.Type = new CodeTypeReference (typeof (int));
+                       fld.InitExpression = new CodePrimitiveExpression (2);
                        TypeDeclaration.Members.Add (fld);
 
                        return GenerateCodeFromType (TypeDeclaration);
@@ -865,7 +887,7 @@ namespace MonoTests.System.CodeDom.Compiler
                        param.Direction = FieldDirection.Out;
                        ctor.Parameters.Add (param);
 
-                       // immplementation types should be ignored on ctors
+                       // implementation types should be ignored on ctors
                        ctor.ImplementationTypes.Add (new CodeTypeReference ("IPolicy"));
 
                        // chained ctor args
@@ -883,5 +905,47 @@ namespace MonoTests.System.CodeDom.Compiler
 
                        return GenerateCodeFromType (TypeDeclaration);
                }
+
+               protected string GenerateTypeConstructor ()
+               {
+                       TypeDeclaration.Name = "Test1";
+
+                       CodeTypeConstructor typeCtor = new CodeTypeConstructor ();
+                       TypeDeclaration.Members.Add (typeCtor);
+
+                       // custom attributes
+                       CodeAttributeDeclaration attrDec = new CodeAttributeDeclaration ();
+                       attrDec.Name = "A";
+                       typeCtor.CustomAttributes.Add (attrDec);
+
+                       attrDec = new CodeAttributeDeclaration ();
+                       attrDec.Name = "B";
+                       typeCtor.CustomAttributes.Add (attrDec);
+
+                       // parameter should be ignored
+                       CodeParameterDeclarationExpression param = new CodeParameterDeclarationExpression (
+                               typeof (object), "value1");
+                       typeCtor.Parameters.Add (param);
+
+                       // implementation types should be ignored on type ctors
+                       typeCtor.ImplementationTypes.Add (new CodeTypeReference ("IPolicy"));
+
+                       // private immplementation type should be ignored on type ctors
+                       typeCtor.PrivateImplementationType = new CodeTypeReference (typeof (int));
+
+                       // return type should be ignored on type ctors
+                       typeCtor.ReturnType = new CodeTypeReference (typeof (int));
+
+                       // return TypeDeclaration custom attributes
+                       attrDec = new CodeAttributeDeclaration ();
+                       attrDec.Name = "A";
+                       attrDec.Arguments.Add (new CodeAttributeArgument ("A1",
+                               new CodePrimitiveExpression (false)));
+                       attrDec.Arguments.Add (new CodeAttributeArgument ("A2",
+                               new CodePrimitiveExpression (true)));
+                       typeCtor.ReturnTypeCustomAttributes.Add (attrDec);
+
+                       return GenerateCodeFromType (TypeDeclaration);
+               }
        }
 }
index 9066e4b15f440adb21da2e7f14aff0ff52cc2d1c..8ac5147164381d118991c490e71d08f1f416faa9 100644 (file)
@@ -7,8 +7,6 @@
 // (c) Novell
 //
 
-using NUnit.Framework;
-
 using System;
 using System.CodeDom;
 using System.CodeDom.Compiler;
index ad7c1fa6b5f022a7d21bc9374a4af97f1dc4bf82..51f8242fce69914e9fa015e27d1e2706bf5ac1bd 100644 (file)
@@ -1,3 +1,7 @@
+2005-07-24  Gert Driesen  <drieseng@users.sourceforge.net>
+
+       * CodeTypeDelegateTest.cs: Added tests for BaseTypes and ReturnType.
+
 2005-06-28  Gert Driesen  <drieseng@users.sourceforge.net>
 
        * CodeTypeReferenceTest.cs: Tests for zero-length and null type names,
diff --git a/mcs/class/System/Test/System.CodeDom/CodeTypeDelegateTest.cs b/mcs/class/System/Test/System.CodeDom/CodeTypeDelegateTest.cs
new file mode 100644 (file)
index 0000000..dda3885
--- /dev/null
@@ -0,0 +1,48 @@
+//
+// CodeTypeReferenceTest.cs - NUnit Test Cases for System.CodeDom.CodeTypeReference
+//
+// Authors:
+//   Gert Driesen (drieseng@users.sourceforge.net)
+//
+// (C) 2005 Novell
+//
+using System;
+using System.CodeDom;
+
+using NUnit.Framework;
+
+namespace MonoTests.System.CodeDom
+{
+       [TestFixture]
+       public class CodeTypeDelegateTest
+       {
+               [Test]
+               public void EmptyTypeName ()
+               {
+                       CodeTypeDelegate delegateType = new CodeTypeDelegate (string.Empty);
+                       Assert.AreEqual (string.Empty, delegateType.Name);
+               }
+
+               [Test]
+               public void NullTypeName ()
+               {
+                       CodeTypeDelegate delegateType = new CodeTypeDelegate ((string) null);
+                       Assert.AreEqual (string.Empty, delegateType.Name);
+               }
+
+               [Test]
+               public void BaseTypes ()
+               {
+                       CodeTypeDelegate delegateType = new CodeTypeDelegate ((string) null);
+                       Assert.AreEqual (1, delegateType.BaseTypes.Count);
+                       Assert.AreEqual ("System.Delegate", delegateType.BaseTypes[0].BaseType);
+               }
+
+               [Test]
+               public void DefaultReturnType ()
+               {
+                       CodeTypeDelegate delegateType = new CodeTypeDelegate ((string) null);
+                       Assert.AreEqual (typeof(void).FullName, delegateType.ReturnType.BaseType);
+               }
+       }
+}