This project is read-only.
3

Closed

Case Sensitive Options Problem

description

Having multiple options with equal ToUpper() conversions will cause a duplicate key to be added to the ignoreCaseLookupDictionary in InitializeArgumentLookupDictionaries. I'm not sure if it is the "correct" fix, but it seems to have worked in this case:
 
        ignoreCaseLookupDirectory.Clear();
        foreach (KeyValuePair<char, Argument> keyValuePair in shortNameLookup)
        {
            // XXX - This will mask our any additional values where ToUpper() is ==
            if (!ignoreCaseLookupDirectory.ContainsKey(keyValuePair.Key.ToString().ToUpper()))
                ignoreCaseLookupDirectory.Add(keyValuePair.Key.ToString().ToUpper(), keyValuePair.Value);
        }
Closed Feb 21, 2016 at 9:30 PM by Trupik
This issue has been addressed in v3 which you now can get from NuGet.
The project has been migrated to GitHub, please use it for tracking the project, getting information about new releases & reporting all potential issues.

comments

gwicksted wrote Dec 16, 2014 at 8:21 PM

I propose a slightly different fix:

Simply wrap the ignoreCaseLookupDictionary block with a check if IgnoreCase is true.

Fix:

ignoreCaseLookupDirectory.Clear();

if (IgnoreCase)
{
    foreach (KeyValuePair<char, Argument> keyValuePair in shortNameLookup)
    {
        ignoreCaseLookupDirectory.Add(keyValuePair.Key.ToString().ToUpper(), keyValuePair.Value);
    }
    foreach (KeyValuePair<string, Argument> keyValuePair in longNameLookup)
    {
        ignoreCaseLookupDirectory.Add(keyValuePair.Key.ToUpper(), keyValuePair.Value);
    }
}

wrote Dec 16, 2014 at 8:22 PM

wrote Feb 21, 2016 at 9:30 PM