2 using System.Reflection;
4 [assembly: AssemblyTitle ("Foo")]
5 [assembly: AssemblyVersion ("1.0.2")]
9 [AttributeUsage (AttributeTargets.All)]
10 public class MineAttribute : Attribute {
14 public MineAttribute (string s)
20 [AttributeUsage (AttributeTargets.ReturnValue)]
21 public class ReturnAttribute : Attribute {
25 public ReturnAttribute (string s)
41 [return: Return ("Bar")]
42 public static int Main ()
44 Type t = typeof (Foo);
45 foreach (MemberInfo m in t.GetMembers ()){
46 if (m.Name == "Main"){
47 MethodInfo mb = (MethodInfo) m;
49 ICustomAttributeProvider p = mb.ReturnTypeCustomAttributes;
50 object [] ret_attrs = p.GetCustomAttributes (false);
52 if (ret_attrs.Length != 1){
53 Console.WriteLine ("Got more than one return attribute");
56 if (!(ret_attrs [0] is ReturnAttribute)){
57 Console.WriteLine ("Dit not get a MineAttribute");
61 ReturnAttribute ma = (ReturnAttribute) ret_attrs [0];
62 if (ma.name != "Bar"){
63 Console.WriteLine ("The return attribute is not Bar");