Skip to content

ThomasHambach/csharpdiff

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

21 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Quality Gate Status Coverage NuGet MIT licensed GitHub contributors

CSharpDiff

C# Diff with Unified Diff Support, this codebase is a port from the popular JS library jsdiff by kpdecker.

Todo

  • Clean-up code (Code smells and bugs according to Sonar)
  • Patch
    • Create
    • Apply
    • Merge
    • Parse
  • Diff
    • Array
    • Base Diff()
    • Character Diff()
    • CSS
    • JSON
    • Line DiffLines()
    • Sentence DiffSentence()
    • Word (Partial, issues with Regex in DiffWord.Tokenize)
  • Convert DiffConvert
    • XML DiffConvert.ToXml
    • DMP (diff-match-patch) DiffConvert.ToDmp

Usage Example

Diff

Character

using CSharpDiff.Diff;

var diff = new Diff(new DiffOptions
{
    IgnoreCase = true
});
var result = diff.diff("New Value.", "New value.");

Line

using CSharpDiff.Diff;

var text1 = "Here im.\nRock you like old man.\nYeah";
var text2 = "Here im.\nRock you like hurricane.\nYeah";

var diff = new DiffLines();
var difference = diff.diff(text1, text2);

Sentence

using CSharpDiff.Diff;

var text1 = "Here im. Rock you like old man.";
var text2 = "Here im. Rock you like hurricane.";

var diff = new DiffSentence();
var difference = diff.diff(text1, text2);

Patch

Create

using CSharpDiff.Patch;

var text1 = "...";
var text2 = "...";

var ps = new Patch();
string patch = ps.create("filename1", "filename2", text1, text2, "header1", "header2", new PatchOptions());

Works Well With

Contributing

Idk, just make a pull request.

Releases

No releases published

Packages

No packages published

Languages