Skip to content

Commit 3e49a0a

Browse files
authored
Diff util (#57)
1 parent 99b68ce commit 3e49a0a

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

51 files changed

+612
-76
lines changed

Diff for: docs/diff-tool.custom.md

+6-6
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ var resolvedTool = DiffTools.AddTool(
2323
exePath: diffToolPath,
2424
binaryExtensions: new[] {"jpg"})!;
2525
```
26-
<sup><a href='/src/Tests/DiffToolsTest.cs#L23-L34' title='File snippet `addtool` was extracted from'>snippet source</a> | <a href='#snippet-addtool' title='Navigate to start of snippet `addtool`'>anchor</a></sup>
26+
<sup><a href='/src/DiffEngine.Tests/DiffToolsTest.cs#L24-L35' title='File snippet `addtool` was extracted from'>snippet source</a> | <a href='#snippet-addtool' title='Navigate to start of snippet `addtool`'>anchor</a></sup>
2727
<!-- endSnippet -->
2828

2929
Add a tool based on existing resolved tool:
@@ -36,7 +36,7 @@ var resolvedTool = DiffTools.AddToolBasedOn(
3636
name: "MyCustomDiffTool",
3737
arguments: (temp, target) => $"\"custom args {temp}\" \"{target}\"");
3838
```
39-
<sup><a href='/src/Tests/DiffToolsTest.cs#L64-L69' title='File snippet `addtoolbasedon` was extracted from'>snippet source</a> | <a href='#snippet-addtoolbasedon' title='Navigate to start of snippet `addtoolbasedon`'>anchor</a></sup>
39+
<sup><a href='/src/DiffEngine.Tests/DiffToolsTest.cs#L65-L70' title='File snippet `addtoolbasedon` was extracted from'>snippet source</a> | <a href='#snippet-addtoolbasedon' title='Navigate to start of snippet `addtoolbasedon`'>anchor</a></sup>
4040
<!-- endSnippet -->
4141

4242

@@ -47,9 +47,9 @@ New tools are added to the top of the order, the last tool added will resolve be
4747
<!-- snippet: DiffRunnerLaunch -->
4848
<a id='snippet-diffrunnerlaunch'></a>
4949
```cs
50-
DiffRunner.Launch(tempFile, targetFile);
50+
await DiffRunner.Launch(tempFile, targetFile);
5151
```
52-
<sup><a href='/src/Tests/DiffRunnerTests.cs#L46-L50' title='File snippet `diffrunnerlaunch` was extracted from'>snippet source</a> | <a href='#snippet-diffrunnerlaunch' title='Navigate to start of snippet `diffrunnerlaunch`'>anchor</a></sup>
52+
<sup><a href='/src/DiffEngine.Tests/DiffRunnerTests.cs#L46-L50' title='File snippet `diffrunnerlaunch` was extracted from'>snippet source</a> | <a href='#snippet-diffrunnerlaunch' title='Navigate to start of snippet `diffrunnerlaunch`'>anchor</a></sup>
5353
<!-- endSnippet -->
5454

5555
Alternatively the instance returned from `AddTool*` can be used to explicitly launch that tool.
@@ -62,9 +62,9 @@ var resolvedTool = DiffTools.AddToolBasedOn(
6262
name: "MyCustomDiffTool",
6363
arguments: (temp, target) => $"\"custom args {temp}\" \"{target}\"");
6464

65-
DiffRunner.Launch(resolvedTool!, "PathToTempFile", "PathToTargetFile");
65+
await DiffRunner.Launch(resolvedTool!, "PathToTempFile", "PathToTargetFile");
6666
```
67-
<sup><a href='/src/Tests/DiffToolsTest.cs#L78-L85' title='File snippet `addtoolandlaunch` was extracted from'>snippet source</a> | <a href='#snippet-addtoolandlaunch' title='Navigate to start of snippet `addtoolandlaunch`'>anchor</a></sup>
67+
<sup><a href='/src/DiffEngine.Tests/DiffToolsTest.cs#L79-L86' title='File snippet `addtoolandlaunch` was extracted from'>snippet source</a> | <a href='#snippet-addtoolandlaunch' title='Navigate to start of snippet `addtoolandlaunch`'>anchor</a></sup>
6868
<!-- endSnippet -->
6969

7070

Diff for: docs/diff-tool.md

+2-2
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,7 @@ Setting the `DiffEngine.MaxInstances` environment variable to the number of inst
6161
```cs
6262
DiffRunner.MaxInstancesToLaunch(10);
6363
```
64-
<sup><a href='/src/Tests/DiffToolsTest.cs#L12-L16' title='File snippet `maxinstancestolaunch` was extracted from'>snippet source</a> | <a href='#snippet-maxinstancestolaunch' title='Navigate to start of snippet `maxinstancestolaunch`'>anchor</a></sup>
64+
<sup><a href='/src/DiffEngine.Tests/DiffToolsTest.cs#L13-L17' title='File snippet `maxinstancestolaunch` was extracted from'>snippet source</a> | <a href='#snippet-maxinstancestolaunch' title='Navigate to start of snippet `maxinstancestolaunch`'>anchor</a></sup>
6565
<!-- endSnippet -->
6666

6767

@@ -98,7 +98,7 @@ ReSharper | Options | Tools | Unit Testing | Test Runner
9898

9999
## Supported Tools:
100100

101-
<!-- include: diffTools. path: /src/Tests/diffTools.include.md -->
101+
<!-- include: diffTools. path: /src/DiffEngine.Tests/diffTools.include.md -->
102102
## [AraxisMerge](https://www.araxis.com/merge)
103103

104104
* Is MDI: True

Diff for: docs/diff-tool.order.md

+2-2
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ To change this file edit the source file and then run MarkdownSnippets.
1010

1111
## Default
1212

13-
* [BeyondCompare](/docs/diff-tool.md#beyondcompare) <!-- include: defaultOrder. path: /src/Tests/defaultOrder.include.md -->
13+
* [BeyondCompare](/docs/diff-tool.md#beyondcompare) <!-- include: defaultOrder. path: /src/DiffEngine.Tests/defaultOrder.include.md -->
1414
* [P4Merge](/docs/diff-tool.md#p4merge)
1515
* [AraxisMerge](/docs/diff-tool.md#araxismerge)
1616
* [Meld](/docs/diff-tool.md#meld)
@@ -52,5 +52,5 @@ For example `VisualStudio,Meld` will result in VisualStudio then Meld then all o
5252
```cs
5353
DiffTools.UseOrder(DiffTool.VisualStudio, DiffTool.AraxisMerge);
5454
```
55-
<sup><a href='/src/Tests/DiffToolsTest.cs#L115-L117' title='File snippet `useorder` was extracted from'>snippet source</a> | <a href='#snippet-useorder' title='Navigate to start of snippet `useorder`'>anchor</a></sup>
55+
<sup><a href='/src/DiffEngine.Tests/DiffToolsTest.cs#L116-L118' title='File snippet `useorder` was extracted from'>snippet source</a> | <a href='#snippet-useorder' title='Navigate to start of snippet `useorder`'>anchor</a></sup>
5656
<!-- endSnippet -->

Diff for: readme.md

+4-4
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ Part of the <a href='https://dotnetfoundation.org' alt=''>.NET Foundation</a>
4646

4747
## [Supported Tools](/docs/diff-tool.md#supported-tools)
4848

49-
* [AraxisMerge](/docs/diff-tool.md#araxismerge) <!-- include: diffToolList. path: /src/Tests/diffToolList.include.md -->
49+
* [AraxisMerge](/docs/diff-tool.md#araxismerge) <!-- include: diffToolList. path: /src/DiffEngine.Tests/diffToolList.include.md -->
5050
* [BeyondCompare](/docs/diff-tool.md#beyondcompare)
5151
* [CodeCompare](/docs/diff-tool.md#codecompare)
5252
* [DeltaWalker](/docs/diff-tool.md#deltawalker)
@@ -78,9 +78,9 @@ A tool can be launched using the following:
7878
<!-- snippet: DiffRunnerLaunch -->
7979
<a id='snippet-diffrunnerlaunch'></a>
8080
```cs
81-
DiffRunner.Launch(tempFile, targetFile);
81+
await DiffRunner.Launch(tempFile, targetFile);
8282
```
83-
<sup><a href='/src/Tests/DiffRunnerTests.cs#L46-L50' title='File snippet `diffrunnerlaunch` was extracted from'>snippet source</a> | <a href='#snippet-diffrunnerlaunch' title='Navigate to start of snippet `diffrunnerlaunch`'>anchor</a></sup>
83+
<sup><a href='/src/DiffEngine.Tests/DiffRunnerTests.cs#L46-L50' title='File snippet `diffrunnerlaunch` was extracted from'>snippet source</a> | <a href='#snippet-diffrunnerlaunch' title='Navigate to start of snippet `diffrunnerlaunch`'>anchor</a></sup>
8484
<!-- endSnippet -->
8585

8686
Note that this method will respect the above [difference behavior](/docs/diff-tool.md#detected-difference-behavior) in terms of Auto refresh and MDI behaviors.
@@ -95,7 +95,7 @@ A tool can be closed using the following:
9595
```cs
9696
DiffRunner.Kill(file1, file2);
9797
```
98-
<sup><a href='/src/Tests/DiffRunnerTests.cs#L58-L60' title='File snippet `diffrunnerkill` was extracted from'>snippet source</a> | <a href='#snippet-diffrunnerkill' title='Navigate to start of snippet `diffrunnerkill`'>anchor</a></sup>
98+
<sup><a href='/src/DiffEngine.Tests/DiffRunnerTests.cs#L58-L60' title='File snippet `diffrunnerkill` was extracted from'>snippet source</a> | <a href='#snippet-diffrunnerkill' title='Navigate to start of snippet `diffrunnerkill`'>anchor</a></sup>
9999
<!-- endSnippet -->
100100

101101
Note that this method will respect the above [difference behavior](/docs/diff-tool.md#detected-difference-behavior) in terms of MDI behavior.
File renamed without changes.
File renamed without changes.
File renamed without changes.

Diff for: src/DiffEngine.Tests/DiffEngineTrayTest.cs

+18
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
using DiffEngine;
2+
using Xunit;
3+
using Xunit.Abstractions;
4+
5+
public class DiffEngineTrayTest :
6+
XunitContextBase
7+
{
8+
[Fact]
9+
public void IsRunning()
10+
{
11+
Assert.False(DiffEngineTray.IsRunning);
12+
}
13+
14+
public DiffEngineTrayTest(ITestOutputHelper output) :
15+
base(output)
16+
{
17+
}
18+
}
File renamed without changes.
File renamed without changes.

Diff for: src/Tests/DiffRunnerTests.cs renamed to src/DiffEngine.Tests/DiffRunnerTests.cs

+10-10
Original file line numberDiff line numberDiff line change
@@ -22,11 +22,11 @@ public async Task MaxInstancesToLaunch()
2222
{
2323
await Task.Delay(500);
2424
ProcessCleanup.Refresh();
25-
var result = DiffRunner.Launch(file1, "fake.txt");
25+
var result = await DiffRunner.Launch(file1, "fake.txt");
2626
await Task.Delay(300);
2727
Assert.Equal(LaunchResult.StartedNewInstance, result);
2828
ProcessCleanup.Refresh();
29-
result = DiffRunner.Launch(file2, "fake.txt");
29+
result = await DiffRunner.Launch(file2, "fake.txt");
3030
Assert.Equal(LaunchResult.TooManyRunningDiffTools, result);
3131
ProcessCleanup.Refresh();
3232
DiffRunner.Kill(file1, "fake.txt");
@@ -38,37 +38,37 @@ public async Task MaxInstancesToLaunch()
3838
}
3939
}
4040

41-
void Launch()
41+
async Task Launch()
4242
{
4343
string targetFile = "";
4444
string tempFile = "";
4545

4646
#region DiffRunnerLaunch
4747

48-
DiffRunner.Launch(tempFile, targetFile);
48+
await DiffRunner.Launch(tempFile, targetFile);
4949

5050
#endregion
5151
}
5252

5353
[Fact(Skip = "Explicit")]
54-
public void Kill()
54+
public async Task Kill()
5555
{
56-
DiffRunner.Launch(file1, file2);
56+
await DiffRunner.Launch(file1, file2);
5757
ProcessCleanup.Refresh();
5858
#region DiffRunnerKill
5959
DiffRunner.Kill(file1, file2);
6060
#endregion
6161
}
6262

6363
[Fact]
64-
public void LaunchAndKillDisabled()
64+
public async Task LaunchAndKillDisabled()
6565
{
6666
DiffRunner.Disabled = true;
6767
try
6868
{
6969
Assert.False(IsRunning());
7070
Assert.False(ProcessCleanup.IsRunning(command));
71-
var result = DiffRunner.Launch(file1, file2);
71+
var result = await DiffRunner.Launch(file1, file2);
7272
Assert.Equal(LaunchResult.Disabled, result);
7373
Thread.Sleep(500);
7474
ProcessCleanup.Refresh();
@@ -87,11 +87,11 @@ public void LaunchAndKillDisabled()
8787
}
8888

8989
[Fact]
90-
public void LaunchAndKill()
90+
public async Task LaunchAndKill()
9191
{
9292
Assert.False(IsRunning());
9393
Assert.False(ProcessCleanup.IsRunning(command));
94-
var result = DiffRunner.Launch(file1, file2);
94+
var result = await DiffRunner.Launch(file1, file2);
9595
Assert.Equal(LaunchResult.StartedNewInstance, result);
9696
Thread.Sleep(500);
9797
ProcessCleanup.Refresh();

Diff for: src/Tests/DiffToolsTest.cs renamed to src/DiffEngine.Tests/DiffToolsTest.cs

+7-6
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
using System.Linq;
2+
using System.Threading.Tasks;
23
using DiffEngine;
34
using Xunit;
45
using Xunit.Abstractions;
@@ -73,35 +74,35 @@ public void AddToolBasedOn()
7374
Assert.Equal("\"custom args foo\" \"bar\"", resolvedTool!.Arguments("foo", "bar"));
7475
}
7576
#endif
76-
void AddToolAndLaunch()
77+
async Task AddToolAndLaunch()
7778
{
7879
#region AddToolAndLaunch
7980
var resolvedTool = DiffTools.AddToolBasedOn(
8081
DiffTool.VisualStudio,
8182
name: "MyCustomDiffTool",
8283
arguments: (temp, target) => $"\"custom args {temp}\" \"{target}\"");
8384

84-
DiffRunner.Launch(resolvedTool!, "PathToTempFile", "PathToTargetFile");
85+
await DiffRunner.Launch(resolvedTool!, "PathToTempFile", "PathToTargetFile");
8586
#endregion
8687
}
8788

8889
//[Fact]
89-
//public void LaunchImageDiff()
90+
//public Task LaunchImageDiff()
9091
//{
9192
// foreach (var tool in DiffTools.Resolved)
9293
// {
93-
// DiffRunner.Launch(tool,
94+
// await DiffRunner.Launch(tool,
9495
// Path.Combine(SourceDirectory, "input.file1.png"),
9596
// Path.Combine(SourceDirectory, "input.file2.png"));
9697
// }
9798
//}
9899

99100
//[Fact]
100-
//public void LaunchTextDiff()
101+
//public Task LaunchTextDiff()
101102
//{
102103
// foreach (var tool in DiffTools.Resolved)
103104
// {
104-
// DiffRunner.Launch(tool,
105+
// await DiffRunner.Launch(tool,
105106
// Path.Combine(SourceDirectory, "input.file1.txt"),
106107
// Path.Combine(SourceDirectory, "input.file2.txt"));
107108
// }
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.

Diff for: src/DiffEngine.sln

+17-8
Original file line numberDiff line numberDiff line change
@@ -16,10 +16,11 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "FakeDiffTool", "FakeDiffToo
1616
EndProject
1717
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "DiffEngine", "DiffEngine\DiffEngine.csproj", "{F494B6C2-29B4-4D73-8533-AF197D882970}"
1818
EndProject
19-
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Tests", "Tests\Tests.csproj", "{58DF5836-41EC-450B-9AAA-AFA4B79169EA}"
20-
ProjectSection(ProjectDependencies) = postProject
21-
{2B054DB2-42A0-4F3E-87CC-30D6E926D0D9} = {2B054DB2-42A0-4F3E-87CC-30D6E926D0D9}
22-
EndProjectSection
19+
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "DiffEngineTray", "DiffEngineTray\DiffEngineTray.csproj", "{E3C93E88-603E-4AA3-8AAF-0B5F7497012C}"
20+
EndProject
21+
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "DiffEngine.Tests", "DiffEngine.Tests\DiffEngine.Tests.csproj", "{A7B838DE-86BF-4C57-8563-7295D583C93A}"
22+
EndProject
23+
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "DiffEngineTray.Tests", "DiffEngineTray.Tests\DiffEngineTray.Tests.csproj", "{E339AB28-21B2-47DB-B995-EB2C4CE8BA99}"
2324
EndProject
2425
Global
2526
GlobalSection(SolutionConfigurationPlatforms) = preSolution
@@ -35,10 +36,18 @@ Global
3536
{F494B6C2-29B4-4D73-8533-AF197D882970}.Debug|Any CPU.Build.0 = Debug|Any CPU
3637
{F494B6C2-29B4-4D73-8533-AF197D882970}.Release|Any CPU.ActiveCfg = Release|Any CPU
3738
{F494B6C2-29B4-4D73-8533-AF197D882970}.Release|Any CPU.Build.0 = Release|Any CPU
38-
{58DF5836-41EC-450B-9AAA-AFA4B79169EA}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
39-
{58DF5836-41EC-450B-9AAA-AFA4B79169EA}.Debug|Any CPU.Build.0 = Debug|Any CPU
40-
{58DF5836-41EC-450B-9AAA-AFA4B79169EA}.Release|Any CPU.ActiveCfg = Release|Any CPU
41-
{58DF5836-41EC-450B-9AAA-AFA4B79169EA}.Release|Any CPU.Build.0 = Release|Any CPU
39+
{E3C93E88-603E-4AA3-8AAF-0B5F7497012C}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
40+
{E3C93E88-603E-4AA3-8AAF-0B5F7497012C}.Debug|Any CPU.Build.0 = Debug|Any CPU
41+
{E3C93E88-603E-4AA3-8AAF-0B5F7497012C}.Release|Any CPU.ActiveCfg = Release|Any CPU
42+
{E3C93E88-603E-4AA3-8AAF-0B5F7497012C}.Release|Any CPU.Build.0 = Release|Any CPU
43+
{A7B838DE-86BF-4C57-8563-7295D583C93A}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
44+
{A7B838DE-86BF-4C57-8563-7295D583C93A}.Debug|Any CPU.Build.0 = Debug|Any CPU
45+
{A7B838DE-86BF-4C57-8563-7295D583C93A}.Release|Any CPU.ActiveCfg = Release|Any CPU
46+
{A7B838DE-86BF-4C57-8563-7295D583C93A}.Release|Any CPU.Build.0 = Release|Any CPU
47+
{E339AB28-21B2-47DB-B995-EB2C4CE8BA99}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
48+
{E339AB28-21B2-47DB-B995-EB2C4CE8BA99}.Debug|Any CPU.Build.0 = Debug|Any CPU
49+
{E339AB28-21B2-47DB-B995-EB2C4CE8BA99}.Release|Any CPU.ActiveCfg = Release|Any CPU
50+
{E339AB28-21B2-47DB-B995-EB2C4CE8BA99}.Release|Any CPU.Build.0 = Release|Any CPU
4251
EndGlobalSection
4352
GlobalSection(SolutionProperties) = preSolution
4453
HideSolutionNode = FALSE

0 commit comments

Comments
 (0)