diff --git a/docs/diff-tool.custom.md b/docs/diff-tool.custom.md
index ba26061c..a889b7da 100644
--- a/docs/diff-tool.custom.md
+++ b/docs/diff-tool.custom.md
@@ -22,12 +22,9 @@ var resolvedTool = DiffTools.AddTool(
Left: (tempFile, targetFile) => $"\"{targetFile}\" \"{tempFile}\"",
Right: (tempFile, targetFile) => $"\"{tempFile}\" \"{targetFile}\""),
exePath: diffToolPath,
- binaryExtensions: new[]
- {
- "jpg"
- })!;
+ binaryExtensions: [".jpg"])!;
```
-snippet source | anchor
+snippet source | anchor
Add a tool based on existing resolved tool:
@@ -42,7 +39,7 @@ var resolvedTool = DiffTools.AddToolBasedOn(
Left: (temp, target) => $"\"custom args \"{target}\" \"{temp}\"",
Right: (temp, target) => $"\"custom args \"{temp}\" \"{target}\""))!;
```
-snippet source | anchor
+snippet source | anchor
@@ -72,7 +69,7 @@ var resolvedTool = DiffTools.AddToolBasedOn(
await DiffRunner.LaunchAsync(resolvedTool!, "PathToTempFile", "PathToTargetFile");
```
-snippet source | anchor
+snippet source | anchor
diff --git a/docs/diff-tool.md b/docs/diff-tool.md
index 457abb2a..d2a8e5fa 100644
--- a/docs/diff-tool.md
+++ b/docs/diff-tool.md
@@ -124,7 +124,7 @@ Non-MDI tools are preferred since it allows [DiffEngineTray](tray.md) to track a
* Supports auto-refresh: True
* Supports text files: True
* Environment variable for custom install location: `DiffEngine_BeyondCompare`
- * Supported binaries: pdf, bmp, gif, ico, jpg, jpeg, png, tif, tiff, rtf
+ * Supported binaries: .pdf, .bmp, .gif, .ico, .jpg, .jpeg, .png, .tif, .tiff, .rtf
#### Notes:
@@ -164,7 +164,7 @@ Non-MDI tools are preferred since it allows [DiffEngineTray](tray.md) to track a
* Supports auto-refresh: True
* Supports text files: True
* Environment variable for custom install location: `DiffEngine_DeltaWalker`
- * Supported binaries: jpg, jp2, j2k, png, gif, psd, tif, bmp, pct, pict, pic, ico, ppm, pgm, pbm, pnm, zip, jar, ear, tar, tgz, tbz2, gz, bz2, doc, docx, xls, xlsx, ppt, pdf, rtf, html, htm
+ * Supported binaries: .jpg, .jp2, .j2k, .png, .gif, .psd, .tif, .bmp, .pct, .pict, .pic, .ico, .ppm, .pgm, .pbm, .pnm, .zip, .jar, .ear, .tar, .tgz, .tbz2, .gz, .bz2, .doc, .docx, .xls, .xlsx, .ppt, .pdf, .rtf, .html, .htm
#### Notes:
@@ -242,7 +242,7 @@ Non-MDI tools are preferred since it allows [DiffEngineTray](tray.md) to track a
* Supports auto-refresh: False
* Supports text files: True
* Environment variable for custom install location: `DiffEngine_Guiffy`
- * Supported binaries: bmp, gif, jpeg, jpg, png, wbmp
+ * Supported binaries: .bmp, .gif, .jpeg, .jpg, .png, .wbmp
#### Notes:
@@ -276,7 +276,7 @@ Non-MDI tools are preferred since it allows [DiffEngineTray](tray.md) to track a
* Supports auto-refresh: True
* Supports text files: True
* Environment variable for custom install location: `DiffEngine_Kaleidoscope`
- * Supported binaries: bmp, gif, ico, jpg, jpeg, png, tiff, tif
+ * Supported binaries: .bmp, .gif, .ico, .jpg, .jpeg, .png, .tiff, .tif
#### OSX settings:
@@ -355,7 +355,7 @@ Non-MDI tools are preferred since it allows [DiffEngineTray](tray.md) to track a
* Supports auto-refresh: False
* Supports text files: True
* Environment variable for custom install location: `DiffEngine_P4Merge`
- * Supported binaries: bmp, gif, jpg, jpeg, png, pbm, pgm, ppm, tif, tiff, xbm, xpm
+ * Supported binaries: .bmp, .gif, .jpg, .jpeg, .png, .pbm, .pgm, .ppm, .tif, .tiff, .xbm, .xpm
#### Windows settings:
@@ -450,7 +450,7 @@ Non-MDI tools are preferred since it allows [DiffEngineTray](tray.md) to track a
* Supports auto-refresh: False
* Supports text files: False
* Environment variable for custom install location: `DiffEngine_TortoiseGitIDiff`
- * Supported binaries: bmp, gif, ico, jpg, jpeg, png, tif, tiff
+ * Supported binaries: .bmp, .gif, .ico, .jpg, .jpeg, .png, .tif, .tiff
#### Windows settings:
@@ -487,7 +487,7 @@ Non-MDI tools are preferred since it allows [DiffEngineTray](tray.md) to track a
* Supports auto-refresh: False
* Supports text files: False
* Environment variable for custom install location: `DiffEngine_TortoiseIDiff`
- * Supported binaries: bmp, gif, ico, jpg, jpeg, png, tif, tiff
+ * Supported binaries: .bmp, .gif, .ico, .jpg, .jpeg, .png, .tif, .tiff
#### Windows settings:
@@ -558,7 +558,7 @@ Non-MDI tools are preferred since it allows [DiffEngineTray](tray.md) to track a
* Supports auto-refresh: True
* Supports text files: True
* Environment variable for custom install location: `DiffEngine_WinMerge`
- * Supported binaries: bmp, cut, dds, exr, g3, gif, hdr, ico, iff, lbm, j2k, j2c, jng, jp2, jpg, jif, jpeg, jpe, jxr, wdp, hdp, koa, mng, pcd, pcx, pfm, pct, pict, pic, png, pbm, pgm, ppm, psd, ras, sgi, rgb, rgba, bw, tga, targa, tif, tiff, wap, wbmp, wbm, webp, xbm, xpm
+ * Supported binaries: .bmp, .cut, .dds, .exr, .g3, .gif, .hdr, .ico, .iff, .lbm, .j2k, .j2c, .jng, .jp2, .jpg, .jif, .jpeg, .jpe, .jxr, .wdp, .hdp, .koa, .mng, .pcd, .pcx, .pfm, .pct, .pict, .pic, .png, .pbm, .pgm, .ppm, .psd, .ras, .sgi, .rgb, .rgba, .bw, .tga, .targa, .tif, .tiff, .wap, .wbmp, .wbm, .webp, .xbm, .xpm
#### Notes:
@@ -590,7 +590,7 @@ Non-MDI tools are preferred since it allows [DiffEngineTray](tray.md) to track a
* Supports auto-refresh: True
* Supports text files: True
* Environment variable for custom install location: `DiffEngine_AraxisMerge`
- * Supported binaries: bmp, dib, emf, gif, jif, j2c, j2k, jp2, jpc, jpeg, jpg, jpx, pbm, pcx, pgm, png, ppm, ras, tif, tiff, tga, wmf
+ * Supported binaries: .bmp, .dib, .emf, .gif, .jif, .j2c, .j2k, .jp2, .jpc, .jpeg, .jpg, .jpx, .pbm, .pcx, .pgm, .png, .ppm, .ras, .tif, .tiff, .tga, .wmf
#### Notes:
diff --git a/docs/diff-tool.order.md b/docs/diff-tool.order.md
index ecc84ce1..8df920fb 100644
--- a/docs/diff-tool.order.md
+++ b/docs/diff-tool.order.md
@@ -51,5 +51,5 @@ For example `VisualStudio,Meld` will result in VisualStudio then Meld then all o
```cs
DiffTools.UseOrder(DiffTool.VisualStudio, DiffTool.AraxisMerge);
```
-snippet source | anchor
+snippet source | anchor
diff --git a/src/.editorconfig b/src/.editorconfig
index c9db1cb9..99a756c1 100644
--- a/src/.editorconfig
+++ b/src/.editorconfig
@@ -134,7 +134,7 @@ csharp_new_line_before_finally = true
csharp_new_line_before_members_in_object_initializers = true
csharp_new_line_before_members_in_anonymous_types = true
resharper_wrap_before_first_type_parameter_constraint = true
-resharper_wrap_extends_list_style = chop_always
+resharper_wrap_extends_list_style = chop_always
resharper_wrap_after_dot_in_method_calls = false
resharper_wrap_before_binary_pattern_op = false
resharper_wrap_object_and_collection_initializer_style = chop_always
@@ -161,11 +161,12 @@ resharper_braces_for_fixed = required
resharper_braces_for_for = required
# Xml files
-[*.{xml,config,nuspec,resx,vsixmanifest,csproj,targets,props}]
+[*.{xml,config,nuspec,resx,vsixmanifest,csproj,targets,props,fsproj}]
indent_size = 2
# https://www.jetbrains.com/help/resharper/EditorConfig_XML_XmlCodeStylePageSchema.html#resharper_xml_blank_line_after_pi
resharper_blank_line_after_pi = false
resharper_space_before_self_closing = true
+ij_xml_space_inside_empty_tag = true
[*.json]
indent_size = 2
\ No newline at end of file
diff --git a/src/DiffEngine.Tests/DiffEngine.Tests.csproj b/src/DiffEngine.Tests/DiffEngine.Tests.csproj
index 94b4a5f2..c31456ec 100644
--- a/src/DiffEngine.Tests/DiffEngine.Tests.csproj
+++ b/src/DiffEngine.Tests/DiffEngine.Tests.csproj
@@ -8,12 +8,12 @@
-
+
-
-
-
-
+
+
+
+
diff --git a/src/DiffEngine.Tests/DiffRunnerTests.cs b/src/DiffEngine.Tests/DiffRunnerTests.cs
index 99ff6038..301062d5 100644
--- a/src/DiffEngine.Tests/DiffRunnerTests.cs
+++ b/src/DiffEngine.Tests/DiffRunnerTests.cs
@@ -192,9 +192,6 @@ static DiffRunnerTests() =>
Left: (tempFile, targetFile) => $"\"{tempFile}\" \"{targetFile}\"",
Right: (tempFile, targetFile) => $"\"{targetFile}\" \"{tempFile}\""),
exePath: FakeDiffTool.Exe,
- binaryExtensions: new[]
- {
- "knownBin"
- })!;
+ binaryExtensions: [".knownBin"])!;
}
#endif
\ No newline at end of file
diff --git a/src/DiffEngine.Tests/DiffToolsTest.cs b/src/DiffEngine.Tests/DiffToolsTest.cs
index dd691754..262085b3 100644
--- a/src/DiffEngine.Tests/DiffToolsTest.cs
+++ b/src/DiffEngine.Tests/DiffToolsTest.cs
@@ -28,15 +28,12 @@ public void AddTool()
Left: (tempFile, targetFile) => $"\"{targetFile}\" \"{tempFile}\"",
Right: (tempFile, targetFile) => $"\"{tempFile}\" \"{targetFile}\""),
exePath: diffToolPath,
- binaryExtensions: new[]
- {
- "jpg"
- })!;
+ binaryExtensions: [".jpg"])!;
#endregion
Assert.Equal(resolvedTool.Name, DiffTools.Resolved.First().Name);
- Assert.True(DiffTools.TryFindByExtension("jpg", out var forExtension));
+ Assert.True(DiffTools.TryFindByExtension(".jpg", out var forExtension));
Assert.Equal(resolvedTool.Name, forExtension.Name);
}
@@ -57,7 +54,7 @@ public void OrderShouldNotMessWithAddTool()
binaryExtensions: Enumerable.Empty())!;
DiffTools.UseOrder(DiffTool.VisualStudio, DiffTool.AraxisMerge);
Assert.Equal("MyCustomDiffTool", resolvedTool.Name);
- Assert.True(DiffTools.TryFindByExtension("txt", out var forExtension));
+ Assert.True(DiffTools.TryFindByExtension(".txt", out var forExtension));
Assert.Equal("MyCustomDiffTool", forExtension.Name);
}
@@ -77,7 +74,7 @@ public void AddToolBasedOn()
#endregion
Assert.Equal(resolvedTool, DiffTools.Resolved.First());
- Assert.True(DiffTools.TryFindByExtension("txt", out var forExtension));
+ Assert.True(DiffTools.TryFindByExtension(".txt", out var forExtension));
Assert.Equal(resolvedTool, forExtension);
Assert.Equal("\"custom args \"bar\" \"foo\"", resolvedTool.LaunchArguments.Left("foo", "bar"));
Assert.Equal("\"custom args \"foo\" \"bar\"", resolvedTool.LaunchArguments.Right("foo", "bar"));
@@ -140,10 +137,10 @@ public void ChangeOrder()
[Fact]
public void TryFind()
{
- Assert.True(DiffTools.TryFindByExtension("txt", out var resolved));
+ Assert.True(DiffTools.TryFindByExtension(".txt", out var resolved));
Assert.NotNull(resolved);
- Assert.False(DiffTools.TryFindByExtension("notFound", out resolved));
+ Assert.False(DiffTools.TryFindByExtension(".notFound", out resolved));
Assert.Null(resolved);
}
diff --git a/src/DiffEngine.Tests/diffTools.include.md b/src/DiffEngine.Tests/diffTools.include.md
index 672dc572..4d169af0 100644
--- a/src/DiffEngine.Tests/diffTools.include.md
+++ b/src/DiffEngine.Tests/diffTools.include.md
@@ -11,7 +11,7 @@ Non-MDI tools are preferred since it allows [DiffEngineTray](tray.md) to track a
* Supports auto-refresh: True
* Supports text files: True
* Environment variable for custom install location: `DiffEngine_BeyondCompare`
- * Supported binaries: pdf, bmp, gif, ico, jpg, jpeg, png, tif, tiff, rtf
+ * Supported binaries: .pdf, .bmp, .gif, .ico, .jpg, .jpeg, .png, .tif, .tiff, .rtf
#### Notes:
@@ -51,7 +51,7 @@ Non-MDI tools are preferred since it allows [DiffEngineTray](tray.md) to track a
* Supports auto-refresh: True
* Supports text files: True
* Environment variable for custom install location: `DiffEngine_DeltaWalker`
- * Supported binaries: jpg, jp2, j2k, png, gif, psd, tif, bmp, pct, pict, pic, ico, ppm, pgm, pbm, pnm, zip, jar, ear, tar, tgz, tbz2, gz, bz2, doc, docx, xls, xlsx, ppt, pdf, rtf, html, htm
+ * Supported binaries: .jpg, .jp2, .j2k, .png, .gif, .psd, .tif, .bmp, .pct, .pict, .pic, .ico, .ppm, .pgm, .pbm, .pnm, .zip, .jar, .ear, .tar, .tgz, .tbz2, .gz, .bz2, .doc, .docx, .xls, .xlsx, .ppt, .pdf, .rtf, .html, .htm
#### Notes:
@@ -129,7 +129,7 @@ Non-MDI tools are preferred since it allows [DiffEngineTray](tray.md) to track a
* Supports auto-refresh: False
* Supports text files: True
* Environment variable for custom install location: `DiffEngine_Guiffy`
- * Supported binaries: bmp, gif, jpeg, jpg, png, wbmp
+ * Supported binaries: .bmp, .gif, .jpeg, .jpg, .png, .wbmp
#### Notes:
@@ -163,7 +163,7 @@ Non-MDI tools are preferred since it allows [DiffEngineTray](tray.md) to track a
* Supports auto-refresh: True
* Supports text files: True
* Environment variable for custom install location: `DiffEngine_Kaleidoscope`
- * Supported binaries: bmp, gif, ico, jpg, jpeg, png, tiff, tif
+ * Supported binaries: .bmp, .gif, .ico, .jpg, .jpeg, .png, .tiff, .tif
#### OSX settings:
@@ -242,7 +242,7 @@ Non-MDI tools are preferred since it allows [DiffEngineTray](tray.md) to track a
* Supports auto-refresh: False
* Supports text files: True
* Environment variable for custom install location: `DiffEngine_P4Merge`
- * Supported binaries: bmp, gif, jpg, jpeg, png, pbm, pgm, ppm, tif, tiff, xbm, xpm
+ * Supported binaries: .bmp, .gif, .jpg, .jpeg, .png, .pbm, .pgm, .ppm, .tif, .tiff, .xbm, .xpm
#### Windows settings:
@@ -337,7 +337,7 @@ Non-MDI tools are preferred since it allows [DiffEngineTray](tray.md) to track a
* Supports auto-refresh: False
* Supports text files: False
* Environment variable for custom install location: `DiffEngine_TortoiseGitIDiff`
- * Supported binaries: bmp, gif, ico, jpg, jpeg, png, tif, tiff
+ * Supported binaries: .bmp, .gif, .ico, .jpg, .jpeg, .png, .tif, .tiff
#### Windows settings:
@@ -374,7 +374,7 @@ Non-MDI tools are preferred since it allows [DiffEngineTray](tray.md) to track a
* Supports auto-refresh: False
* Supports text files: False
* Environment variable for custom install location: `DiffEngine_TortoiseIDiff`
- * Supported binaries: bmp, gif, ico, jpg, jpeg, png, tif, tiff
+ * Supported binaries: .bmp, .gif, .ico, .jpg, .jpeg, .png, .tif, .tiff
#### Windows settings:
@@ -445,7 +445,7 @@ Non-MDI tools are preferred since it allows [DiffEngineTray](tray.md) to track a
* Supports auto-refresh: True
* Supports text files: True
* Environment variable for custom install location: `DiffEngine_WinMerge`
- * Supported binaries: bmp, cut, dds, exr, g3, gif, hdr, ico, iff, lbm, j2k, j2c, jng, jp2, jpg, jif, jpeg, jpe, jxr, wdp, hdp, koa, mng, pcd, pcx, pfm, pct, pict, pic, png, pbm, pgm, ppm, psd, ras, sgi, rgb, rgba, bw, tga, targa, tif, tiff, wap, wbmp, wbm, webp, xbm, xpm
+ * Supported binaries: .bmp, .cut, .dds, .exr, .g3, .gif, .hdr, .ico, .iff, .lbm, .j2k, .j2c, .jng, .jp2, .jpg, .jif, .jpeg, .jpe, .jxr, .wdp, .hdp, .koa, .mng, .pcd, .pcx, .pfm, .pct, .pict, .pic, .png, .pbm, .pgm, .ppm, .psd, .ras, .sgi, .rgb, .rgba, .bw, .tga, .targa, .tif, .tiff, .wap, .wbmp, .wbm, .webp, .xbm, .xpm
#### Notes:
@@ -477,7 +477,7 @@ Non-MDI tools are preferred since it allows [DiffEngineTray](tray.md) to track a
* Supports auto-refresh: True
* Supports text files: True
* Environment variable for custom install location: `DiffEngine_AraxisMerge`
- * Supported binaries: bmp, dib, emf, gif, jif, j2c, j2k, jp2, jpc, jpeg, jpg, jpx, pbm, pcx, pgm, png, ppm, ras, tif, tiff, tga, wmf
+ * Supported binaries: .bmp, .dib, .emf, .gif, .jif, .j2c, .j2k, .jp2, .jpc, .jpeg, .jpg, .jpx, .pbm, .pcx, .pgm, .png, .ppm, .ras, .tif, .tiff, .tga, .wmf
#### Notes:
diff --git a/src/DiffEngine/DiffEngine.csproj b/src/DiffEngine/DiffEngine.csproj
index c954843c..eddc5b2d 100644
--- a/src/DiffEngine/DiffEngine.csproj
+++ b/src/DiffEngine/DiffEngine.csproj
@@ -1,9 +1,7 @@
- netstandard2.0;netstandard2.1;net5.0;net6.0;net7.0;net8.0;netcoreapp3.1;netcoreapp3.0;netcoreapp2.1;netcoreapp2.0
-
-
- netstandard2.0;netstandard2.1;net5.0;net6.0;net7.0;net8.0;netcoreapp3.1;netcoreapp3.0;netcoreapp2.1;netcoreapp2.0;net461;net48
+ net472;net48
+ $(TargetFrameworks);net6.0;net7.0;net8.0
@@ -15,12 +13,12 @@
-
+
+
-
-
-
+
+
diff --git a/src/DiffEngine/DiffRunner.cs b/src/DiffEngine/DiffRunner.cs
index 2772c513..bc0ba31c 100644
--- a/src/DiffEngine/DiffRunner.cs
+++ b/src/DiffEngine/DiffRunner.cs
@@ -10,61 +10,65 @@ public static partial class DiffRunner
public static void MaxInstancesToLaunch(int value) =>
MaxInstance.SetForAppDomain(value);
- public static LaunchResult Launch(DiffTool tool, string tempFile, string targetFile)
+ public static LaunchResult Launch(DiffTool tool, string tempFile, string targetFile, Encoding? encoding = null)
{
GuardFiles(tempFile, targetFile);
return InnerLaunch(
([NotNullWhen(true)] out ResolvedTool? resolved) => DiffTools.TryFindByName(tool, out resolved),
tempFile,
- targetFile);
+ targetFile,
+ encoding);
}
- public static Task LaunchAsync(DiffTool tool, string tempFile, string targetFile)
+ public static Task LaunchAsync(DiffTool tool, string tempFile, string targetFile, Encoding? encoding = null)
{
GuardFiles(tempFile, targetFile);
return InnerLaunchAsync(
([NotNullWhen(true)] out ResolvedTool? resolved) => DiffTools.TryFindByName(tool, out resolved),
tempFile,
- targetFile);
+ targetFile,
+ encoding);
}
///
/// Launch a diff tool for the given paths.
///
- public static LaunchResult Launch(string tempFile, string targetFile)
+ public static LaunchResult Launch(string tempFile, string targetFile, Encoding? encoding = null)
{
GuardFiles(tempFile, targetFile);
return InnerLaunch(
([NotNullWhen(true)] out ResolvedTool? tool) =>
{
- var extension = FileExtensions.GetExtension(tempFile);
+ var extension = Path.GetExtension(tempFile);
return DiffTools.TryFindByExtension(extension, out tool);
},
tempFile,
- targetFile);
+ targetFile,
+ encoding);
}
///
/// Launch a diff tool for the given paths.
///
- public static Task LaunchAsync(string tempFile, string targetFile)
+ public static Task LaunchAsync(string tempFile, string targetFile, Encoding? encoding = null)
{
GuardFiles(tempFile, targetFile);
return InnerLaunchAsync(
([NotNullWhen(true)] out ResolvedTool? tool) =>
{
- var extension = FileExtensions.GetExtension(tempFile);
+ var extension = Path.GetExtension(tempFile);
return DiffTools.TryFindByExtension(extension, out tool);
},
tempFile,
- targetFile);
+ targetFile,
+ encoding);
}
- public static LaunchResult Launch(ResolvedTool tool, string tempFile, string targetFile)
+ public static LaunchResult Launch(ResolvedTool tool, string tempFile, string targetFile, Encoding? encoding = null)
{
GuardFiles(tempFile, targetFile);
@@ -75,10 +79,11 @@ public static LaunchResult Launch(ResolvedTool tool, string tempFile, string tar
return true;
},
tempFile,
- targetFile);
+ targetFile,
+ encoding);
}
- public static Task LaunchAsync(ResolvedTool tool, string tempFile, string targetFile)
+ public static Task LaunchAsync(ResolvedTool tool, string tempFile, string targetFile, Encoding? encoding = null)
{
GuardFiles(tempFile, targetFile);
@@ -89,12 +94,13 @@ public static Task LaunchAsync(ResolvedTool tool, string tempFile,
return true;
},
tempFile,
- targetFile);
+ targetFile,
+ encoding);
}
- static LaunchResult InnerLaunch(TryResolveTool tryResolveTool, string tempFile, string targetFile)
+ static LaunchResult InnerLaunch(TryResolveTool tryResolveTool, string tempFile, string targetFile, Encoding? encoding)
{
- if (ShouldExitLaunch(tryResolveTool, targetFile, out var tool, out var result))
+ if (ShouldExitLaunch(tryResolveTool, targetFile, encoding, out var tool, out var result))
{
DiffEngineTray.AddMove(tempFile, targetFile, null, null, false, null);
return result.Value;
@@ -126,9 +132,9 @@ static LaunchResult InnerLaunch(TryResolveTool tryResolveTool, string tempFile,
return LaunchResult.StartedNewInstance;
}
- static async Task InnerLaunchAsync(TryResolveTool tryResolveTool, string tempFile, string targetFile)
+ static async Task InnerLaunchAsync(TryResolveTool tryResolveTool, string tempFile, string targetFile, Encoding? encoding)
{
- if (ShouldExitLaunch(tryResolveTool, targetFile, out var tool, out var result))
+ if (ShouldExitLaunch(tryResolveTool, targetFile, encoding, out var tool, out var result))
{
await DiffEngineTray.AddMoveAsync(tempFile, targetFile, null, null, false, null);
return result.Value;
@@ -164,6 +170,7 @@ static async Task InnerLaunchAsync(TryResolveTool tryResolveTool,
static bool ShouldExitLaunch(
TryResolveTool tryResolveTool,
string targetFile,
+ Encoding? encoding,
[NotNullWhen(false)] out ResolvedTool? tool,
[NotNullWhen(true)] out LaunchResult? result)
{
@@ -180,7 +187,7 @@ static bool ShouldExitLaunch(
return true;
}
- if (!TryCreate(tool, targetFile))
+ if (!TryCreate(tool, targetFile, encoding))
{
result = LaunchResult.NoEmptyFileForExtension;
return true;
@@ -190,12 +197,12 @@ static bool ShouldExitLaunch(
return false;
}
- static bool TryCreate(ResolvedTool tool, string targetFile)
+ static bool TryCreate(ResolvedTool tool, string targetFile, Encoding? encoding)
{
var targetExists = File.Exists(targetFile);
if (tool.RequiresTarget && !targetExists)
{
- if (!AllFiles.TryCreateFile(targetFile, useEmptyStringForTextFiles: true))
+ if (!AllFiles.TryCreateFile(targetFile, useEmptyStringForTextFiles: true, encoding))
{
return false;
}
diff --git a/src/DiffEngine/DiffRunner_Kill.cs b/src/DiffEngine/DiffRunner_Kill.cs
index ea8e9044..286ca2d4 100644
--- a/src/DiffEngine/DiffRunner_Kill.cs
+++ b/src/DiffEngine/DiffRunner_Kill.cs
@@ -12,7 +12,7 @@ public static void Kill(string tempFile, string targetFile)
return;
}
- var extension = FileExtensions.GetExtension(tempFile);
+ var extension = Path.GetExtension(tempFile);
if (!DiffTools.TryFindByExtension(extension, out var diffTool))
{
Logging.Write($"Extension not found. {extension}");
diff --git a/src/DiffEngine/DiffTools.cs b/src/DiffEngine/DiffTools.cs
index 7fae782e..15232919 100644
--- a/src/DiffEngine/DiffTools.cs
+++ b/src/DiffEngine/DiffTools.cs
@@ -35,17 +35,18 @@ public static void UseOrder(in bool throwForNoTool, params DiffTool[] order)
InitTools(throwForNoTool, order);
}
- public static bool IsDetectedFor(DiffTool diffTool, string extensionOrPath)
- {
- var extension = FileExtensions.GetExtension(extensionOrPath);
+ public static bool IsDetectedForFile(DiffTool diffTool, string path) =>
+ IsDetectedForExtension(diffTool, Path.GetExtension(path));
+ public static bool IsDetectedForExtension(DiffTool diffTool, string extension)
+ {
var tool = resolved.SingleOrDefault(_ => _.Tool == diffTool);
if (tool == null)
{
return false;
}
- if (FileExtensions.IsText(extension))
+ if (FileExtensions.IsTextExtension(extension))
{
return tool.SupportsText;
}
diff --git a/src/DiffEngine/DiffTools_Add.cs b/src/DiffEngine/DiffTools_Add.cs
index f73f0dfa..6dc46444 100644
--- a/src/DiffEngine/DiffTools_Add.cs
+++ b/src/DiffEngine/DiffTools_Add.cs
@@ -54,8 +54,7 @@ static void AddResolvedToolAtStart(ResolvedTool resolvedTool)
resolved.Insert(0, resolvedTool);
foreach (var extension in resolvedTool.BinaryExtensions)
{
- var cleanedExtension = FileExtensions.GetExtension(extension);
- ExtensionLookup[cleanedExtension] = resolvedTool;
+ ExtensionLookup[extension] = resolvedTool;
}
PathLookup[resolvedTool.ExePath] = resolvedTool;
diff --git a/src/DiffEngine/DiffTools_TryFind.cs b/src/DiffEngine/DiffTools_TryFind.cs
index 65027bed..37ed13de 100644
--- a/src/DiffEngine/DiffTools_TryFind.cs
+++ b/src/DiffEngine/DiffTools_TryFind.cs
@@ -11,8 +11,7 @@ public static bool TryFindByExtension(
string extension,
[NotNullWhen(true)] out ResolvedTool? tool)
{
- extension = FileExtensions.GetExtension(extension);
- if (FileExtensions.IsText(extension))
+ if (FileExtensions.IsTextExtension(extension))
{
tool = resolved.FirstOrDefault(_ => _.SupportsText);
return tool != null;
diff --git a/src/DiffEngine/Guard.cs b/src/DiffEngine/Guard.cs
index 6824ea5a..8ce175ef 100644
--- a/src/DiffEngine/Guard.cs
+++ b/src/DiffEngine/Guard.cs
@@ -25,24 +25,6 @@ public static void AgainstEmpty(string value, string argumentName)
}
}
- public static void AgainstEmpty(object?[] value, string argumentName)
- {
- if (value == null)
- {
- throw new ArgumentNullException(argumentName);
- }
-
- if (value.Length == 0)
- {
- throw new ArgumentNullException(argumentName, "Argument cannot be empty.");
- }
-
- if (value.Any(item => item == null))
- {
- throw new ArgumentNullException(argumentName);
- }
- }
-
public static void AgainstEmpty(T[] value, string argumentName)
{
if (value == null)
@@ -55,14 +37,4 @@ public static void AgainstEmpty(T[] value, string argumentName)
throw new ArgumentNullException(argumentName, "Argument cannot be empty.");
}
}
-
- public static void AgainstBadExtension(string value, string argumentName)
- {
- AgainstEmpty(value, argumentName);
-
- if (value[0] == '.')
- {
- throw new ArgumentException("Must not start with a period ('.').", argumentName);
- }
- }
}
\ No newline at end of file
diff --git a/src/DiffEngine/Implementation/AraxisMerge.cs b/src/DiffEngine/Implementation/AraxisMerge.cs
index fab275bb..a97c4c69 100644
--- a/src/DiffEngine/Implementation/AraxisMerge.cs
+++ b/src/DiffEngine/Implementation/AraxisMerge.cs
@@ -9,31 +9,31 @@ public static Definition AraxisMerge() =>
Cost: "Paid",
SupportsText: true,
RequiresTarget: true,
- BinaryExtensions: new[]
- {
- "bmp",
- "dib",
- "emf",
- "gif",
- "jif",
- "j2c",
- "j2k",
- "jp2",
- "jpc",
- "jpeg",
- "jpg",
- "jpx",
- "pbm", //?
- "pcx",
- "pgm",
- "png",
- "ppm", //?
- "ras", //?
- "tif",
- "tiff",
- "tga",
- "wmf" //?
- },
+ BinaryExtensions:
+ [
+ ".bmp",
+ ".dib",
+ ".emf",
+ ".gif",
+ ".jif",
+ ".j2c",
+ ".j2k",
+ ".jp2",
+ ".jpc",
+ ".jpeg",
+ ".jpg",
+ ".jpx",
+ ".pbm", //?
+ ".pcx",
+ ".pgm",
+ ".png",
+ ".ppm", //?
+ ".ras", //?
+ ".tif",
+ ".tiff",
+ ".tga",
+ ".wmf" //?
+ ],
OsSupport: new(
Windows: new(
"Compare.exe",
diff --git a/src/DiffEngine/Implementation/BeyondCompare.cs b/src/DiffEngine/Implementation/BeyondCompare.cs
index 5d5cb2d8..2f0f8972 100644
--- a/src/DiffEngine/Implementation/BeyondCompare.cs
+++ b/src/DiffEngine/Implementation/BeyondCompare.cs
@@ -24,19 +24,19 @@ static string RightOsxLinuxArguments(string temp, string target) =>
// technically BC doesnt require a target.
// but if no target exists, the target cannot be edited
RequiresTarget: true,
- BinaryExtensions: new[]
- {
- "pdf",
- "bmp",
- "gif",
- "ico",
- "jpg",
- "jpeg",
- "png",
- "tif",
- "tiff",
- "rtf"
- },
+ BinaryExtensions:
+ [
+ ".pdf",
+ ".bmp",
+ ".gif",
+ ".ico",
+ ".jpg",
+ ".jpeg",
+ ".png",
+ ".tif",
+ ".tiff",
+ ".rtf"
+ ],
OsSupport: new(
Windows: new(
"BCompare.exe",
diff --git a/src/DiffEngine/Implementation/DeltaWalker.cs b/src/DiffEngine/Implementation/DeltaWalker.cs
index 0769b07a..9f739814 100644
--- a/src/DiffEngine/Implementation/DeltaWalker.cs
+++ b/src/DiffEngine/Implementation/DeltaWalker.cs
@@ -14,42 +14,42 @@ public static Definition DeltaWalker()
SupportsText: true,
RequiresTarget: false,
Cost: "Paid",
- BinaryExtensions: new[]
- {
- "jpg",
- "jp2",
- "j2k",
- "png",
- "gif",
- "psd",
- "tif",
- "bmp",
- "pct",
- "pict",
- "pic",
- "ico",
- "ppm",
- "pgm",
- "pbm",
- "pnm",
- "zip",
- "jar",
- "ear",
- "tar",
- "tgz",
- "tbz2",
- "gz",
- "bz2",
- "doc",
- "docx",
- "xls",
- "xlsx",
- "ppt",
- "pdf",
- "rtf",
- "html",
- "htm"
- },
+ BinaryExtensions:
+ [
+ ".jpg",
+ ".jp2",
+ ".j2k",
+ ".png",
+ ".gif",
+ ".psd",
+ ".tif",
+ ".bmp",
+ ".pct",
+ ".pict",
+ ".pic",
+ ".ico",
+ ".ppm",
+ ".pgm",
+ ".pbm",
+ ".pnm",
+ ".zip",
+ ".jar",
+ ".ear",
+ ".tar",
+ ".tgz",
+ ".tbz2",
+ ".gz",
+ ".bz2",
+ ".doc",
+ ".docx",
+ ".xls",
+ ".xlsx",
+ ".ppt",
+ ".pdf",
+ ".rtf",
+ ".html",
+ ".htm"
+ ],
OsSupport: new(
Osx: new(
"DeltaWalker",
diff --git a/src/DiffEngine/Implementation/Guiffy.cs b/src/DiffEngine/Implementation/Guiffy.cs
index 2092c0c3..34dda6d8 100644
--- a/src/DiffEngine/Implementation/Guiffy.cs
+++ b/src/DiffEngine/Implementation/Guiffy.cs
@@ -14,15 +14,15 @@ public static Definition Guiffy()
SupportsText: true,
RequiresTarget: true,
Cost: "Paid",
- BinaryExtensions: new[]
- {
- "bmp",
- "gif",
- "jpeg",
- "jpg",
- "png",
- "wbmp"
- },
+ BinaryExtensions:
+ [
+ ".bmp",
+ ".gif",
+ ".jpeg",
+ ".jpg",
+ ".png",
+ ".wbmp"
+ ],
OsSupport: new(
Windows: new(
"guiffy.exe",
diff --git a/src/DiffEngine/Implementation/Kaleidoscope.cs b/src/DiffEngine/Implementation/Kaleidoscope.cs
index 1e9bb9f5..89f49984 100644
--- a/src/DiffEngine/Implementation/Kaleidoscope.cs
+++ b/src/DiffEngine/Implementation/Kaleidoscope.cs
@@ -9,17 +9,17 @@ public static Definition Kaleidoscope() =>
SupportsText: true,
RequiresTarget: true,
Cost: "Paid",
- BinaryExtensions: new[]
- {
- "bmp",
- "gif",
- "ico",
- "jpg",
- "jpeg",
- "png",
- "tiff",
- "tif"
- },
+ BinaryExtensions:
+ [
+ ".bmp",
+ ".gif",
+ ".ico",
+ ".jpg",
+ ".jpeg",
+ ".png",
+ ".tiff",
+ ".tif"
+ ],
OsSupport: new(
Osx: new(
"ksdiff",
diff --git a/src/DiffEngine/Implementation/P4Merge.cs b/src/DiffEngine/Implementation/P4Merge.cs
index cc04d89c..ddc0be02 100644
--- a/src/DiffEngine/Implementation/P4Merge.cs
+++ b/src/DiffEngine/Implementation/P4Merge.cs
@@ -5,7 +5,7 @@ public static Definition P4Merge()
var launchArguments = new LaunchArguments(
Left: (temp, target) =>
{
- if (FileExtensions.IsText(temp))
+ if (FileExtensions.IsTextFile(temp))
{
return $"\"{target}\" \"{temp}\"";
}
@@ -14,7 +14,7 @@ public static Definition P4Merge()
},
Right: (temp, target) =>
{
- if (FileExtensions.IsText(temp))
+ if (FileExtensions.IsTextFile(temp))
{
return $"\"{temp}\" \"{target}\"";
}
@@ -30,21 +30,21 @@ public static Definition P4Merge()
SupportsText: true,
RequiresTarget: true,
Cost: "Free",
- BinaryExtensions: new[]
- {
- "bmp",
- "gif",
- "jpg",
- "jpeg",
- "png",
- "pbm",
- "pgm",
- "ppm",
- "tif",
- "tiff",
- "xbm",
- "xpm"
- },
+ BinaryExtensions:
+ [
+ ".bmp",
+ ".gif",
+ ".jpg",
+ ".jpeg",
+ ".png",
+ ".pbm",
+ ".pgm",
+ ".ppm",
+ ".tif",
+ ".tiff",
+ ".xbm",
+ ".xpm"
+ ],
OsSupport: new(
Windows: new(
"p4merge.exe",
diff --git a/src/DiffEngine/Implementation/TortoiseGitIDiff.cs b/src/DiffEngine/Implementation/TortoiseGitIDiff.cs
index 8baf9327..402f3d40 100644
--- a/src/DiffEngine/Implementation/TortoiseGitIDiff.cs
+++ b/src/DiffEngine/Implementation/TortoiseGitIDiff.cs
@@ -9,17 +9,17 @@ public static Definition TortoiseGitIDiff() =>
SupportsText: false,
RequiresTarget: true,
Cost: "Free",
- BinaryExtensions: new[]
- {
- "bmp",
- "gif",
- "ico",
- "jpg",
- "jpeg",
- "png",
- "tif",
- "tiff"
- },
+ BinaryExtensions:
+ [
+ ".bmp",
+ ".gif",
+ ".ico",
+ ".jpg",
+ ".jpeg",
+ ".png",
+ ".tif",
+ ".tiff"
+ ],
OsSupport: new(
Windows: new(
"TortoiseGitIDiff.exe",
diff --git a/src/DiffEngine/Implementation/TortoiseIDiff.cs b/src/DiffEngine/Implementation/TortoiseIDiff.cs
index 66b488c3..495a5f05 100644
--- a/src/DiffEngine/Implementation/TortoiseIDiff.cs
+++ b/src/DiffEngine/Implementation/TortoiseIDiff.cs
@@ -9,17 +9,17 @@ public static Definition TortoiseIDiff() =>
SupportsText: false,
RequiresTarget: true,
Cost: "Free",
- BinaryExtensions: new[]
- {
- "bmp",
- "gif",
- "ico",
- "jpg",
- "jpeg",
- "png",
- "tif",
- "tiff"
- },
+ BinaryExtensions:
+ [
+ ".bmp",
+ ".gif",
+ ".ico",
+ ".jpg",
+ ".jpeg",
+ ".png",
+ ".tif",
+ ".tiff"
+ ],
OsSupport: new(
Windows: new(
"TortoiseIDiff.exe",
diff --git a/src/DiffEngine/Implementation/WinMerge.cs b/src/DiffEngine/Implementation/WinMerge.cs
index b00ad62e..4b95423a 100644
--- a/src/DiffEngine/Implementation/WinMerge.cs
+++ b/src/DiffEngine/Implementation/WinMerge.cs
@@ -24,58 +24,58 @@ static string RightArguments(string temp, string target)
SupportsText: true,
RequiresTarget: true,
Cost: "Free with option to donate",
- BinaryExtensions: new[]
- {
- "bmp",
- "cut",
- "dds",
- "exr",
- "g3",
- "gif",
- "hdr",
- "ico",
- "iff",
- "lbm",
- "j2k",
- "j2c",
- "jng",
- "jp2",
- "jpg",
- "jif",
- "jpeg",
- "jpe",
- "jxr",
- "wdp",
- "hdp",
- "koa",
- "mng",
- "pcd",
- "pcx",
- "pfm",
- "pct",
- "pict",
- "pic",
- "png",
- "pbm",
- "pgm",
- "ppm",
- "psd",
- "ras",
- "sgi",
- "rgb",
- "rgba",
- "bw",
- "tga",
- "targa",
- "tif",
- "tiff",
- "wap",
- "wbmp",
- "wbm",
- "webp",
- "xbm",
- "xpm"
- },
+ BinaryExtensions:
+ [
+ ".bmp",
+ ".cut",
+ ".dds",
+ ".exr",
+ ".g3",
+ ".gif",
+ ".hdr",
+ ".ico",
+ ".iff",
+ ".lbm",
+ ".j2k",
+ ".j2c",
+ ".jng",
+ ".jp2",
+ ".jpg",
+ ".jif",
+ ".jpeg",
+ ".jpe",
+ ".jxr",
+ ".wdp",
+ ".hdp",
+ ".koa",
+ ".mng",
+ ".pcd",
+ ".pcx",
+ ".pfm",
+ ".pct",
+ ".pict",
+ ".pic",
+ ".png",
+ ".pbm",
+ ".pgm",
+ ".ppm",
+ ".psd",
+ ".ras",
+ ".sgi",
+ ".rgb",
+ ".rgba",
+ ".bw",
+ ".tga",
+ ".targa",
+ ".tif",
+ ".tiff",
+ ".wap",
+ ".wbmp",
+ ".wbm",
+ ".webp",
+ ".xbm",
+ ".xpm"
+ ],
OsSupport: new(
Windows: new(
"WinMergeU.exe",
diff --git a/src/DiffEngine/OrderReader.cs b/src/DiffEngine/OrderReader.cs
index 72c3a15c..2f988845 100644
--- a/src/DiffEngine/OrderReader.cs
+++ b/src/DiffEngine/OrderReader.cs
@@ -2,7 +2,9 @@
{
public record Result(bool UsedToolOrderEnvVar, IEnumerable Order);
- static Result defaultResult = new(false, Enum.GetValues(typeof(DiffTool)).Cast());
+ static Result defaultResult = new(false, Enum
+ .GetValues(typeof(DiffTool))
+ .Cast());
public static Result ReadToolOrder()
{
@@ -17,10 +19,12 @@ public static Result ReadToolOrder()
return new(true, order);
}
+ static char[] environmentSeparators = [',', '|', ' '];
+
internal static IEnumerable ParseEnvironment(string diffOrder)
{
foreach (var toolString in diffOrder
- .Split(new[] {',', '|', ' '}, StringSplitOptions.RemoveEmptyEntries))
+ .Split(environmentSeparators, StringSplitOptions.RemoveEmptyEntries))
{
if (!Enum.TryParse(toolString, out var diffTool))
{
diff --git a/src/DiffEngine/OsSettings.cs b/src/DiffEngine/OsSettings.cs
index b389e3a0..423d7a3a 100644
--- a/src/DiffEngine/OsSettings.cs
+++ b/src/DiffEngine/OsSettings.cs
@@ -5,10 +5,7 @@ public OsSettings(string exeName, string pathCommandName, LaunchArguments launch
exeName,
pathCommandName,
launchArguments,
- new[]
- {
- searchDirectory
- })
+ [searchDirectory])
{
}
@@ -22,10 +19,7 @@ public OsSettings(string exeName, LaunchArguments launchArguments, string search
exeName,
exeName,
launchArguments,
- new[]
- {
- searchDirectory
- })
+ [searchDirectory])
{
}
diff --git a/src/DiffEngine/OsSettingsResolver.cs b/src/DiffEngine/OsSettingsResolver.cs
index 1170187e..093e2018 100644
--- a/src/DiffEngine/OsSettingsResolver.cs
+++ b/src/DiffEngine/OsSettingsResolver.cs
@@ -17,7 +17,7 @@ static OsSettingsResolver()
}
else
{
- envPaths = Array.Empty();
+ envPaths = [];
}
}
diff --git a/src/DiffEngine/Process/LinuxOsxProcess.cs b/src/DiffEngine/Process/LinuxOsxProcess.cs
index 2ceb88a9..1c4c381e 100644
--- a/src/DiffEngine/Process/LinuxOsxProcess.cs
+++ b/src/DiffEngine/Process/LinuxOsxProcess.cs
@@ -66,7 +66,7 @@ public static bool TryParse(string line, out ProcessCommand? processCommand)
var multiSpaceIndex = 0;
CharSpan command;
- var spaces = new CharSpan(new []{' ',' ',' '});
+ var spaces = new CharSpan([' ',' ',' ']);
if (timeAndCommandString.IndexOf(spaces, StringComparison.InvariantCulture) > 0)
{
multiSpaceIndex = timeAndCommandString[firstSpace..].IndexOf(spaces, StringComparison.InvariantCulture);
diff --git a/src/DiffEngine/ResolvedTool.cs b/src/DiffEngine/ResolvedTool.cs
index 865c23d6..a3201f3d 100644
--- a/src/DiffEngine/ResolvedTool.cs
+++ b/src/DiffEngine/ResolvedTool.cs
@@ -1,15 +1,8 @@
-namespace DiffEngine;
-
-public record ResolvedTool(
- string Name,
- DiffTool? Tool,
- string ExePath,
- LaunchArguments LaunchArguments,
- bool IsMdi,
- bool AutoRefresh,
- IReadOnlyCollection BinaryExtensions,
- bool RequiresTarget,
- bool SupportsText)
+using System.Collections.Frozen;
+
+namespace DiffEngine;
+
+public record ResolvedTool
{
internal void CommandAndArguments(string tempFile, string targetFile, out string arguments, out string command)
{
@@ -32,8 +25,50 @@ public string GetArguments(string tempFile, string targetFile)
public ResolvedTool(string name, string exePath, LaunchArguments launchArguments, bool isMdi, bool autoRefresh, IReadOnlyCollection binaryExtensions, bool requiresTarget, bool supportsText) :
this(name, null, exePath, launchArguments, isMdi, autoRefresh, binaryExtensions, requiresTarget, supportsText)
+ {
+ }
+
+ public ResolvedTool(
+ string name,
+ DiffTool? tool,
+ string exePath,
+ LaunchArguments launchArguments,
+ bool isMdi,
+ bool autoRefresh,
+ IReadOnlyCollection binaryExtensions,
+ bool requiresTarget,
+ bool supportsText)
{
Guard.FileExists(exePath, nameof(exePath));
Guard.AgainstEmpty(name, nameof(name));
+ Name = name;
+ Tool = tool;
+ ExePath = exePath;
+ LaunchArguments = launchArguments;
+ IsMdi = isMdi;
+ AutoRefresh = autoRefresh;
+ BinaryExtensions = binaryExtensions.ToFrozenSet();
+ if (binaryExtensions.Any(_ => !_.StartsWith('.')))
+ {
+ throw new(
+ $"""
+ Extensions must begin with a period.
+ {string.Join(Environment.NewLine, binaryExtensions)}
+ """);
+ }
+
+ RequiresTarget = requiresTarget;
+ SupportsText = supportsText;
}
+
+ public string Name { get; init; }
+ public DiffTool? Tool { get; init; }
+ public string ExePath { get; init; }
+ public LaunchArguments LaunchArguments { get; init; }
+ public bool IsMdi { get; init; }
+ public bool AutoRefresh { get; init; }
+ public FrozenSet BinaryExtensions { get; init; }
+ public bool RequiresTarget { get; init; }
+ public bool SupportsText { get; init; }
+
}
\ No newline at end of file
diff --git a/src/DiffEngine/WildcardFileFinder.cs b/src/DiffEngine/WildcardFileFinder.cs
index a18847fa..4d7fc9b9 100644
--- a/src/DiffEngine/WildcardFileFinder.cs
+++ b/src/DiffEngine/WildcardFileFinder.cs
@@ -1,10 +1,10 @@
static class WildcardFileFinder
{
static char[] separators =
- {
+ [
Path.DirectorySeparatorChar,
Path.AltDirectorySeparatorChar
- };
+ ];
static IEnumerable EnumerateDirectories(string directory)
{
diff --git a/src/DiffEngineTray.Tests/DiffEngineTray.Tests.csproj b/src/DiffEngineTray.Tests/DiffEngineTray.Tests.csproj
index 850b9af7..c3c8fbac 100644
--- a/src/DiffEngineTray.Tests/DiffEngineTray.Tests.csproj
+++ b/src/DiffEngineTray.Tests/DiffEngineTray.Tests.csproj
@@ -7,14 +7,14 @@
-
+
-
+
-
-
-
+
+
+
diff --git a/src/DiffEngineTray.Tests/SettingsHelperTests.cs b/src/DiffEngineTray.Tests/SettingsHelperTests.cs
index 51c395fb..2895ec0d 100644
--- a/src/DiffEngineTray.Tests/SettingsHelperTests.cs
+++ b/src/DiffEngineTray.Tests/SettingsHelperTests.cs
@@ -1,29 +1,29 @@
-[UsesVerify]
-public class SettingsHelperTests(ITestOutputHelper output) :
- XunitContextBase(output)
-{
- [Fact]
- public async Task ReadWrite()
- {
- var tempFile = "ReadWrite.txt";
- File.Delete(tempFile);
- try
- {
- SettingsHelper.FilePath = tempFile;
- await SettingsHelper.Write(
- new()
- {
- AcceptAllHotKey = new()
- {
- Key = "T"
- }
- });
- var result = await SettingsHelper.Read();
- await Verify(result);
- }
- finally
- {
- File.Delete(tempFile);
- }
- }
-}
\ No newline at end of file
+// [UsesVerify]
+// public class SettingsHelperTests(ITestOutputHelper output) :
+// XunitContextBase(output)
+// {
+// [Fact]
+// public async Task ReadWrite()
+// {
+// var tempFile = "ReadWrite.txt";
+// File.Delete(tempFile);
+// try
+// {
+// SettingsHelper.FilePath = tempFile;
+// await SettingsHelper.Write(
+// new()
+// {
+// AcceptAllHotKey = new()
+// {
+// Key = "T"
+// }
+// });
+// var result = await SettingsHelper.Read();
+// await Verify(result);
+// }
+// finally
+// {
+// File.Delete(tempFile);
+// }
+// }
+// }
\ No newline at end of file
diff --git a/src/DiffEngineTray/DiffEngineTray.csproj b/src/DiffEngineTray/DiffEngineTray.csproj
index 9bf43186..599df42a 100644
--- a/src/DiffEngineTray/DiffEngineTray.csproj
+++ b/src/DiffEngineTray/DiffEngineTray.csproj
@@ -34,7 +34,7 @@
-
+
diff --git a/src/DiffEngineTray/Program.cs b/src/DiffEngineTray/Program.cs
index 1274c350..a4cdf9eb 100644
--- a/src/DiffEngineTray/Program.cs
+++ b/src/DiffEngineTray/Program.cs
@@ -1,3 +1,5 @@
+using NotifyIcon = System.Windows.Forms.NotifyIcon;
+
static class Program
{
static async Task Main()
@@ -55,7 +57,6 @@ static async Task Inner()
async () => await OptionsFormLauncher.Launch(keyRegister, tracker),
tracker);
- var showMenu = typeof(NotifyIcon).GetMethod("ShowContextMenu", BindingFlags.Instance | BindingFlags.NonPublic)!;
icon.MouseClick += (_, args) =>
{
if (args.Button == MouseButtons.Left)
@@ -63,7 +64,7 @@ static async Task Inner()
var position = Cursor.Position;
position.Offset(-menuStrip.Width, -menuStrip.Height);
menuStrip.Location = position;
- showMenu.Invoke(icon, null);
+ ShowContextMenu(icon);
}
};
@@ -74,6 +75,9 @@ static async Task Inner()
await task;
}
+ [UnsafeAccessor(UnsafeAccessorKind.Method, Name = "ShowContextMenu")]
+ static extern void ShowContextMenu(NotifyIcon icon);
+
static void ReBindKeys(Settings settings, KeyRegister keyRegister, Tracker tracker)
{
var discardAllHotKey = settings.DiscardAllHotKey;
diff --git a/src/Directory.Build.props b/src/Directory.Build.props
index c0b8bc3f..d98c6a4a 100644
--- a/src/Directory.Build.props
+++ b/src/Directory.Build.props
@@ -2,7 +2,7 @@
CS1591;CS0649
- 13.0.2
+ 15.1.1
1.0.0
Testing, Snapshot, Diff, Compare
Launches diff tools based on file extensions. Designed to be consumed by snapshot testing libraries.
diff --git a/src/Shared.sln.DotSettings b/src/Shared.sln.DotSettings
index 500b0d7a..f2dd1f39 100644
--- a/src/Shared.sln.DotSettings
+++ b/src/Shared.sln.DotSettings
@@ -27,6 +27,7 @@
ERROR
ERROR
ERROR
+ ERROR
ERROR
ERROR
ERROR
@@ -36,6 +37,7 @@
ERROR
ERROR
DO_NOT_SHOW
+ DO_NOT_SHOW
ERROR
ERROR
ERROR
@@ -43,6 +45,7 @@
ERROR
ERROR
ERROR
+ ERROR
ERROR
ERROR
ERROR
@@ -151,7 +154,10 @@
NEVER
NEVER
False
+ True
+ CHOP_ALWAYS
False
+ CHOP_ALWAYS
False
False
RemoveIndent