Support for VS2010
kmrgithub opened this issue · 6 comments
Hi wbish - Great work!
I only have VS2010 and the following lines do not compile:
result[$"{index}"] = new JArray(right[index]);
result[$"_{index}"] = new JArray(left[index], 0, (int)DiffOperation.Deleted);
result[$"{index}"] = diff;
I can successfully compile them if I change them to:
result.Add(new JProperty(index.ToString(), new JArray(right[index])));
result.Add(new JProperty("_"+index.ToString(), new JArray(left[index], 0, (int)DiffOperation.Deleted)));
result.Add(new JProperty(index.ToString(), diff));
When I run your example shown here I do not return the same patch output. Are my changes valid for VS2010?
Thanks in advance.
So, I just read about "string interpolation" in C# 6.0. I changed the offending lines with the following. But my patch json is not what is shown in your example on your project homepage.
${index} ==> index.ToString()
$"_{index}" ==> "_" + index.ToString()
Your patch json:
{
"revision": [ // Changed the value of a property
5, // Old value
6 // New value
],
"items": { // Inserted and moved items in an array
"0": [
"bike"
],
"_t": "a",
"_1": [
"",
1,
3
]
},
"tagline": [ // A long string diff using google-diff-match-patch
"@@ -2,10 +2,8 @@\n can\n-'t\n do \n@@ -23,49 +23,28 @@\n is \n+not \n too long\n- for me to handle! Please help me\n+. Thanks\n Jso\n",
0,
2
],
"author": [ // Changed the type of the author property from string to object
"wbish",
{
"first": "w",
"last": "bish"
}
]
}
My patch json:
{
"revision": [
5,
6
],
"items": {
"_t": "a",
"_1": [
"bus",
0,
0
],
"0": [
"bike"
],
"1": [
"bus"
]
},
"tagline": [
"@@ -2,10 +2,8 @@\n can\n-'t\n do \n@@ -23,16 +23,20 @@\n is \n+not \n too long\n for\n@@ -35,41 +35,16 @@\n long\n- for me to handle! Please help me\n+. Thanks\n Jso\n",
0,
2
],
"author": [
"wbish",
{
"first": "w",
"last": "bish"
}
]
}
To be honest I'm against of replacing string interpolation and other readability improvement constructs. Is there really a need to support older C# versions?
I suppose your patch is different from example because of EfficientArrayPatching turned off (it should be turned on in example, but that's not done)
-
The C# version I can work around.
-
I get the same patch json regardless of the Options set:
Option options = new Options { ArrayDiff = ArrayDiffMode.Efficient,
TextDiff = TextDiffMode.Efficient };
var jdp = new JsonDiffPatch(options);
Or
var jdp = new JsonDiffPatch()
You can close this issue. Though the patch json was different it still resulted in the same patched json. I neglected to check that fact.
Yeah, I'm not sure why you are seeing those differences. I'll ensure the output still matches the readme later tonight and update if necessary.