Author: gert
Date: 2005-07-05 11:39:44 -0400 (Tue, 05 Jul 2005)
New Revision: 46950

Modified:
   trunk/mcs/class/System/Microsoft.CSharp/CSharpCodeGenerator.cs
   trunk/mcs/class/System/Microsoft.CSharp/ChangeLog
   trunk/mcs/class/System/Microsoft.VisualBasic/ChangeLog
   trunk/mcs/class/System/Microsoft.VisualBasic/VBCodeGenerator.cs
   trunk/mcs/class/System/Test/Microsoft.CSharp/ChangeLog
   trunk/mcs/class/System/Test/Microsoft.CSharp/CodeGeneratorFromTypeTest.cs
   trunk/mcs/class/System/Test/Microsoft.VisualBasic/ChangeLog
   
trunk/mcs/class/System/Test/Microsoft.VisualBasic/CodeGeneratorFromTypeTest.cs
Log:
* CodeGeneratorFromTypeTest.cs: Added test for ReturnTypeCustomAttributes.
* CSharpCodeGenerator.cs: Fixed output of ReturnTypeCustomAttributes.
* VBCodeGenerator.cs: Added support for ReturnTypeCustomAttributes.


Modified: trunk/mcs/class/System/Microsoft.CSharp/CSharpCodeGenerator.cs
===================================================================
--- trunk/mcs/class/System/Microsoft.CSharp/CSharpCodeGenerator.cs      
2005-07-05 15:34:51 UTC (rev 46949)
+++ trunk/mcs/class/System/Microsoft.CSharp/CSharpCodeGenerator.cs      
2005-07-05 15:39:44 UTC (rev 46950)
@@ -592,8 +592,8 @@
 
                        OutputAttributes (method.CustomAttributes, null, false);
 
-                       if (method.ReturnTypeCustomAttributes.Count > 0)
-                               OutputAttributeDeclarations 
(method.ReturnTypeCustomAttributes);
+                       OutputAttributes (method.ReturnTypeCustomAttributes, 
+                               "return: ", false);
 
                        MemberAttributes attributes = method.Attributes;
 
@@ -838,9 +838,6 @@
                protected override void GenerateAttributeDeclarationsStart( 
CodeAttributeDeclarationCollection attributes )
                {
                        Output.Write ('[');
-                       CodeMemberMethod met = CurrentMember as 
CodeMemberMethod;
-                       if (met != null && met.ReturnTypeCustomAttributes == 
attributes)
-                               Output.Write ("return: ");
                }
                
                protected override void GenerateAttributeDeclarationsEnd( 
CodeAttributeDeclarationCollection attributes )

Modified: trunk/mcs/class/System/Microsoft.CSharp/ChangeLog
===================================================================
--- trunk/mcs/class/System/Microsoft.CSharp/ChangeLog   2005-07-05 15:34:51 UTC 
(rev 46949)
+++ trunk/mcs/class/System/Microsoft.CSharp/ChangeLog   2005-07-05 15:39:44 UTC 
(rev 46950)
@@ -1,5 +1,9 @@
 2005-07-02 Gert Driesen <[EMAIL PROTECTED]>
 
+       * CSharpCodeGenerator.cs: Fixed output of ReturnTypeCustomAttributes.
+
+2005-07-02 Gert Driesen <[EMAIL PROTECTED]>
+
        * CSharpCodeGenerator.cs: Added PrivateImplementationType support
        for events, properties, methods. No longer output scope modifier
        for events.

Modified: trunk/mcs/class/System/Microsoft.VisualBasic/ChangeLog
===================================================================
--- trunk/mcs/class/System/Microsoft.VisualBasic/ChangeLog      2005-07-05 
15:34:51 UTC (rev 46949)
+++ trunk/mcs/class/System/Microsoft.VisualBasic/ChangeLog      2005-07-05 
15:39:44 UTC (rev 46950)
@@ -1,5 +1,9 @@
 2005-07-02  Gert Driesen <[EMAIL PROTECTED]>
 
+       * VBCodeGenerator.cs: Added support for ReturnTypeCustomAttributes.
+
+2005-07-02  Gert Driesen <[EMAIL PROTECTED]>
+
        * VBCodeGenerator.cs: Scope modifiers should not be output for
        events.
 

Modified: trunk/mcs/class/System/Microsoft.VisualBasic/VBCodeGenerator.cs
===================================================================
--- trunk/mcs/class/System/Microsoft.VisualBasic/VBCodeGenerator.cs     
2005-07-05 15:34:51 UTC (rev 46949)
+++ trunk/mcs/class/System/Microsoft.VisualBasic/VBCodeGenerator.cs     
2005-07-05 15:39:44 UTC (rev 46950)
@@ -655,6 +655,8 @@
 
                        if (!isSub) {
                                output.Write (" As ");
+                               OutputAttributes 
(method.ReturnTypeCustomAttributes, null,
+                                       LineHandling.InLine);
                                OutputType (method.ReturnType);
                        }
 

Modified: trunk/mcs/class/System/Test/Microsoft.CSharp/ChangeLog
===================================================================
--- trunk/mcs/class/System/Test/Microsoft.CSharp/ChangeLog      2005-07-05 
15:34:51 UTC (rev 46949)
+++ trunk/mcs/class/System/Test/Microsoft.CSharp/ChangeLog      2005-07-05 
15:39:44 UTC (rev 46950)
@@ -1,5 +1,10 @@
 2005-07-02  Gert Driesen <[EMAIL PROTECTED]>
 
+       * CodeGeneratorFromTypeTest.cs: Added test for 
+       ReturnTypeCustomAttributes.
+
+2005-07-02  Gert Driesen <[EMAIL PROTECTED]>
+
        * CodeGeneratorFromTypeTest.cs: Added event ImplementationTypes
        tests. Added PrivateImplementationType and property and method
        overload tests. Added property indexer tests.

Modified: 
trunk/mcs/class/System/Test/Microsoft.CSharp/CodeGeneratorFromTypeTest.cs
===================================================================
--- trunk/mcs/class/System/Test/Microsoft.CSharp/CodeGeneratorFromTypeTest.cs   
2005-07-05 15:34:51 UTC (rev 46949)
+++ trunk/mcs/class/System/Test/Microsoft.CSharp/CodeGeneratorFromTypeTest.cs   
2005-07-05 15:39:44 UTC (rev 46950)
@@ -993,6 +993,52 @@
                }
 
                [Test]
+               public 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 ();
+                       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);
+               }
+
+               [Test]
                public void ConstructorAttributesTest ()
                {
                        type.Name = "Test1";

Modified: trunk/mcs/class/System/Test/Microsoft.VisualBasic/ChangeLog
===================================================================
--- trunk/mcs/class/System/Test/Microsoft.VisualBasic/ChangeLog 2005-07-05 
15:34:51 UTC (rev 46949)
+++ trunk/mcs/class/System/Test/Microsoft.VisualBasic/ChangeLog 2005-07-05 
15:39:44 UTC (rev 46950)
@@ -1,5 +1,10 @@
 2005-07-02  Gert Driesen <[EMAIL PROTECTED]>
 
+       * CodeGeneratorFromTypeTest.cs: Added test for 
+       ReturnTypeCustomAttributes.
+
+2005-07-02  Gert Driesen <[EMAIL PROTECTED]>
+
        * CodeGeneratorFromTypeTest.cs: Modified test to ensure that scope
        modifiers are not output for events.
 

Modified: 
trunk/mcs/class/System/Test/Microsoft.VisualBasic/CodeGeneratorFromTypeTest.cs
===================================================================
--- 
trunk/mcs/class/System/Test/Microsoft.VisualBasic/CodeGeneratorFromTypeTest.cs  
    2005-07-05 15:34:51 UTC (rev 46949)
+++ 
trunk/mcs/class/System/Test/Microsoft.VisualBasic/CodeGeneratorFromTypeTest.cs  
    2005-07-05 15:39:44 UTC (rev 46950)
@@ -1098,6 +1098,50 @@
                }
 
                [Test]
+               public 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 ();
+                       Assert.AreEqual (string.Format 
(CultureInfo.InvariantCulture,
+                               "Public Class Test1{0}"
+                               + "    {0}"
+                               + "    <A(),  _{0}"
+                               + "     B()>  _{0}"
+                               + "    Public Overridable Function Execute() As 
<C(A1:=false, A2:=true), D()> Integer{0}"
+                               + "    End Function{0}"
+                               + "End Class{0}", writer.NewLine), Code);
+               }
+
+               [Test]
                public void ConstructorAttributesTest ()
                {
                        type.Name = "Test1";

_______________________________________________
Mono-patches maillist  -  [email protected]
http://lists.ximian.com/mailman/listinfo/mono-patches

Reply via email to