Bugs item #2697388, was opened at 2009-03-20 14:07
Message generated for change (Comment added) made by drieseng
You can respond by visiting: 
https://sourceforge.net/tracker/?func=detail&atid=402868&aid=2697388&group_id=31650

Please note that this message will contain a full copy of the comment thread,
including the initial issue submission, for this request,
not just the latest update.
Category: Core
Group: cvs
Status: Open
Resolution: None
Priority: 5
Private: No
Submitted By: georgesz (georgesz)
Assigned to: Nobody/Anonymous (nobody)
Summary: readonly property not readonly if already exist readwrite

Initial Comment:
Once a property has been defined read-write, if it is redefined readonly, the 
readonly attribute is ignored. I tested this with 0.85 and 
nant-0.86-nightly-2009-01-30. For example:

  <!-- This defines the property readwrite. -->
  <property name="p1" value="1"/>
  <echo message="${p1};${property::is-readonly('p1')}"/>
  <!-- This should redefine the property readonly, ... -->
  <property name="p1" value="2" readonly="true"/>
  <echo message="${p1};${property::is-readonly('p1')}"/>
  <!-- but it doesn't. The property can be set to '3'. -->
  <property name="p1" value="3"/>
  <echo message="${p1};${property::is-readonly('p1')}"/>

If this is by design, it should be noted in the documentation, for example in 
help/fundamentals/properties.html or help/tasks/property.html, as this behavior 
can be unexpected.

----------------------------------------------------------------------

>Comment By: Gert Driesen (drieseng)
Date: 2009-03-23 21:00

Message:
I'll accept patches in any format (even full source files, if the lastest
from CVS is used as base) ;-)

Regarding making read-only properties writable:
There's a difference between attempting to assign a value to a read-only
property (which we do not treat as an error, for backward compatibility),
and explicitly attempting to mark a read-only property writable. However,
the "readonly" attribute is backed by a bool in the property task, and as
such we cannot check if the user explicitly provided a value for the
"readonly" attribute (or if he went along with the default value).

----------------------------------------------------------------------

Comment By: georgesz (georgesz)
Date: 2009-03-23 18:57

Message:
Thanks for the quick follow up. I had already started looking at the code.
I could provide a patch and a unit test for PropertyTest.cs, but I am not
sure in which format you accept patches.

Regarding "attempting to make a read-only property writable", it already
displays the message "Read-only property \"{0}\" cannot be overwritten."
when attempting to set a read-only property.

----------------------------------------------------------------------

Comment By: Gert Driesen (drieseng)
Date: 2009-03-23 18:18

Message:
I'll add support for marking a given property read-only, and will report an
error when attempting to make a read-only property writable.

----------------------------------------------------------------------

Comment By: georgesz (georgesz)
Date: 2009-03-23 17:16

Message:
Here is my use case where I encountered this problem: I was working on a
NAnt script in 2 different environments: test and production. For the same
NAnt script to support those 2 environments, I included a files containing
the computer name (<include
name="build-${environment::get-variable('COMPUTERNAME')}.include"/>) where
I defined some properties read-only for each environment. After this, I
included a files containing default values for those and other properties
in case the script was going to be use in more environments. Because I
wanted to reuse some of those default properties in my included file, I
decided to also include the same file containing those common properties
before the machine dependent include. And that's when I encountered the
problem.

The danger of the current behavior is that a script could start behaving
differently if a read-write property definition is added before a read-only
property definition. For this reason, I am planning to phase out the use of
the readonly attribute of my properties, as the purpose of the readonly
attribute can be easily defeated.

----------------------------------------------------------------------

Comment By: georgesz (georgesz)
Date: 2009-03-23 16:54

Message:
I also tested with overwrite="true" along with readonly="true" and it did
not changed an existing read-write property to read-only either.

----------------------------------------------------------------------

You can respond by visiting: 
https://sourceforge.net/tracker/?func=detail&atid=402868&aid=2697388&group_id=31650

------------------------------------------------------------------------------
Apps built with the Adobe(R) Flex(R) framework and Flex Builder(TM) are
powering Web 2.0 with engaging, cross-platform capabilities. Quickly and
easily build your RIAs with Flex Builder, the Eclipse(TM)based development
software that enables intelligent coding and step-through debugging.
Download the free 60 day trial. http://p.sf.net/sfu/www-adobe-com
_______________________________________________
nant-developers mailing list
nant-developers@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/nant-developers

Reply via email to