Home > Programming > Google diff, match and patch ported to C#

Google diff, match and patch ported to C#

June 22nd, 2009

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:

  1. Unit testing introduction
  2. Boost 1.38 incoming
  3. niven ported to x64
  4. Bazaar for version control
  5. nivenCore on x64

Anteru Programming

  1. @dermouk
    June 23rd, 2009 at 16:18 | #1

    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 ;-)

  2. June 24th, 2009 at 06:21 | #2

    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

  3. June 24th, 2009 at 07:07 | #3

    @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.

  4. June 24th, 2009 at 07:07 | #4

    @@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.

  5. Andy Robinson
    July 13th, 2009 at 02:27 | #5

    @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

  6. July 17th, 2009 at 09:14 | #6

    @Andy Robinson
    Couldn’t you use a Dictionary for that? Simply add null as the value, and just work on the keys.

  1. No trackbacks yet.