Page 1 of 3
Use of Attributes
Posted: Tue Mar 21, 2017 12:27 pm
by Meinhard
Hi guys!
I want to apply this attribute to a property :
[Option('i',"input",Required := true, HelpText := "Input file to read.")];
But I get this error:
XS0182 An attribute argument must be a constant expression, typeof expression or array creation expression of an attribute parameter type
What am I doing wrong?
TIA
Meinhard
Use of Attributes
Posted: Tue Mar 21, 2017 12:42 pm
by robert
Meinhard,
What happens if you use "i" in stead of 'i' ?
Robert
Use of Attributes
Posted: Tue Mar 21, 2017 12:43 pm
by wriedmann
Hi Meinhard,
a complete shot in the dark (before Robert gives the right answer):
I would try
Code: Select all
[Option{'i',"input",Required := true, HelpText := "Input file to read."}]
Wolfgang
Use of Attributes
Posted: Tue Mar 21, 2017 12:48 pm
by Meinhard
Hi Robert,
same message.
Regards
Meinhard
Use of Attributes
Posted: Tue Mar 21, 2017 12:49 pm
by Meinhard
Hi Wolfgang,
already tried, but accroding to the grammar this is invalid syntax anyway.
Regards
Meinhard
Use of Attributes
Posted: Tue Mar 21, 2017 1:13 pm
by robert
Meinhard,
what type is the OptionAttribute ?
And what happens if you omit one or more values from the definition ?
Can you send me the assembly that defines the optionattribute class ?
Robert
Use of Attributes
Posted: Tue Mar 21, 2017 6:38 pm
by Meinhard
Hi Robert,
just sent you the complete solution (small) via email.
TIA & Regards
Meinhard
Use of Attributes
Posted: Tue Mar 21, 2017 8:55 pm
by robert
For those reading :
We have found the problem with Meinhards code: there is a problem handling literal character values in Attributes and Switch statements.
In this case the OptionAttribute class expects a literal character followed by a literal string, and this is not handled properly by the compiler.
We will fix this asap.
Robert
Use of Attributes
Posted: Wed Mar 22, 2017 7:21 am
by wriedmann
Hi,
again this fast reaction of the development team confirms my decision to use X# as my primary development tool.
Wolfgang
Use of Attributes
Posted: Wed Mar 22, 2017 7:28 am
by Meinhard
Indeed!