// Before
var differ = new Differ();
var sideBySideBuilder = new SideBySideBuilder(differ);
var result = sideBySideBuilder.BuildDiffModel(oldText, newText);
// Now (in PR)
var result = SideBySideBuilder.Diff(oldText, newText);
And of course, this pull request keeps the old style to allow advanced customization and usages.
Breaking changes
Call the constructors SideBySideDiffBuilder(IDiffer differ) and InlineDiffBuilder(IDiffer differ) with an argument null is no longer throw an exception but use a default Differ instance to fill automatically instead.
var diffBuilder = new SideBySideDiffBuilder(null);
// Before: It throws an exception.
// throw new ArgumentNullException("differ");
// Now (in PR): It is equivalent to following.
// var diffBuilder = new SideBySideDiffBuilder(Differ.Instance);
Helper functions
SideBySideDiffBuilder.Diff
InlineDiffBuilder.Diff
Singletons
Differ.Instance
WordChunker.Instance
LineEndingsPreservingChunker.Instance
LineChunker.Instance
CharacterChunker.Instance
WPF controls
A benefit of the helper functions and singletons is that I add a new WPF control DiffViewer which we can set the old text and new text directly instead of an instance of SideBySideDiffModel or DiffPaneModel.
<diffplex:DiffViewer />
The helper functions and the singletons will also decrease the memory cost for the scenario user create more instances of Differ class, diff builders and chunks.
Add some helper functions and singletons to make the usage of APIs more friendly. It is very useful for most of scenario.
Sample
Following is a sample of Before vs Now (in PR).
And of course, this pull request keeps the old style to allow advanced customization and usages.
Breaking changes
Call the constructors
SideBySideDiffBuilder(IDiffer differ)
andInlineDiffBuilder(IDiffer differ)
with an argumentnull
is no longer throw an exception but use a defaultDiffer
instance to fill automatically instead.Helper functions
SideBySideDiffBuilder.Diff
InlineDiffBuilder.Diff
Singletons
Differ.Instance
WordChunker.Instance
LineEndingsPreservingChunker.Instance
LineChunker.Instance
CharacterChunker.Instance
WPF controls
A benefit of the helper functions and singletons is that I add a new WPF control
DiffViewer
which we can set the old text and new text directly instead of an instance ofSideBySideDiffModel
orDiffPaneModel
.The helper functions and the singletons will also decrease the memory cost for the scenario user create more instances of
Differ
class, diff builders and chunks.