} catch (NotSupportedException) {\r
}\r
}\r
+\r
+ public void TestSetCustomAttribute () {\r
+ TypeBuilder tb = module.DefineType ("class21", TypeAttributes.Public);\r
+ ConstructorBuilder cb = tb.DefineConstructor (\r
+ 0, 0, \r
+ new Type [1] {typeof(int)});\r
+ cb.GetILGenerator ().Emit (OpCodes.Ret);\r
+\r
+ // Null argument\r
+ try {\r
+ cb.SetCustomAttribute (null);\r
+ Fail ();\r
+ } catch (ArgumentNullException) {\r
+ }\r
+\r
+ byte[] custAttrData = { 1, 0, 0, 0, 0};\r
+ Type attrType = Type.GetType\r
+ ("System.Reflection.AssemblyKeyNameAttribute");\r
+ Type[] paramTypes = new Type[1];\r
+ paramTypes[0] = typeof(String);\r
+ ConstructorInfo ctorInfo =\r
+ attrType.GetConstructor(paramTypes);\r
+\r
+ cb.SetCustomAttribute (ctorInfo, custAttrData);\r
+\r
+ // Null arguments again\r
+ try {\r
+ cb.SetCustomAttribute (null, new byte[2]);\r
+ Fail ();\r
+ } catch (ArgumentNullException) {\r
+ }\r
+\r
+ try {\r
+ cb.SetCustomAttribute (ctorInfo, null);\r
+ Fail ();\r
+ } catch (ArgumentNullException) {\r
+ }\r
+ }\r
}\r
}\r