Skip to content

Commit

Permalink
fix: fixed merge logic like js {...obj} such it do not override value…
Browse files Browse the repository at this point in the history
…s defined after.
  • Loading branch information
pksorensen committed Aug 21, 2024
1 parent f61ede0 commit 332b3d8
Showing 1 changed file with 7 additions and 2 deletions.
9 changes: 7 additions & 2 deletions sdk/DefaultManifestReplacementRunner.cs
Original file line number Diff line number Diff line change
Expand Up @@ -187,6 +187,8 @@ public async Task RunReplacements(JToken jsonraw, string customizationprefix, IL
{
var parentObj = prop.Parent as JObject;
var obj = prop.Value;
var mergeIndex = Array.IndexOf(parentObj.Properties().ToArray(), prop);
var parentObjKeys = parentObj.Properties().Select(k => k.Name).ToArray();

if (obj.Type == JTokenType.String && ShouldEvaluate(obj.ToString()))
{
Expand All @@ -211,9 +213,12 @@ public async Task RunReplacements(JToken jsonraw, string customizationprefix, IL
}
else
{

parentObj.Add(childProp);

if (!parentObj.ContainsKey(childProp.Name) || Array.IndexOf(parentObjKeys,childProp.Name) < mergeIndex)
{
parentObj[childProp.Name] = childProp.Value;
q.Enqueue(childProp);
}

}

Expand Down

0 comments on commit 332b3d8

Please sign in to comment.