Closed kingcean closed 4 years ago
In fact this pull request only contains the last 4 commits of the above list.
@kingcean Are any of these changes "breaking" changes?
The only breaking change (maybe you don't think it is a breaking change) is that the following result is different.
var diffBuilder = new SideBySideDiffBuilder(null);
The new (in PR) implementation is equivalent to following.
var diffBuilder = new SideBySideDiffBuilder(Differ.Instance); // Differ.Instance = new Differ();
The old (current) implementation throws an exception.
throw new ArgumentNullException("differ");
And so does InlineDiffBuilder
.
@kingcean Can you re-merge and push since there are conflicts it seems
OK.
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 previous (current) vs new (in PR).
And of course, this pull request keeps the old style to allow advanced customization and usages.
Breaking changes
The
IDiffer
argument of constructors ofSideBySideDiffBuilder
andInlineDiffBuilder
can be null now. A defaultDiffer
instance will be used when it is null.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.