wbish/jsondiffpatch.net

Unpatch throws exception

npfrizze opened this issue · 3 comments

Using the attached files, I am unable to 'Unpatch' a file. While the json is fairly complex, the changes are not that complex. Is this a bug?

exception - Index is equal to or greater than Count.
Parameter name: index

string modifiedJson = File.ReadAllText($"c:/temp/modified.json");
string defaultJson = File.ReadAllText($"c:/temp/default.json");

JsonDiffPatch jsonDiffPatch = new JsonDiffPatch();
var patch = jsonDiffPatch.Diff(modifiedJson, defaultJson);

Console.WriteLine("patch" + patch);

try
{
string patched = jsonDiffPatch.Unpatch(defaultJson, patch);
Console.WriteLine("patched" + patched);
}
catch (Exception ex)
{
Console.WriteLine("exception" + ex.Message);
}
default.txt
modified.txt

wbish commented

Yes, definitely a bug. Thanks for reporting. I can confirm I am able to repro it. I will try to get a fix published tonight to nuget.

I am also seeing an issue with these 2 files.
It doesn't throw an exception, but the unpatched file is not correct.

modified.txt
default.txt

wbish commented

@npfrizze 2.02.0 has been published to nuget with fixes for both issues.