diff options
author | Gert Driesen <drieseng@users.sourceforge.net> | 2005-10-28 22:05:39 +0400 |
---|---|---|
committer | Gert Driesen <drieseng@users.sourceforge.net> | 2005-10-28 22:05:39 +0400 |
commit | 4a813ed0db1731467bd0a23133a11f882237b1b3 (patch) | |
tree | ce99ada5a135c10e43403db7fc85f00557afc79f /mcs/class/System | |
parent | d1c39fd21621c9815192b2d54ddb6f85a73d54bd (diff) |
* CodeGeneratorFromTypeTest.cs: Added tests for CodeEntryPointMethod
and bug #76580.
* CodeGeneratorTestBase.cs: Set eol-style to native.
* CodeGeneratorTest.cs: Set eol-style to native.
* CodeGeneratorFromTypeTestBase.cs: Added tests for
CodeEntryPointMethod and bug #76580. Set eol-style to native.
* IndentedTextWriterTest.cs: Set eol-style to native.
* CodeGeneratorFromTypeTest.cs: Added tests for CodeEntryPointMethod
and bug #76580.
* CSharpCodeGenerator.cs: Use fixed signature for entrypoint method
on 1.0 profile. On 2.0 profile output custom attributes, and return
type. On 1.0 profile, also replace + with dot (for nested types).
Fixes bug #76580. Set eol-style to native.
* CSharpCodeCompiler.cs: Set eol-style to native.
* CSharpCodeProvider.cs: Set eol-style to native.
* VBCodeGenerator.cs: Use fixed signature for entrypoint method.
Only output attributes on 2.0 profile. Replace + with dot in type
name (for nested types). Fixes bug #76580.
svn path=/trunk/mcs/; revision=52344
Diffstat (limited to 'mcs/class/System')
10 files changed, 264 insertions, 7 deletions
diff --git a/mcs/class/System/Microsoft.CSharp/CSharpCodeGenerator.cs b/mcs/class/System/Microsoft.CSharp/CSharpCodeGenerator.cs index 615f7a14603..4c0624af412 100644 --- a/mcs/class/System/Microsoft.CSharp/CSharpCodeGenerator.cs +++ b/mcs/class/System/Microsoft.CSharp/CSharpCodeGenerator.cs @@ -588,8 +588,22 @@ namespace Mono.CSharp protected override void GenerateEntryPointMethod (CodeEntryPointMethod method, CodeTypeDeclaration declaration) { - method.Name = "Main"; - GenerateMethod (method, declaration); +#if NET_2_0 + OutputAttributes (method.CustomAttributes, null, false); +#endif + + Output.Write ("public static "); +#if NET_2_0 + OutputType (method.ReturnType); +#else + Output.Write ("void"); +#endif + Output.Write (" Main()"); + OutputStartBrace (); + Indent++; + GenerateStatements (method.Statements); + Indent--; + Output.WriteLine ("}"); } protected override void GenerateMethod (CodeMemberMethod method, @@ -1120,7 +1134,7 @@ namespace Mono.CSharp else return value; } - + protected override string GetTypeOutput (CodeTypeReference type) { string typeOutput = null; @@ -1248,6 +1262,7 @@ namespace Mono.CSharp typeOutput = sb.ToString (); #else typeOutput = GetSafeName (baseType); + typeOutput = typeOutput.Replace ('+', '.'); #endif break; } diff --git a/mcs/class/System/Microsoft.CSharp/ChangeLog b/mcs/class/System/Microsoft.CSharp/ChangeLog index 4712cb5b5f0..a5f53de33e2 100644 --- a/mcs/class/System/Microsoft.CSharp/ChangeLog +++ b/mcs/class/System/Microsoft.CSharp/ChangeLog @@ -1,3 +1,12 @@ +2005-10-28 Gert Driesen <drieseng@users.sourceforge.net> + + * CSharpCodeGenerator.cs: Use fixed signature for entrypoint method + on 1.0 profile. On 2.0 profile output custom attributes, and return + type. On 1.0 profile, also replace + with dot (for nested types). + Fixes bug #76580. Set eol-style to native. + * CSharpCodeCompiler.cs: Set eol-style to native. + * CSharpCodeProvider.cs: Set eol-style to native. + 2005-10-19 Miguel de Icaza <miguel@novell.com> * CSharpCodeCompiler.cs: Quote the directory, to fix #76469 diff --git a/mcs/class/System/Microsoft.VisualBasic/ChangeLog b/mcs/class/System/Microsoft.VisualBasic/ChangeLog index 96ddeddd0ae..c4ed7f1fb62 100644 --- a/mcs/class/System/Microsoft.VisualBasic/ChangeLog +++ b/mcs/class/System/Microsoft.VisualBasic/ChangeLog @@ -1,3 +1,9 @@ +2005-10-28 Gert Driesen <drieseng@users.sourceforge.net> + + * VBCodeGenerator.cs: Use fixed signature for entrypoint method. + Only output attributes on 2.0 profile. Replace + with dot in type + name (for nested types). Fixes bug #76580. + 2005-10-25 Gert Driesen <drieseng@users.sourceforge.net> * VBCodeGenerator.cs: Do not output name of CodeAttributeArgument if diff --git a/mcs/class/System/Microsoft.VisualBasic/VBCodeGenerator.cs b/mcs/class/System/Microsoft.VisualBasic/VBCodeGenerator.cs index 103690d1918..6c0eecc1776 100644 --- a/mcs/class/System/Microsoft.VisualBasic/VBCodeGenerator.cs +++ b/mcs/class/System/Microsoft.VisualBasic/VBCodeGenerator.cs @@ -628,10 +628,18 @@ namespace Microsoft.VisualBasic Output.Write (member.Text);
}
- protected override void GenerateEntryPointMethod( CodeEntryPointMethod method, CodeTypeDeclaration declaration )
+ protected override void GenerateEntryPointMethod (CodeEntryPointMethod method, CodeTypeDeclaration declaration)
{
- method.Name = "Main";
- GenerateMethod (method, declaration);
+#if NET_2_0
+ OutputAttributes (method.CustomAttributes, null,
+ LineHandling.ContinueLine);
+#endif
+
+ Output.WriteLine ("Public Shared Sub Main()");
+ Indent++;
+ GenerateStatements (method.Statements);
+ Indent--;
+ Output.WriteLine ("End Sub");
}
[MonoTODO ("partially implemented")]
@@ -1437,7 +1445,7 @@ namespace Microsoft.VisualBasic break;
#endif
default:
- output = type.BaseType;
+ output = type.BaseType.Replace('+', '.');
break;
}
}
diff --git a/mcs/class/System/Test/Microsoft.CSharp/ChangeLog b/mcs/class/System/Test/Microsoft.CSharp/ChangeLog index 1e8093bb349..93c23151073 100644 --- a/mcs/class/System/Test/Microsoft.CSharp/ChangeLog +++ b/mcs/class/System/Test/Microsoft.CSharp/ChangeLog @@ -1,3 +1,8 @@ +2005-10-28 Gert Driesen <drieseng@users.sourceforge.net> + + * CodeGeneratorFromTypeTest.cs: Added tests for CodeEntryPointMethod + and bug #76580. + 2005-10-25 Gert Driesen <drieseng@users.sourceforge.net> * CodeGeneratorTestBase.cs: Fixed line endings. Set eol-style to diff --git a/mcs/class/System/Test/Microsoft.CSharp/CodeGeneratorFromTypeTest.cs b/mcs/class/System/Test/Microsoft.CSharp/CodeGeneratorFromTypeTest.cs index 4ffcec4c27d..0f34a681467 100644 --- a/mcs/class/System/Test/Microsoft.CSharp/CodeGeneratorFromTypeTest.cs +++ b/mcs/class/System/Test/Microsoft.CSharp/CodeGeneratorFromTypeTest.cs @@ -902,6 +902,24 @@ namespace MonoTests.Microsoft.CSharp "}}{0}", NewLine), code); } + [Test] + public override void EntryPointMethodTest () + { + string code = GenerateEntryPointMethod (Options); + Assert.AreEqual (string.Format (CultureInfo.InvariantCulture, + "public class Test1 {{{0}" + + " {0}" + +#if NET_2_0 + " [A()]{0}" + + " public static int Main() {{{0}" + +#else + " public static void Main() {{{0}" + +#endif + " Test.InnerType x;{0}" + + " }}{0}" + + "}}{0}", NewLine), code); + } + #endregion Override implementation of CodeGeneratorFromTypeTestBase } @@ -1371,6 +1389,22 @@ namespace MonoTests.Microsoft.CSharp "public delegate void Test1();{0}{0}", NewLine), code); } + [Test] + public override void EntryPointMethodTest () + { + string code = GenerateEntryPointMethod (Options); + Assert.AreEqual (string.Format (CultureInfo.InvariantCulture, + "public delegate void Test1();{0}{0}" + +#if NET_2_0 + "[A()]{0}" + + "public static int Main() {{{0}" + +#else + "public static void Main() {{{0}" + +#endif + " Test.InnerType x;{0}" + + "}}{0}", NewLine), code); + } + #endregion Override implementation of CodeGeneratorFromTypeTestBase } @@ -2105,6 +2139,24 @@ namespace MonoTests.Microsoft.CSharp "}}{0}", NewLine), code); } + [Test] + public override void EntryPointMethodTest () + { + string code = GenerateEntryPointMethod (Options); + Assert.AreEqual (string.Format (CultureInfo.InvariantCulture, + "public interface Test1 {{{0}" + + " {0}" + +#if NET_2_0 + " [A()]{0}" + + " public static int Main() {{{0}" + +#else + " public static void Main() {{{0}" + +#endif + " Test.InnerType x;{0}" + + " }}{0}" + + "}}{0}", NewLine), code); + } + #endregion Override implementation of CodeGeneratorFromTypeTestBase } @@ -2927,6 +2979,24 @@ namespace MonoTests.Microsoft.CSharp "}}{0}", NewLine), code, "#2"); } + [Test] + public override void EntryPointMethodTest () + { + string code = GenerateEntryPointMethod (Options); + Assert.AreEqual (string.Format (CultureInfo.InvariantCulture, + "public struct Test1 {{{0}" + + " {0}" + +#if NET_2_0 + " [A()]{0}" + + " public static int Main() {{{0}" + +#else + " public static void Main() {{{0}" + +#endif + " Test.InnerType x;{0}" + + " }}{0}" + + "}}{0}", NewLine), code); + } + #endregion Override implementation of CodeGeneratorFromTypeTestBase } @@ -3562,6 +3632,24 @@ namespace MonoTests.Microsoft.CSharp "}}{0}", NewLine), code); } + [Test] + public override void EntryPointMethodTest () + { + string code = GenerateEntryPointMethod (Options); + Assert.AreEqual (string.Format (CultureInfo.InvariantCulture, + "public enum Test1 {{{0}" + + " {0}" + +#if NET_2_0 + " [A()]{0}" + + " public static int Main() {{{0}" + +#else + " public static void Main() {{{0}" + +#endif + " Test.InnerType x;{0}" + + " }}{0}" + + "}}{0}", NewLine), code); + } + #endregion Override implementation of CodeGeneratorFromTypeTestBase } } diff --git a/mcs/class/System/Test/Microsoft.VisualBasic/ChangeLog b/mcs/class/System/Test/Microsoft.VisualBasic/ChangeLog index bdf69a2ef22..5177a0e5b68 100644 --- a/mcs/class/System/Test/Microsoft.VisualBasic/ChangeLog +++ b/mcs/class/System/Test/Microsoft.VisualBasic/ChangeLog @@ -1,3 +1,8 @@ +2005-10-28 Gert Driesen <drieseng@users.sourceforge.net> + + * CodeGeneratorFromTypeTest.cs: Added tests for CodeEntryPointMethod + and bug #76580. + 2005-10-25 Gert Driesen <drieseng@users.sourceforge.net> * CodeGeneratorTestBase.cs: Set eol-style to native. diff --git a/mcs/class/System/Test/Microsoft.VisualBasic/CodeGeneratorFromTypeTest.cs b/mcs/class/System/Test/Microsoft.VisualBasic/CodeGeneratorFromTypeTest.cs index d5a465d0915..4d12913734c 100644 --- a/mcs/class/System/Test/Microsoft.VisualBasic/CodeGeneratorFromTypeTest.cs +++ b/mcs/class/System/Test/Microsoft.VisualBasic/CodeGeneratorFromTypeTest.cs @@ -850,6 +850,22 @@ namespace MonoTests.Microsoft.VisualBasic " End Sub{0}" + "End Class{0}", NewLine), code); } + + [Test] + public override void EntryPointMethodTest () + { + string code = GenerateEntryPointMethod (Options); + Assert.AreEqual (string.Format (CultureInfo.InvariantCulture, + "Public Class Test1{0}" + + " {0}" + +#if NET_2_0 + " <A()> _{0}" + +#endif + " Public Shared Sub Main(){0}" + + " Dim x As Test.InnerType{0}" + + " End Sub{0}" + + "End Class{0}", NewLine), code); + } } [TestFixture] @@ -1311,6 +1327,20 @@ namespace MonoTests.Microsoft.VisualBasic Assert.AreEqual (string.Format (CultureInfo.InvariantCulture, "Public Delegate Sub Test1(){0}{0}", NewLine), code); } + + [Test] + public override void EntryPointMethodTest () + { + string code = GenerateEntryPointMethod (Options); + Assert.AreEqual (string.Format (CultureInfo.InvariantCulture, + "Public Delegate Sub Test1(){0}{0}" + +#if NET_2_0 + "<A()> _{0}" + +#endif + "Public Shared Sub Main(){0}" + + " Dim x As Test.InnerType{0}" + + "End Sub{0}", NewLine), code); + } } [TestFixture] @@ -1976,6 +2006,22 @@ namespace MonoTests.Microsoft.VisualBasic " {0}" + "End Interface{0}", NewLine), code); } + + [Test] + public override void EntryPointMethodTest () + { + string code = GenerateEntryPointMethod (Options); + Assert.AreEqual (string.Format (CultureInfo.InvariantCulture, + "Public Interface Test1{0}" + + " {0}" + +#if NET_2_0 + " <A()> _{0}" + +#endif + " Public Shared Sub Main(){0}" + + " Dim x As Test.InnerType{0}" + + " End Sub{0}" + + "End Interface{0}", NewLine), code); + } } [TestFixture] @@ -2747,6 +2793,22 @@ namespace MonoTests.Microsoft.VisualBasic " End Sub{0}" + "End Structure{0}", NewLine), code); } + + [Test] + public override void EntryPointMethodTest () + { + string code = GenerateEntryPointMethod (Options); + Assert.AreEqual (string.Format (CultureInfo.InvariantCulture, + "Public Structure Test1{0}" + + " {0}" + +#if NET_2_0 + " <A()> _{0}" + +#endif + " Public Shared Sub Main(){0}" + + " Dim x As Test.InnerType{0}" + + " End Sub{0}" + + "End Structure{0}", NewLine), code); + } } [TestFixture] @@ -3305,5 +3367,21 @@ namespace MonoTests.Microsoft.VisualBasic " {0}" + "End Enum{0}", NewLine), code); } + + [Test] + public override void EntryPointMethodTest () + { + string code = GenerateEntryPointMethod (Options); + Assert.AreEqual (string.Format (CultureInfo.InvariantCulture, + "Public Enum Test1{0}" + + " {0}" + +#if NET_2_0 + " <A()> _{0}" + +#endif + " Public Shared Sub Main(){0}" + + " Dim x As Test.InnerType{0}" + + " End Sub{0}" + + "End Enum{0}", NewLine), code); + } } } diff --git a/mcs/class/System/Test/System.CodeDom.Compiler/ChangeLog b/mcs/class/System/Test/System.CodeDom.Compiler/ChangeLog index 18026c6fd0d..39baa2aa42e 100644 --- a/mcs/class/System/Test/System.CodeDom.Compiler/ChangeLog +++ b/mcs/class/System/Test/System.CodeDom.Compiler/ChangeLog @@ -1,3 +1,11 @@ +2005-10-28 Gert Driesen <drieseng@users.sourceforge.net> + + * CodeGeneratorTestBase.cs: Set eol-style to native. + * CodeGeneratorTest.cs: Set eol-style to native. + * CodeGeneratorFromTypeTestBase.cs: Added tests for + CodeEntryPointMethod and bug #76580. Set eol-style to native. + * IndentedTextWriterTest.cs: Set eol-style to native. + 2005-10-25 Sebastien Pouliot <sebastien@ximian.com> * CompilerErrorCas.cs: Under 1.x CompilerError is protected by a diff --git a/mcs/class/System/Test/System.CodeDom.Compiler/CodeGeneratorFromTypeTestBase.cs b/mcs/class/System/Test/System.CodeDom.Compiler/CodeGeneratorFromTypeTestBase.cs index a557a8b4057..600a3294090 100644 --- a/mcs/class/System/Test/System.CodeDom.Compiler/CodeGeneratorFromTypeTestBase.cs +++ b/mcs/class/System/Test/System.CodeDom.Compiler/CodeGeneratorFromTypeTestBase.cs @@ -177,6 +177,9 @@ namespace MonoTests.System.CodeDom.Compiler [Test] public abstract void TypeConstructorTest (); + [Test] + public abstract void EntryPointMethodTest (); + protected string GenerateDefaultType (CodeGeneratorOptions options) { return GenerateCodeFromType (TypeDeclaration, options); @@ -981,5 +984,37 @@ namespace MonoTests.System.CodeDom.Compiler return GenerateCodeFromType (TypeDeclaration, options); } + + protected string GenerateEntryPointMethod (CodeGeneratorOptions options) + { + TypeDeclaration.Name = "Test1"; + + CodeEntryPointMethod method = new CodeEntryPointMethod (); + method.Name = "Something"; // should be ignored in C# and VB + method.Attributes = MemberAttributes.Private ; // should be ignored in C# and VB + method.ReturnType = new CodeTypeReference (typeof (int)); // should be ignored in C# 1.x and VB 1.x and 2.x + + // parameters on entry point are ignored in C# and VB + CodeParameterDeclarationExpression param = new CodeParameterDeclarationExpression ( + typeof (object), "value1"); + method.Parameters.Add (param); + + // custom attributes on entry point are ignored in C# 1.x and VB 1.x + CodeAttributeDeclaration attrDec = new CodeAttributeDeclaration (); + attrDec.Name = "A"; + method.CustomAttributes.Add (attrDec); + + CodeVariableDeclarationStatement v = new CodeVariableDeclarationStatement ("Test+InnerType", "x"); + method.Statements.Add (v); + + TypeDeclaration.Members.Add (method); + + /* + CodeTypeDeclaration nestedType = new CodeTypeDeclaration ("InnerType"); + TypeDeclaration.Members.Add (nestedType); + */ + + return GenerateCodeFromType (TypeDeclaration, options); + } } } |