Skip to content

Commit 55165b2

Browse files
authored
Remove Fody
1 parent 245b0d6 commit 55165b2

File tree

15 files changed

+205
-48
lines changed

15 files changed

+205
-48
lines changed

src/DiffEngine.Tests/DiffToolsTest.cs

Lines changed: 71 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -217,6 +217,77 @@ public void TryFindByName()
217217
}
218218
#endif
219219
**/
220+
[Fact]
221+
public void TryFindByName_IsCaseInsensitive()
222+
{
223+
var diffToolPath = FakeDiffTool.Exe;
224+
225+
DiffTools.AddTool(
226+
name: "MyCaseSensitiveTool",
227+
autoRefresh: true,
228+
isMdi: false,
229+
supportsText: true,
230+
requiresTarget: true,
231+
useShellExecute: true,
232+
launchArguments: new(
233+
Left: (tempFile, targetFile) => $"\"{targetFile}\" \"{tempFile}\"",
234+
Right: (tempFile, targetFile) => $"\"{tempFile}\" \"{targetFile}\""),
235+
exePath: diffToolPath,
236+
binaryExtensions: []);
237+
238+
// Exact case
239+
Assert.True(DiffTools.TryFindByName("MyCaseSensitiveTool", out var tool1));
240+
Assert.Equal("MyCaseSensitiveTool", tool1!.Name);
241+
242+
// All lowercase
243+
Assert.True(DiffTools.TryFindByName("mycasesensitivetool", out var tool2));
244+
Assert.Equal("MyCaseSensitiveTool", tool2!.Name);
245+
246+
// All uppercase
247+
Assert.True(DiffTools.TryFindByName("MYCASESENSITIVETOOL", out var tool3));
248+
Assert.Equal("MyCaseSensitiveTool", tool3!.Name);
249+
250+
// Mixed case
251+
Assert.True(DiffTools.TryFindByName("myCASEsensitiveTOOL", out var tool4));
252+
Assert.Equal("MyCaseSensitiveTool", tool4!.Name);
253+
}
254+
255+
[Fact]
256+
public void AddTool_RejectsDuplicateNameCaseInsensitive()
257+
{
258+
var diffToolPath = FakeDiffTool.Exe;
259+
260+
DiffTools.AddTool(
261+
name: "UniqueTool",
262+
autoRefresh: true,
263+
isMdi: false,
264+
supportsText: true,
265+
requiresTarget: true,
266+
useShellExecute: true,
267+
launchArguments: new(
268+
Left: (tempFile, targetFile) => $"\"{targetFile}\" \"{tempFile}\"",
269+
Right: (tempFile, targetFile) => $"\"{tempFile}\" \"{targetFile}\""),
270+
exePath: diffToolPath,
271+
binaryExtensions: []);
272+
273+
// Adding with different case should throw
274+
var exception = Assert.Throws<ArgumentException>(() =>
275+
DiffTools.AddTool(
276+
name: "UNIQUETOOL",
277+
autoRefresh: true,
278+
isMdi: false,
279+
supportsText: true,
280+
requiresTarget: true,
281+
useShellExecute: true,
282+
launchArguments: new(
283+
Left: (tempFile, targetFile) => $"\"{targetFile}\" \"{tempFile}\"",
284+
Right: (tempFile, targetFile) => $"\"{tempFile}\" \"{targetFile}\""),
285+
exePath: diffToolPath,
286+
binaryExtensions: []));
287+
288+
Assert.Contains("Tool with name already exists", exception.Message);
289+
}
290+
220291
public DiffToolsTest(ITestOutputHelper output) :
221292
base(output) =>
222293
DiffTools.Reset();
Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
public class TargetPositionTest :
2+
XunitContextBase
3+
{
4+
[Theory]
5+
[InlineData("true", true)]
6+
[InlineData("TRUE", true)]
7+
[InlineData("True", true)]
8+
[InlineData("tRuE", true)]
9+
[InlineData("false", false)]
10+
[InlineData("FALSE", false)]
11+
[InlineData("False", false)]
12+
[InlineData("fAlSe", false)]
13+
public void ParseTargetOnLeft_IsCaseInsensitive(string input, bool expected)
14+
{
15+
var result = TargetPosition.ParseTargetOnLeft(input);
16+
Assert.Equal(expected, result);
17+
}
18+
19+
[Fact]
20+
public void ParseTargetOnLeft_NullReturnsNull()
21+
{
22+
var result = TargetPosition.ParseTargetOnLeft(null);
23+
Assert.Null(result);
24+
}
25+
26+
[Theory]
27+
[InlineData("yes")]
28+
[InlineData("no")]
29+
[InlineData("1")]
30+
[InlineData("0")]
31+
[InlineData("")]
32+
[InlineData("invalid")]
33+
public void ParseTargetOnLeft_InvalidValueThrows(string input)
34+
{
35+
var exception = Assert.Throws<Exception>(() => TargetPosition.ParseTargetOnLeft(input));
36+
Assert.Contains("Unable to parse Position", exception.Message);
37+
Assert.Contains(input, exception.Message);
38+
}
39+
40+
public TargetPositionTest(ITestOutputHelper output) :
41+
base(output)
42+
{
43+
}
44+
}

src/DiffEngine/DiffEngine.csproj

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,9 +16,7 @@
1616
<PackageReference Include="Microsoft.Sbom.Targets" PrivateAssets="all" />
1717
<PackageReference Include="System.Runtime.InteropServices.RuntimeInformation"
1818
Condition="'$(TargetFramework)' == 'net462' OR '$(TargetFramework)' == 'net472'" />
19-
<PackageReference Include="Caseless.Fody" PrivateAssets="All" />
2019
<PackageReference Include="EmptyFiles" PrivateAssets="None" />
21-
<PackageReference Include="Fody" PrivateAssets="all" />
2220
<PackageReference Include="Polyfill" PrivateAssets="all" />
2321
<PackageReference Include="ProjectDefaults" PrivateAssets="all" />
2422
</ItemGroup>

src/DiffEngine/DiffTools_Add.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ public static partial class DiffTools
5252
static ResolvedTool? AddInner(string name, DiffTool? diffTool, bool autoRefresh, bool isMdi, bool supportsText, bool requiresTarget, IEnumerable<string> binaries, string exePath, LaunchArguments launchArguments, bool useShellExecute, bool createNoWindow)
5353
{
5454
Guard.AgainstEmpty(name, nameof(name));
55-
if (resolved.Any(_ => _.Name == name))
55+
if (resolved.Any(_ => _.Name.Equals(name, StringComparison.OrdinalIgnoreCase)))
5656
{
5757
throw new ArgumentException($"Tool with name already exists. Name: {name}", nameof(name));
5858
}

src/DiffEngine/DiffTools_TryFind.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,7 @@ public static bool TryFindByName(
6565
string name,
6666
[NotNullWhen(true)] out ResolvedTool? resolvedTool)
6767
{
68-
resolvedTool = resolved.SingleOrDefault(_ => _.Name.Equals(name, StringComparison.Ordinal));
68+
resolvedTool = resolved.SingleOrDefault(_ => _.Name.Equals(name, StringComparison.OrdinalIgnoreCase));
6969
return resolvedTool != null;
7070
}
7171
}

src/DiffEngine/FodyWeavers.xml

Lines changed: 0 additions & 3 deletions
This file was deleted.

src/DiffEngine/OsSettingsResolver.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -83,7 +83,7 @@ public static bool TryFindForEnvironmentVariable(string tool, string exeName, [N
8383
return false;
8484
}
8585

86-
if (basePath.EndsWith(exeName) &&
86+
if (basePath.EndsWith(exeName, StringComparison.OrdinalIgnoreCase) &&
8787
File.Exists(basePath))
8888
{
8989
envPath = basePath;

src/DiffEngine/TargetPosition.cs

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -5,21 +5,22 @@
55
static TargetPosition() =>
66
TargetOnLeft = ReadTargetOnLeft().GetValueOrDefault(false);
77

8-
static bool? ReadTargetOnLeft()
9-
{
10-
var value = Environment.GetEnvironmentVariable("DiffEngine_TargetOnLeft");
8+
static bool? ReadTargetOnLeft() =>
9+
ParseTargetOnLeft(Environment.GetEnvironmentVariable("DiffEngine_TargetOnLeft"));
1110

11+
internal static bool? ParseTargetOnLeft(string? value)
12+
{
1213
if (value == null)
1314
{
1415
return null;
1516
}
1617

17-
if (value == "true")
18+
if (string.Equals(value, "true", StringComparison.OrdinalIgnoreCase))
1819
{
1920
return true;
2021
}
2122

22-
if (value == "false")
23+
if (string.Equals(value, "false", StringComparison.OrdinalIgnoreCase))
2324
{
2425
return false;
2526
}
Lines changed: 59 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,59 @@
1+
public class ImagesTest :
2+
XunitContextBase
3+
{
4+
[Fact]
5+
public void AllImagesLoaded()
6+
{
7+
// Verify all icon resources load correctly
8+
Assert.NotNull(Images.Active);
9+
Assert.NotNull(Images.Default);
10+
11+
// Verify all image resources load correctly
12+
Assert.NotNull(Images.Exit);
13+
Assert.NotNull(Images.Delete);
14+
Assert.NotNull(Images.AcceptAll);
15+
Assert.NotNull(Images.Accept);
16+
Assert.NotNull(Images.Discard);
17+
Assert.NotNull(Images.VisualStudio);
18+
Assert.NotNull(Images.Folder);
19+
Assert.NotNull(Images.Options);
20+
Assert.NotNull(Images.Link);
21+
}
22+
23+
[Fact]
24+
public void IconsHaveValidSize()
25+
{
26+
Assert.True(Images.Active.Width > 0);
27+
Assert.True(Images.Active.Height > 0);
28+
Assert.True(Images.Default.Width > 0);
29+
Assert.True(Images.Default.Height > 0);
30+
}
31+
32+
[Fact]
33+
public void ImagesHaveValidSize()
34+
{
35+
Assert.True(Images.Exit.Width > 0);
36+
Assert.True(Images.Exit.Height > 0);
37+
Assert.True(Images.Delete.Width > 0);
38+
Assert.True(Images.Delete.Height > 0);
39+
Assert.True(Images.AcceptAll.Width > 0);
40+
Assert.True(Images.AcceptAll.Height > 0);
41+
Assert.True(Images.Accept.Width > 0);
42+
Assert.True(Images.Accept.Height > 0);
43+
Assert.True(Images.Discard.Width > 0);
44+
Assert.True(Images.Discard.Height > 0);
45+
Assert.True(Images.VisualStudio.Width > 0);
46+
Assert.True(Images.VisualStudio.Height > 0);
47+
Assert.True(Images.Folder.Width > 0);
48+
Assert.True(Images.Folder.Height > 0);
49+
Assert.True(Images.Options.Width > 0);
50+
Assert.True(Images.Options.Height > 0);
51+
Assert.True(Images.Link.Width > 0);
52+
Assert.True(Images.Link.Height > 0);
53+
}
54+
55+
public ImagesTest(ITestOutputHelper output) :
56+
base(output)
57+
{
58+
}
59+
}
Lines changed: 5 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
public class TrackerClearTest :
2-
XunitContextBase
1+
public class TrackerClearTest(ITestOutputHelper output) :
2+
XunitContextBase(output)
33
{
44
[Fact]
55
public async Task Simple()
@@ -11,20 +11,13 @@ public async Task Simple()
1111
tracker.AssertEmpty();
1212
}
1313

14-
public TrackerClearTest(ITestOutputHelper output) :
15-
base(output)
16-
{
17-
file1 = Path.GetTempFileName();
18-
file2 = Path.GetTempFileName();
19-
}
20-
2114
public override void Dispose()
2215
{
2316
File.Delete(file1);
2417
File.Delete(file2);
2518
base.Dispose();
2619
}
2720

28-
string file1;
29-
string file2;
30-
}
21+
string file1 = Path.GetTempFileName();
22+
string file2 = Path.GetTempFileName();
23+
}

0 commit comments

Comments
 (0)