MacroDef: Setting attribute via API should convert to lowercase

classic Classic list List threaded Threaded
5 messages Options
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

MacroDef: Setting attribute via API should convert to lowercase

Al Le
Hello,

in my ant script, I define a task "MyTask" via "macrodef". The task has a mandatory attribute "nodeName" (not the camelCase name).

Then I call the task from a javascript snippet:

var myTask = project.createTask('myTask');
myTask.setDynamicAttribute("nodeName", "blah");
myTask.perform();


This does not work because I use the camleCase name in the call to setDynamicAttribute. Later, when the task is performed, I get an error that the attribute "nodename" (lowercase!) is not set.

In the source of MacroInstance I see that attribute names are converted to lower case when they are retrieved. But why are they not converted when they are set?

When I use this (note the lowercase name)

    myTask.setDynamicAttribute("nodename", "blah");

everything works. But here I''m forced to use an attribute name I didn't specify (I specified "nodeName").

Why is it made this way?

I see one reason for converting everything to lower case -- to avoid errors due to a wrong capitalizing. But then the conversion should be done everywhere, i.e. when getting and when setting the attributes.

Regards
AL

---------------------------------------------------------------------
To unsubscribe, e-mail: [hidden email]
For additional commands, e-mail: [hidden email]

Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: MacroDef: Setting attribute via API should convert to lowercase

Stefan Bodewig
On 2016-04-12, Al Le wrote:

> in my ant script, I define a task "MyTask" via "macrodef". The task
> has a mandatory attribute "nodeName" (not the camelCase name).

> Then I call the task from a javascript snippet:

> var myTask = project.createTask('myTask');
> myTask.setDynamicAttribute("nodeName", "blah");
> myTask.perform();

> This does not work because I use the camleCase name in the call to
> setDynamicAttribute. Later, when the task is performed, I get an error
> that the attribute "nodename" (lowercase!) is not set.

> In the source of MacroInstance I see that attribute names are
> converted to lower case when they are retrieved. But why are they not
> converted when they are set?

My guess is that you are the first person who's trying what you do and
you've simply hit a bug.

Any attribute set on a MacroInstance via an ant build file gets
lowercased in IntrospectionHelper - we've probably just overlooked the
case of anybody using the API directly.

Please open a bug ticket.

> I see one reason for converting everything to lower case

That's how Ant build files have always worked, task attributes are not
case-sensitive. And IntrospectionHelper is the central piece of mapping
attributes to method names or dynamic attributes (and a few other
things) - which takes care of using lowercase attribute names.

If you want to work around this, you may want to use IntrospectionHelper
via its API as well.

IntrospectionHelper.getHelper(MacroInstance.class).setAttribute(...)

Stefan

---------------------------------------------------------------------
To unsubscribe, e-mail: [hidden email]
For additional commands, e-mail: [hidden email]

Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: MacroDef: Setting attribute via API should convert to lowercase

Al Le
> My guess is that you are the first person who's trying what you do and
> you've simply hit a bug.
>
> [...]
>
> Please open a bug ticket.

Created the bug report 59339.

---------------------------------------------------------------------
To unsubscribe, e-mail: [hidden email]
For additional commands, e-mail: [hidden email]

Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: MacroDef: Setting attribute via API should convert to lowercase

Stefan Bodewig
On 2016-04-17, Al Le wrote:


>> Please open a bug ticket.

> Created the bug report 59339.

Thanks, should be fixed in git, will be fixed in 1.9.8 and 1.10.0.

Stefan

---------------------------------------------------------------------
To unsubscribe, e-mail: [hidden email]
For additional commands, e-mail: [hidden email]

Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Aw: Re: MacroDef: Setting attribute via API should convert to lowercase

Al Le
> Thanks, should be fixed in git, will be fixed in 1.9.8 and 1.10.0.

That's not fair! I've needed so long to identify the problem and create a bug report, and you fix it so quickly! :-)

---------------------------------------------------------------------
To unsubscribe, e-mail: [hidden email]
For additional commands, e-mail: [hidden email]

Loading...