Use of Attributes

This forum is meant for questions and discussions about the X# language and tools
User avatar
Meinhard
Posts: 81
Joined: Thu Oct 01, 2015 4:51 pm

Use of Attributes

Post 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
User avatar
robert
Posts: 4518
Joined: Fri Aug 21, 2015 10:57 am
Location: Netherlands

Use of Attributes

Post by robert »

Meinhard,

What happens if you use "i" in stead of 'i' ?

Robert
XSharp Development Team
The Netherlands
robert@xsharp.eu
User avatar
wriedmann
Posts: 3755
Joined: Mon Nov 02, 2015 5:07 pm
Location: Italy

Use of Attributes

Post 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
Wolfgang Riedmann
Meran, South Tyrol, Italy
wolfgang@riedmann.it
https://www.riedmann.it - https://docs.xsharp.it
User avatar
Meinhard
Posts: 81
Joined: Thu Oct 01, 2015 4:51 pm

Use of Attributes

Post by Meinhard »

Hi Robert,

same message.

Regards
Meinhard
User avatar
Meinhard
Posts: 81
Joined: Thu Oct 01, 2015 4:51 pm

Use of Attributes

Post by Meinhard »

Hi Wolfgang,

already tried, but accroding to the grammar this is invalid syntax anyway.

Regards
Meinhard
User avatar
robert
Posts: 4518
Joined: Fri Aug 21, 2015 10:57 am
Location: Netherlands

Use of Attributes

Post 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
XSharp Development Team
The Netherlands
robert@xsharp.eu
User avatar
Meinhard
Posts: 81
Joined: Thu Oct 01, 2015 4:51 pm

Use of Attributes

Post by Meinhard »

Hi Robert,

just sent you the complete solution (small) via email.

TIA & Regards
Meinhard
User avatar
robert
Posts: 4518
Joined: Fri Aug 21, 2015 10:57 am
Location: Netherlands

Use of Attributes

Post 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
XSharp Development Team
The Netherlands
robert@xsharp.eu
User avatar
wriedmann
Posts: 3755
Joined: Mon Nov 02, 2015 5:07 pm
Location: Italy

Use of Attributes

Post by wriedmann »

Hi,

again this fast reaction of the development team confirms my decision to use X# as my primary development tool.

Wolfgang
Wolfgang Riedmann
Meran, South Tyrol, Italy
wolfgang@riedmann.it
https://www.riedmann.it - https://docs.xsharp.it
User avatar
Meinhard
Posts: 81
Joined: Thu Oct 01, 2015 4:51 pm

Use of Attributes

Post by Meinhard »

Indeed!
Post Reply