1 // Compiler options: -langversion:linq
2 // Make sure that the field and accessor methods of an automatic property have the CompilerGenerated attribute
4 using System.Reflection;
5 using System.Runtime.CompilerServices;
9 public string Foo { get; set; }
13 FieldInfo [] fields = typeof (Test).GetFields(BindingFlags.NonPublic | BindingFlags.Instance);
14 if (!(fields.Length > 0))
16 object [] field_atts = fields[0].GetCustomAttributes (false);
17 if (!(field_atts.Length > 0))
19 if (field_atts[0].GetType() != typeof (CompilerGeneratedAttribute))
22 PropertyInfo property = typeof (Test).GetProperty ("Foo");
23 MethodInfo get = property.GetGetMethod (false);
24 object [] get_atts = get.GetCustomAttributes (false);
25 if (!(get_atts.Length > 0))
27 if (get_atts[0].GetType() != typeof (CompilerGeneratedAttribute))
30 MethodInfo set = property.GetSetMethod (false);
31 object [] set_atts = set.GetCustomAttributes (false);
32 if (!(set_atts.Length > 0))
34 if (set_atts[0].GetType() != typeof (CompilerGeneratedAttribute))