Bug 318877 (MONO75968) - [PATCH] allow string array for attribute parameter type
Summary: [PATCH] allow string array for attribute parameter type
Status: RESOLVED FIXED
Alias: MONO75968
Product: Mono: Compilers
Classification: Mono
Component: C# (show other bugs)
Version: 1.1
Hardware: Other Other
: P3 - Medium : Normal
Target Milestone: ---
Assignee: Atsushi Enomoto
QA Contact: Mono Bugs
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2005-09-02 17:52 UTC by Atsushi Enomoto
Modified: 2007-09-15 21:24 UTC (History)
0 users

See Also:
Found By: ---
Services Priority:
Business Priority:
Blocker: ---
Marketing QA Status: ---
IT Deployment: ---


Attachments
proposed fix (1.39 KB, patch)
2005-09-02 17:52 UTC, Thomas Wiest
Details | Diff
improved patch. Type[] and Object[] should be treated as well. (1.70 KB, patch)
2005-09-05 09:13 UTC, Thomas Wiest
Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Thomas Wiest 2007-09-15 19:29:19 UTC


---- Reported by atsushi@ximian.com 2005-09-02 10:52:12 MST ----

Currently mcs does not allow string array type as a parameter type, while
it is allowed:

<blockquote>
24.1.3 Attribute parameter types
The types of positional and named parameters for an attribute class are
limited to the attribute parameter
types, which are:
• One of the following types: bool, byte, char, double, float, int, long,
short, string.
• The type object.
• The type System.Type.
• An enum type, provided it has public accessibility and the types in which
it is nested (if any) also have
public accessibility.
• Single-dimensional arrays of the above types.
</blockquote>

---- repro ----
using System;

class FooAttribute : Attribute
{
        public string [] Values;

        public FooAttribute ()
        {
        }
}

[Foo (Values = new string [] {"foo", "bar", "baz"})]
class Test
{
        public static void Main () {}
}
--------


Actual Results:

test-453.cs(13,2): error CS0655: `Values' is not a valid named attribute
argument because it is not a valid attribute parameter type.

Expected Results:

Compiles successfully.

Attaching a fix.



---- Additional Comments From atsushi@ximian.com 2005-09-02 10:52:38 MST ----

Created an attachment (id=168455)
proposed fix




---- Additional Comments From rharinath@novell.com 2005-09-02 14:50:49 MST ----

Looks good.  Please apply.



---- Additional Comments From atsushi@ximian.com 2005-09-05 02:13:12 MST ----

Created an attachment (id=168456)
improved patch. Type[] and Object[] should be treated as well.




---- Additional Comments From atsushi@ximian.com 2005-09-05 13:54:03 MST ----

Fixed in svn (r49488).

Imported an attachment (id=168455)
Imported an attachment (id=168456)

Unknown operating system unknown. Setting to default OS "Other".