Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 0 additions & 4 deletions .nuke/build.schema.json
Original file line number Diff line number Diff line change
Expand Up @@ -86,10 +86,6 @@
]
}
},
"Solution": {
"type": "string",
"description": "Path to a solution file that is automatically loaded"
},
"Target": {
"type": "array",
"description": "List of targets to be invoked. Default is '{default_target}'",
Expand Down
28 changes: 26 additions & 2 deletions source/Nevermore/CommandParameterValues.cs
Original file line number Diff line number Diff line change
Expand Up @@ -227,10 +227,34 @@ public void AddRange(CommandParameterValues other)
{
foreach (var item in other)
{
if (ContainsKey(item.Key))
throw new Exception($"The parameter {item.Key} already exists");
CheckForDuplicate(item);
this[item.Key] = item.Value;
}
}

void CheckForDuplicate(KeyValuePair<string, object> item)
{
if (!ContainsKey(item.Key))
{
return;
}
var existingValue = this[item.Key];
var newValue = item.Value;
if (existingValue.Equals(newValue))
{
return;
}
if (existingValue is IEnumerable existingValueEnumerable && newValue is IEnumerable newValueEnumerable)
{
var existingValueSet = existingValueEnumerable.Cast<object>().ToHashSet();
var newValueSet = newValueEnumerable.Cast<object>().ToHashSet();
if (existingValueSet.SetEquals(newValueSet))
{
return;
}
}

throw new Exception($"The parameter {item.Key} already exists and has a different value");
}
}
}