do not check order sequence if option /order was not used
[mono.git] / mcs / tests / gtest-autoproperty-03.cs
1
2 // Make sure that the field and accessor methods of an automatic property have the CompilerGenerated attribute
3 using System;
4 using System.Reflection;
5 using System.Runtime.CompilerServices;
6
7 public class Test
8 {
9         public string Foo { get; set; }
10         
11         static int Main ()
12         {
13                 FieldInfo [] fields = typeof (Test).GetFields(BindingFlags.NonPublic | BindingFlags.Instance);
14                 if (!(fields.Length > 0))
15                         return 1;
16                 object [] field_atts = fields[0].GetCustomAttributes (false);
17                 if (!(field_atts.Length > 0))
18                         return 2;
19                 if (field_atts[0].GetType() != typeof (CompilerGeneratedAttribute))
20                         return 3;
21                         
22                 if (fields [0].Name != "<Foo>k__BackingField")
23                         return 10;
24                 
25                 PropertyInfo property = typeof (Test).GetProperty ("Foo");
26                 MethodInfo get = property.GetGetMethod (false);
27                 object [] get_atts = get.GetCustomAttributes (false);
28                 if (!(get_atts.Length > 0))
29                         return 4;
30                 if (get_atts[0].GetType() != typeof (CompilerGeneratedAttribute))
31                         return 5;
32                         
33                 MethodInfo set = property.GetSetMethod (false);
34                 object [] set_atts = set.GetCustomAttributes (false);
35                 if (!(set_atts.Length > 0))
36                         return 6;
37                 if (set_atts[0].GetType() != typeof (CompilerGeneratedAttribute))
38                         return 7;
39
40                 return 0;
41         }
42 }