New test.
[mono.git] / mcs / class / corlib / Test / System.Reflection.Emit / MethodBuilderTest.cs
index f63bf0127e2515035bbf245f957d27530985cbb2..3f1b82fc38e0e1a59ed3436c03661853df29ed16 100644 (file)
@@ -535,6 +535,13 @@ public class MethodBuilderTest : Assertion
                }
        }
 
+       [AttributeUsage (AttributeTargets.Parameter)]
+       class PrivateAttribute : Attribute {
+
+               public PrivateAttribute () {
+               }
+       }
+
        [Test]
        public void GetCustomAttributes () {
                TypeBuilder tb = module.DefineType (genTypeName (), TypeAttributes.Public);
@@ -549,6 +556,9 @@ public class MethodBuilderTest : Assertion
 
                mb.SetCustomAttribute (new CustomAttributeBuilder (ctorInfo, new object [] { "FOO" }));
 
+               // Check that attributes not accessible are not returned
+               mb.SetCustomAttribute (new CustomAttributeBuilder (typeof (PrivateAttribute).GetConstructor (new Type [0]), new object [] { }));
+
                Type t = tb.CreateType ();
 
                // Try the created type
@@ -611,8 +621,7 @@ public class MethodBuilderTest : Assertion
                        try {
                                mb.AddDeclarativeSecurity (action, set);
                                Fail ();
-                       }
-                       catch (ArgumentException) {
+                       } catch (ArgumentOutOfRangeException) {
                        }
                }
        }