Google diff, match and patch ported to C#
The title says it all, I’ve ported the Google diff-match-patch library to C#. It’s a nice diff library, and supports Java, JavaScript, Python, C++ (with Qt) and C# with exactly the same API.
Porting wise, everything went fine due to the high test coverage (IIRC, something around 98% of the code is covered by unit tests), so I could quickly check if everything works as expected. For unit testing on C#, I initially used MSTest, but switched to NUnit for portability. The code works fine with Mono 2.4 and .NET 3.5, possibly also with older version. If you change the LINQ extension calls like First () to indexed based access, you’ll probably get it working on .NET 2.0 as well. So, have fun with this nice library!
Thanks to Neil Frasier for adding this into the project codebase and for further maintenance.
Related posts:
Nice! I had also ported it to C# but didn’t submit it because I had some problems with unicode chars having in .NET length 6 instead of 4 (as I remember) causing one test to fail.
I check out how did you do it. Fo my Version I just changed the test
If you use Joseph Albahari Linq Bridge, you don’t need to change the code to run under .Net 2.0 http://www.albahari.com/nutshell/linqbridge.aspx
@Marc Brooks
Cool, didn’t know of that. I was wondering anyway why the extension methods from LINQ are not available separately, as they are mostly trivial implementations and it’s plain stupid to drag in the 100+ MiB of .NET 3.5 just to use .First(). Definitely worth a try.
@@dermouk
I had no problems while porting, the tests are exactly the same as for Java, the only difference is that the URLencode result is lower-case instead of upper-case.
@Marc Brooks
I’ve implemented the LinqBridge and that’s helped the Linq references but I’m still struggling with Hashset substitutes. Any suggestions?
Thanks,
Andy Robinson
@Andy Robinson
Couldn’t you use a Dictionary for that? Simply add null as the value, and just work on the keys.