Update to recent changes -- mostly testcases failing due to missing ArrayList
[mcs.git] / tests / gtest-autoproperty-03.cs
blobe0787572cce018b9e702b378332d8c9017efb4f7
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;
7 public class Test
9 public string Foo { get; set; }
11 static int Main ()
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;
22 if (fields [0].Name != "<Foo>k__BackingField")
23 return 10;
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;
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;
40 return 0;