[Mono-bugs] [Bug 35903][Nor] New - MemberInfo.ReturnTypeCustomAttributes not implemented
bugzilla-daemon@rocky.ximian.com
bugzilla-daemon@rocky.ximian.com
19 Dec 2002 02:20:37 -0000
Please do not reply to this email- if you want to comment on the bug, go to the
URL shown below and enter your comments there.
Changed by jonpryor@vt.edu.
http://bugzilla.ximian.com/show_bug.cgi?id=35903
--- shadow/35903 Wed Dec 18 21:20:37 2002
+++ shadow/35903.tmp.4762 Wed Dec 18 21:20:37 2002
@@ -0,0 +1,106 @@
+Bug#: 35903
+Product: Mono/Class Libraries
+Version: unspecified
+OS: Red Hat 8.0
+OS Details:
+Status: NEW
+Resolution:
+Severity:
+Priority: Normal
+Component: CORLIB
+AssignedTo: mono-bugs@ximian.com
+ReportedBy: jonpryor@vt.edu
+QAContact: mono-bugs@ximian.com
+TargetMilestone: ---
+URL:
+Cc:
+Summary: MemberInfo.ReturnTypeCustomAttributes not implemented
+
+Please fill in this template when reporting a bug, unless you know what you
+are doing.
+Description of Problem:
+
+This was a problem that effected both mcs and the class libraries. Mcs has
+been fixed; now it's time for the class libraries...
+
+"return" attribute targets do not behave the same under Mono and .NET.
+Consider the following program:
+
+ // file: rat.cs (return attribute target)
+ using System;
+ using System.Reflection;
+
+ public class MethodAttribute : Attribute {}
+ public class ReturnAttribute : Attribute {}
+
+ public class Test {
+ [Method]
+ [return: Return]
+ public void Method () {}
+
+ public static void Main () {
+ Type t = typeof(Test);
+ MethodInfo mi = t.GetMethod("Method");
+ ICustomAttributeProvider cap = mi.ReturnTypeCustomAttributes;
+ if (cap != null) {
+ object[] ca = cap.GetCustomAttributes (true);
+ foreach (object o in ca)
+ Console.WriteLine ("[return: " + o + "]");
+ }
+ else {
+ Console.WriteLine ("Error: no return type custom attributes");
+ }
+ }
+ }
+
+It compiles properly under both mcs and csc.exe.
+
+The runtime behavior is incorrect for the mcs-generated program.
+
+Under mcs/mono:
+ jon@melchior:tmp$ mono rat.exe
+ Error: no return type custom attributes
+
+Under csc.exe/.NET:
+ K:\tmp>rat.exe
+ [return: ReturnAttribute]
+
+Note that csc.exe/.NET correctly sees the "return" attribute-targeted
+attribute specified on Test.Method.
+
+However, it looks to be a Mono library/runtime issue as well. Under
+csc.exe/mono (compiled with csc.exe, run on Mono):
+ Error: no return type custom attributes
+
+So the mono runtime doesn't understand "return" attribute targets.
+
+The last combination, mcs-comiled and run on .NET, produces no output. I'm
+not sure why this is the case. (Under Windows XP with Visual Studio .NET
+installed, if that's important.)
+
+The next step is to examine the IL produced by csc.exe and mcs using
+ildasm.exe. There are two major difference I saw (just eyeballing the
+code; a diff between the IL produced with `ildasm.exe /all /utf8
+/out=<filename> assembly.exe' was too much to go over).
+
+First of all, the custom attributes on Test.Method are separated by a
+.param [0] line under csc.exe, but not mcs, e.g.:
+
+ .method public hidebysig instance void Method() cil managed
+ {
+ .custom instance void MethodAttribute::.ctor() = (01 00 00 00)
+ // the following line was produced by csc.exe but not mcs
+ .param [0] /*08000001*/
+ .custom instance void ReturnAttribute::.ctor() = (01 00 00 00)
+ }
+
+The other difference (not sure that it matters) was the token numbers
+produced between mcs and csc.exe. Under mcs, the MethodAttribute got a
+token of 0C000001 while csc.exe gave it 0C000003, and the ReturnAttribute
+got 0C000002 under mcs while csc.exe gave it 0C000001.
+
+Thus, it appears that both mono and mcs need improvement in handling
+[return:] attribute targets.
+
+See also: http://bugzilla.ximian.com/show_bug.cgi?id=35465
+This was the original report (fixed in mcs).