X-Git-Url: http://wien.tomnetworks.com/gitweb/?a=blobdiff_plain;f=mono%2Ftests%2Fcustom-attr.cs;h=b8d35607ae6dc3411731a31bead8c26b96274408;hb=e00a400b3b1beca91822859884a7594354ea5081;hp=7e8d50dd41d7a743a52d2b898e48f0469755f2a0;hpb=bd9f9ee7cb81823608edc76ef9d0b6416783fe71;p=mono.git diff --git a/mono/tests/custom-attr.cs b/mono/tests/custom-attr.cs index 7e8d50dd41d..b8d35607ae6 100644 --- a/mono/tests/custom-attr.cs +++ b/mono/tests/custom-attr.cs @@ -32,6 +32,27 @@ namespace Test { public char[] Prop2; } + + class XAttribute : Attribute { + public XAttribute () + { + throw new Exception ("X"); + } + } + + interface ZInterface { + } + + class ZAttribute : Attribute, ZInterface { + } + + [X, Z, Serializable] + class Y { + } + + [My("arg\0string\0with\0nuls")] + class NulTests { + } [My("testclass")] [My2("testclass", 22)] @@ -61,6 +82,38 @@ namespace Test { } } } + + // + // Test that requesting a specific custom attributes does not + // create all the others + // + + typeof (Y).IsDefined (typeof (ZAttribute), true); + typeof (Y).IsDefined (typeof (XAttribute), true); + + typeof (Y).GetCustomAttributes (typeof (ZAttribute), true); + + try { + typeof (Y).GetCustomAttributes (true); + return 4; + } + catch { + } + + if (typeof (Y).GetCustomAttributes (typeof (ZInterface), true).Length != 1) + return 5; + + if (!typeof (Y).IsDefined (typeof (ZInterface), true)) + return 6; + + // Test that synthetic methods have no attributes + if (typeof(int[,]).GetConstructor (new Type [] { typeof (int), typeof (int) }).GetCustomAttributes (true).Length != 0) + return 7; + + // Test that nuls are preserved (see Xamarin bug 5732) + if (((MyAttribute)typeof (NulTests).GetCustomAttributes (true)[0]).val != "arg\0string\0with\0nuls") + return 8; + return 0; } }