Handle duplicate nodes key checks in MiniYaml in a better place.

Moving the key duplication check allows a redundant check on top-level nodes to be avoided. Add tests to ensure key checks are functioning as expected.
This commit is contained in:
RoosterDragon
2023-07-07 19:35:02 +01:00
committed by Matthias Mailänder
parent 30b1f926f2
commit a96e445e4d
2 changed files with 144 additions and 9 deletions

View File

@@ -416,6 +416,9 @@ namespace OpenRA
static MiniYaml MergePartial(MiniYaml existingNodes, MiniYaml overrideNodes)
{
existingNodes?.Nodes.ToDictionaryWithConflictLog(x => x.Key, "MiniYaml.Merge", null, x => $"{x.Key} (at {x.Location})");
overrideNodes?.Nodes.ToDictionaryWithConflictLog(x => x.Key, "MiniYaml.Merge", null, x => $"{x.Key} (at {x.Location})");
if (existingNodes == null)
return overrideNodes;
@@ -435,9 +438,6 @@ namespace OpenRA
var ret = new List<MiniYamlNode>(existingNodes.Count + overrideNodes.Count);
var existingDict = existingNodes.ToDictionaryWithConflictLog(x => x.Key, "MiniYaml.Merge", null, x => $"{x.Key} (at {x.Location})");
var overrideDict = overrideNodes.ToDictionaryWithConflictLog(x => x.Key, "MiniYaml.Merge", null, x => $"{x.Key} (at {x.Location})");
foreach (var node in existingNodes.Concat(overrideNodes))
{
// Append Removal nodes to the result.