"disable_omit_fp" can now be included in MONO_DEBUG
[mono-project.git] / mcs / tests / test-102.cs
blob1c82586d3530ec41798fb2201b931603eb123335
1 using System;
2 using System.Reflection;
4 [assembly: AssemblyTitle ("Foo")]
5 [assembly: AssemblyVersion ("1.0.2")]
7 namespace N1 {
9 [AttributeUsage (AttributeTargets.All)]
10 public class MineAttribute : Attribute {
12 public string name;
14 public MineAttribute (string s)
16 name = s;
20 [AttributeUsage (AttributeTargets.ReturnValue)]
21 public class ReturnAttribute : Attribute {
23 public string name;
25 public ReturnAttribute (string s)
27 name = s;
31 public interface TestInterface {
32 void Hello ([Mine ("param")] int i);
35 public class Foo {
37 int i;
39 [Mine ("Foo")]
40 [return: Return ("Bar")]
41 public static int Main ()
43 Type t = typeof (Foo);
44 foreach (MemberInfo m in t.GetMembers ()){
45 if (m.Name == "Main"){
46 MethodInfo mb = (MethodInfo) m;
48 ICustomAttributeProvider p = mb.ReturnTypeCustomAttributes;
49 object [] ret_attrs = p.GetCustomAttributes (false);
51 if (ret_attrs.Length != 1){
52 Console.WriteLine ("Got more than one return attribute");
53 return 1;
55 if (!(ret_attrs [0] is ReturnAttribute)){
56 Console.WriteLine ("Dit not get a MineAttribute");
57 return 2;
60 ReturnAttribute ma = (ReturnAttribute) ret_attrs [0];
61 if (ma.name != "Bar"){
62 Console.WriteLine ("The return attribute is not Bar");
63 return 2;
68 Type ifType = typeof (TestInterface);
70 MethodInfo method = ifType.GetMethod ("Hello",
71 BindingFlags.Public | BindingFlags.Instance);
73 ParameterInfo[] parameters = method.GetParameters();
74 ParameterInfo param = parameters [0];
76 object[] testAttrs = param.GetCustomAttributes (true);
78 if (testAttrs.Length != 1)
79 return 1;
81 return 0;