Skip to content

Commit 7320ebd

Browse files
committed
Merge branch 'main' into tray-menu-open-without-io
2 parents 8d41eb2 + 892cb0f commit 7320ebd

10 files changed

Lines changed: 22 additions & 16 deletions

File tree

docs/diff-tool.custom.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@ New tools are added to the top of the order, the last tool added will resolve be
5353
```cs
5454
await DiffRunner.LaunchAsync(tempFile, targetFile);
5555
```
56-
<sup><a href='/src/DiffEngine.Tests/DiffRunnerTests.cs#L92-L96' title='Snippet source file'>snippet source</a> | <a href='#snippet-DiffRunnerLaunch' title='Start of snippet'>anchor</a></sup>
56+
<sup><a href='/src/DiffEngine.Tests/DiffRunnerTests.cs#L94-L98' title='Snippet source file'>snippet source</a> | <a href='#snippet-DiffRunnerLaunch' title='Start of snippet'>anchor</a></sup>
5757
<!-- endSnippet -->
5858

5959
Alternatively the instance returned from `AddTool*` can be used to explicitly launch that tool.

readme.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -103,7 +103,7 @@ A tool can be launched using the following:
103103
```cs
104104
await DiffRunner.LaunchAsync(tempFile, targetFile);
105105
```
106-
<sup><a href='/src/DiffEngine.Tests/DiffRunnerTests.cs#L92-L96' title='Snippet source file'>snippet source</a> | <a href='#snippet-DiffRunnerLaunch' title='Start of snippet'>anchor</a></sup>
106+
<sup><a href='/src/DiffEngine.Tests/DiffRunnerTests.cs#L94-L98' title='Snippet source file'>snippet source</a> | <a href='#snippet-DiffRunnerLaunch' title='Start of snippet'>anchor</a></sup>
107107
<!-- endSnippet -->
108108

109109
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.
@@ -118,7 +118,7 @@ A tool can be closed using the following:
118118
```cs
119119
DiffRunner.Kill(file1, file2);
120120
```
121-
<sup><a href='/src/DiffEngine.Tests/DiffRunnerTests.cs#L106-L110' title='Snippet source file'>snippet source</a> | <a href='#snippet-DiffRunnerKill' title='Start of snippet'>anchor</a></sup>
121+
<sup><a href='/src/DiffEngine.Tests/DiffRunnerTests.cs#L108-L112' title='Snippet source file'>snippet source</a> | <a href='#snippet-DiffRunnerKill' title='Start of snippet'>anchor</a></sup>
122122
<!-- endSnippet -->
123123

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

src/DiffEngine.Tests/DiffRunnerTests.cs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,10 +43,12 @@ public async Task MaxInstancesToLaunch()
4343
{
4444
await Task.Delay(500);
4545
ProcessCleanup.Refresh();
46+
// ReSharper disable once MethodHasAsyncOverload
4647
var result = DiffRunner.Launch(file1, "fake.txt");
4748
await Task.Delay(300);
4849
await Assert.That(result).IsEqualTo(LaunchResult.StartedNewInstance);
4950
ProcessCleanup.Refresh();
51+
// ReSharper disable once MethodHasAsyncOverload
5052
result = DiffRunner.Launch(file2, "fake.txt");
5153
await Assert.That(result).IsEqualTo(LaunchResult.TooManyRunningDiffTools);
5254
ProcessCleanup.Refresh();
@@ -119,6 +121,7 @@ public async Task LaunchAndKillDisabled()
119121
await WaitForRunning(false);
120122
await Assert.That(IsRunning()).IsFalse();
121123
await Assert.That(ProcessCleanup.IsRunning(command)).IsFalse();
124+
// ReSharper disable once MethodHasAsyncOverload
122125
var result = DiffRunner.Launch(file1, file2);
123126
await Assert.That(result).IsEqualTo(LaunchResult.Disabled);
124127
Thread.Sleep(500);
@@ -170,6 +173,7 @@ public async Task LaunchAndKill()
170173
await WaitForRunning(false);
171174
await Assert.That(IsRunning()).IsFalse();
172175
await Assert.That(ProcessCleanup.IsRunning(command)).IsFalse();
176+
// ReSharper disable once MethodHasAsyncOverload
173177
var result = DiffRunner.Launch(file1, file2);
174178
await Assert.That(result).IsEqualTo(LaunchResult.StartedNewInstance);
175179
await WaitForRunning(true);

src/DiffEngine.Tests/TrayDisabledTests.cs

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -17,14 +17,14 @@
1717
[NotInParallel]
1818
public class TrayDisabledTests
1919
{
20-
const string Variable = "DiffEngine_TrayDisabled";
20+
const string variable = "DiffEngine_TrayDisabled";
2121

2222
[Test]
2323
public async Task Read_from_the_environment_until_set()
2424
{
2525
DiffRunner.ResetTrayDisabled();
2626

27-
Environment.SetEnvironmentVariable(Variable, "true");
27+
Environment.SetEnvironmentVariable(variable, "true");
2828
await Assert.That(DiffRunner.TrayDisabled).IsTrue();
2929

3030
// Setting pins it, exactly as Disabled does, so a consumer that opts back in is not
@@ -108,7 +108,7 @@ public async Task A_disabled_tray_leaves_the_move_to_the_queue_owner()
108108
[After(Test)]
109109
public void Restore()
110110
{
111-
Environment.SetEnvironmentVariable(Variable, null);
111+
Environment.SetEnvironmentVariable(variable, null);
112112
DiffRunner.ResetTrayDisabled();
113113
}
114114

@@ -159,6 +159,7 @@ async Task Accept()
159159
// net48 too. Stop in Dispose is what breaks the accept, which lands in the
160160
// catch below.
161161
using var client = await listener.AcceptTcpClientAsync();
162+
// ReSharper disable once UseAwaitUsing
162163
using var stream = client.GetStream();
163164
using var reader = new StreamReader(stream);
164165
Payloads.Add(await reader.ReadToEndAsync());

src/DiffEngine.Tests/WindowsProcessTests.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -179,7 +179,7 @@ public async Task TryTerminateProcess_WithNonWindowedProcess_ForcefullyTerminate
179179
FileName = FakeDiffTool.Exe,
180180
UseShellExecute = false,
181181
CreateNoWindow = true
182-
});
182+
})!;
183183

184184
await Assert.That(process).IsNotNull();
185185

src/DiffEngine/Protocol/ViewerClient.cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -187,6 +187,7 @@ public static async Task<SendOutcome> SendAsync(
187187
// ReadToEndAsync takes no token at all, and net462 has no cancellable connect or
188188
// write either. Registered after the client and so disposed before it, which is what
189189
// stops the callback firing on a disposed object
190+
// ReSharper disable once UseAwaitUsing
190191
using var abort = token.Register(() => Abort(client));
191192
#if NET6_0_OR_GREATER
192193
await client.ConnectAsync(IPAddress.Loopback, endpointPort, token);

src/DiffEngineTray.Tests/MenuBuilderTest.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -225,9 +225,9 @@ public async Task A_group_named_after_a_fixed_item_is_removed_with_the_rest()
225225
Directory.CreateDirectory(directory);
226226
try
227227
{
228-
File.WriteAllText(Path.Combine(directory, "Options.sln"), "");
228+
await File.WriteAllTextAsync(Path.Combine(directory, "Options.sln"), "");
229229
var file = Path.Combine(directory, "file.txt");
230-
File.WriteAllText(file, "");
230+
await File.WriteAllTextAsync(file, "");
231231
await using var tracker = new RecordingTracker();
232232
tracker.AddDelete(file);
233233
var menu = MenuBuilder.Build(

src/DiffEngineTray.Tests/TrackerDeleteTest.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -92,7 +92,7 @@ public async Task AcceptLeavesAnUndeletableFileTracked()
9292
await using var tracker = new RecordingTracker();
9393
var tracked = tracker.AddDelete(file1);
9494

95-
using (File.Open(file1, FileMode.Open, FileAccess.Read, FileShare.None))
95+
await using (File.Open(file1, FileMode.Open, FileAccess.Read, FileShare.None))
9696
{
9797
tracker.Accept(tracked);
9898
}
@@ -112,7 +112,7 @@ public async Task AcceptAllContinuesPastAnUndeletableFile()
112112
tracker.AddDelete(file1);
113113
tracker.AddDelete(file2);
114114

115-
using (File.Open(file1, FileMode.Open, FileAccess.Read, FileShare.None))
115+
await using (File.Open(file1, FileMode.Open, FileAccess.Read, FileShare.None))
116116
{
117117
await tracker.AcceptAll();
118118
}

src/DiffEngineViewer.Tests/MoveSweepTests.cs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ public async Task A_directory_that_cannot_be_removed_does_not_fail_the_move()
2222
var received = Path.Combine(locked, "received");
2323
Directory.CreateDirectory(received);
2424
var temp = Path.Combine(received, "sample.received.txt");
25-
File.WriteAllText(temp, "the snapshot");
25+
await File.WriteAllTextAsync(temp, "the snapshot");
2626
var target = Path.Combine(root, "target");
2727
Directory.CreateDirectory(target);
2828
var verified = Path.Combine(target, "sample.verified.txt");
@@ -41,7 +41,7 @@ public async Task An_emptied_directory_is_removed()
4141
var received = Path.Combine(root, "received");
4242
Directory.CreateDirectory(received);
4343
var temp = Path.Combine(received, "sample.received.txt");
44-
File.WriteAllText(temp, "the snapshot");
44+
await File.WriteAllTextAsync(temp, "the snapshot");
4545
var target = Path.Combine(root, "sample.verified.txt");
4646

4747
ViewerActions.Real.MoveFile(temp, target);
@@ -59,8 +59,8 @@ public async Task A_directory_with_anything_left_in_it_stays()
5959
var received = Path.Combine(root, "received");
6060
Directory.CreateDirectory(received);
6161
var temp = Path.Combine(received, "sample.received.txt");
62-
File.WriteAllText(temp, "the snapshot");
63-
File.WriteAllText(Path.Combine(received, "other.received.txt"), "another");
62+
await File.WriteAllTextAsync(temp, "the snapshot");
63+
await File.WriteAllTextAsync(Path.Combine(received, "other.received.txt"), "another");
6464
var target = Path.Combine(root, "sample.verified.txt");
6565

6666
ViewerActions.Real.MoveFile(temp, target);

src/DiffEngineViewer.Tests/RevealFileTests.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ public class RevealFileTests :
1010
public async Task A_file_that_is_there_is_selected()
1111
{
1212
var file = Path.Combine(directory, "sample.verified.txt");
13-
File.WriteAllText(file, "");
13+
await File.WriteAllTextAsync(file, "");
1414

1515
var resolved = RevealFile.Resolve(file);
1616

0 commit comments

Comments
 (0)