Forgive me if this is not the proper forum:

I found a bug when the sysinfo task was getting called twice in a script the
build was failing...

INTERNAL ERROR
System.ArgumentException: Item has already been added.  Key in dictionary:
"sys.clr.version"  Key being adde
d: "sys.clr.version"

I traced it to PropertyDictionary.cs not checking to see if a property was
already present before adding it. 

Here is my fix sorry about the lack of diff. Basically added a check to not
allow duplicates to the PropertyDictionary.

PropertyDictionary.cs:

public virtual void AddReadOnly(string name, string value) {
if (!_readOnlyProperties.Contains(name)) {
_readOnlyProperties.Add(name);
        if(!Dictionary.Contains(name)) // <---------------------
        {
                Dictionary.Add(name, value);
        }
}
}

/// <summary>
/// Adds a property to the collection.
/// </summary>
/// <param name="name">Name of property</param>
/// <param name="value">Value of property</param>
public virtual void Add(string name, string value) {
if (!_readOnlyProperties.Contains(name)) {
        if(!Dictionary.Contains(name)) // <-----------------------
        {
                Dictionary.Add(name, value);
        }
}
}

Cavet: I am not really sure if this behavior will affect other property
creation. My initial tests and unit tests indicate no.

Kevin Miller


-------------------------------------------------------
This sf.net email is sponsored by:ThinkGeek
Welcome to geek heaven.
http://thinkgeek.com/sf
_______________________________________________
Nant-developers mailing list
[EMAIL PROTECTED]
https://lists.sourceforge.net/lists/listinfo/nant-developers

Reply via email to