Please do not reply to this email- if you want to comment on the bug, go to the URL shown below and enter your comments there.
Changed by [EMAIL PROTECTED] http://bugzilla.ximian.com/show_bug.cgi?id=79666 --- shadow/79666 2006-10-15 07:27:29.000000000 -0400 +++ shadow/79666.tmp.19389 2006-10-15 07:27:29.000000000 -0400 @@ -0,0 +1,71 @@ +Bug#: 79666 +Product: Mono: Compilers +Version: unspecified +OS: +OS Details: +Status: NEW +Resolution: +Severity: +Priority: Normal +Component: C# +AssignedTo: [EMAIL PROTECTED] +ReportedBy: [EMAIL PROTECTED] +QAContact: [EMAIL PROTECTED] +TargetMilestone: --- +URL: +Cc: +Summary: can't use arrays of enums as cattr parameters + +The testcase is an extended version of test-454.cs. csc compiles it fine, +while mcs says: + +test-454.cs(23,33): error CS0182: An attribute argument must be a constant +expression, typeof expression or array creation expression + +<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<< +// Test various kinds of arrays as custom attribute parameters +using System; + +enum EnumType { + X, + Y +}; + +class FooAttribute : Attribute +{ + public string [] StringValues; + public object [] ObjectValues; + public EnumType [] EnumValues; + public Type [] Types; + + public FooAttribute () + { + } +} + +[Foo (StringValues = new string [] {"foo", "bar", "baz"}, + ObjectValues = new object [] {1, 'A', "B"}, + EnumValues = new EnumType [] { EnumType.X, EnumType.Y }, + Types = new Type [] {typeof (int), typeof (Type)} + )] +class Test +{ + public static void Main () + { + FooAttribute foo = (FooAttribute) typeof (Test) + .GetCustomAttributes (false) [0]; + if (foo.StringValues [0] != "foo" + || foo.StringValues [1] != "bar" + || foo.StringValues [2] != "baz" + || 1 != (int) foo.ObjectValues [0] + || 'A' != (char) foo.ObjectValues [1] + || "B" != (string) foo.ObjectValues [2] + || EnumType.X != foo.EnumValues [0] + || EnumType.Y != foo.EnumValues [1] + || foo.Types [0] != typeof (int) + || foo.Types [1] != typeof (Type) + ) + throw new ApplicationException (); + } +} +<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<< _______________________________________________ mono-bugs maillist - [email protected] http://lists.ximian.com/mailman/listinfo/mono-bugs
