Skip to content

Commit 11b34bd

Browse files
committed
more
1 parent 933b9e8 commit 11b34bd

File tree

2 files changed

+72
-2
lines changed

2 files changed

+72
-2
lines changed

Facts.DiffPlex/ConsoleRunnerFacts.cs

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,11 @@ public class ConsoleRunnerFacts
1414
private readonly string _consoleRunnerPath;
1515

1616
public ConsoleRunnerFacts()
17+
{
18+
_consoleRunnerPath = FindConsoleRunnerPath();
19+
}
20+
21+
private static string FindConsoleRunnerPath()
1722
{
1823
// Find the console runner executable
1924
var baseDir = AppDomain.CurrentDomain.BaseDirectory;
@@ -48,8 +53,15 @@ public ConsoleRunnerFacts()
4853
possiblePaths.Add(simplePath);
4954
}
5055

51-
_consoleRunnerPath = possiblePaths.FirstOrDefault(File.Exists)
52-
?? throw new InvalidOperationException($"Could not find DiffPlex.ConsoleRunner.dll in any of the expected locations. Base directory: {baseDir}");
56+
var foundPath = possiblePaths.FirstOrDefault(File.Exists);
57+
58+
if (foundPath == null)
59+
{
60+
var searchedPaths = string.Join("\n", possiblePaths.Select((path, i) => $" {i + 1}. {path}"));
61+
throw new InvalidOperationException($"Could not find DiffPlex.ConsoleRunner.dll in any of the expected locations.\nBase directory: {baseDir}\nSearched paths:\n{searchedPaths}");
62+
}
63+
64+
return foundPath;
5365
}
5466

5567
[Fact]

README.md

Lines changed: 58 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -174,6 +174,64 @@ Example output:
174174
Line 4
175175
```
176176

177+
## IThreeWayDiffer Interface
178+
179+
The `IThreeWayDiffer` interface provides functionality for three-way diffing and merging, which is essential for merge operations in version control systems or when comparing three versions of text.
180+
181+
```csharp
182+
/// <summary>
183+
/// Responsible for generating three-way differences and merges between texts
184+
/// </summary>
185+
public interface IThreeWayDiffer
186+
{
187+
/// <summary>
188+
/// Creates a three-way diff by comparing base, old, and new text line by line.
189+
/// </summary>
190+
ThreeWayDiffResult CreateDiffs(string baseText, string oldText, string newText,
191+
bool ignoreWhiteSpace, bool ignoreCase, IChunker chunker);
192+
193+
/// <summary>
194+
/// Creates a three-way merge by comparing base, old, and new text line by line.
195+
/// </summary>
196+
ThreeWayMergeResult CreateMerge(string baseText, string oldText, string newText,
197+
bool ignoreWhiteSpace, bool ignoreCase, IChunker chunker);
198+
}
199+
```
200+
201+
Three-way diffing compares three versions of text:
202+
- **Base text**: The common ancestor or original version
203+
- **Old text**: One modified version (e.g., your changes)
204+
- **New text**: Another modified version (e.g., incoming changes)
205+
206+
This enables intelligent merging by identifying:
207+
- Changes unique to the old version
208+
- Changes unique to the new version
209+
- Changes made to both versions (conflicts)
210+
- Unchanged sections
211+
212+
```csharp
213+
var threeWayDiffer = new ThreeWayDiffer();
214+
215+
// Three-way diff
216+
var diffResult = threeWayDiffer.CreateDiffs(baseText, oldText, newText,
217+
ignoreWhiteSpace: false, ignoreCase: false, new LineChunker());
218+
219+
// Three-way merge with automatic conflict detection
220+
var mergeResult = threeWayDiffer.CreateMerge(baseText, oldText, newText,
221+
ignoreWhiteSpace: false, ignoreCase: false, new LineChunker());
222+
223+
// Check for conflicts
224+
if (mergeResult.HasConflicts)
225+
{
226+
Console.WriteLine($"Found {mergeResult.ConflictBlocks.Count} conflicts");
227+
}
228+
else
229+
{
230+
Console.WriteLine("Merge completed successfully");
231+
Console.WriteLine(mergeResult.MergedText);
232+
}
233+
```
234+
177235
## ISideBySideDifferBuilder Interface
178236

179237
```csharp

0 commit comments

Comments
 (0)