Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -8,3 +8,4 @@ obj/
*.received.*
nugets/
.claude/settings.local.json
nul
18 changes: 18 additions & 0 deletions src/DiffEngine.AotTests/DiffEngine.AotTests.csproj
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<OutputType>Exe</OutputType>
<TargetFramework>net9.0</TargetFramework>
<ImplicitUsings>enable</ImplicitUsings>
<PublishAot>true</PublishAot>
<PublishTrimmed>true</PublishTrimmed>
<InvariantGlobalization>true</InvariantGlobalization>
<!-- Default RID for AOT publish; override with -r flag if needed -->
<RuntimeIdentifier Condition="'$(RuntimeIdentifier)' == '' and '$(PublishAot)' == 'true'">win-x64</RuntimeIdentifier>
</PropertyGroup>

<ItemGroup>
<ProjectReference Include="..\DiffEngine\DiffEngine.csproj" />
</ItemGroup>

</Project>
1 change: 1 addition & 0 deletions src/DiffEngine.AotTests/GlobalUsings.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
global using DiffEngine;
58 changes: 58 additions & 0 deletions src/DiffEngine.AotTests/Program.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
public static class Program
{
public static int Main()
{
try
{
TestDiffToolsAccess();
TestDefinitionsAccess();
TestToolResolution();

Console.WriteLine("All DiffEngine AOT tests passed!");
return 0;
}
catch (Exception ex)
{
Console.Error.WriteLine($"Test failed: {ex}");
return 1;
}
}

static void TestDiffToolsAccess()
{
// Test that we can access DiffTools static properties without reflection issues
var isDetected = DiffTools.IsDetectedForExtension(DiffTool.VisualStudioCode, "txt");
Console.WriteLine($"DiffTools.IsDetectedForExtension(VSCode, 'txt'): {isDetected}");

var allTools = DiffTools.Resolved.ToList();
Console.WriteLine($"DiffTools.Resolved count: {allTools.Count}");
}

static void TestDefinitionsAccess()
{
// Test that tool definitions can be accessed
var definitions = Definitions.Tools.ToList();
Console.WriteLine($"Definitions.Tools count: {definitions.Count}");

foreach (var def in definitions.Take(3))
{
Console.WriteLine($" Tool: {def.Tool}, Url: {def.Url}");
}
}

static void TestToolResolution()
{
// Test tool resolution
var found = DiffTools.TryFindByExtension("txt", out var resolved);
Console.WriteLine($"TryFindByExtension('txt'): found={found}");

if (found && resolved != null)
{
Console.WriteLine($" Resolved tool: {resolved.Tool}");
}

// Test by name
var foundByName = DiffTools.TryFindByName(DiffTool.VisualStudioCode, out _);
Console.WriteLine($"TryFindByName(VisualStudioCode): found={foundByName}");
}
}
3 changes: 3 additions & 0 deletions src/DiffEngine.slnx
Original file line number Diff line number Diff line change
Expand Up @@ -33,4 +33,7 @@
<Project Path="FakeDiffTool/FakeDiffTool.csproj">
<BuildType Solution="Release-NotWindows|*" Project="Release" />
</Project>
<Project Path="DiffEngine.AotTests/DiffEngine.AotTests.csproj">
<BuildType Solution="Release-NotWindows|*" Project="Release" />
</Project>
</Solution>
1 change: 1 addition & 0 deletions src/DiffEngine/DiffEngine.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
<TargetFrameworks Condition=" '$(OS)' == 'Windows_NT'">net462;net472;net48;net9.0;net10.0</TargetFrameworks>
<TargetFrameworks>$(TargetFrameworks);net6.0;net7.0;net8.0;net9.0;net10.0</TargetFrameworks>
<AllowUnsafeBlocks Condition="$([MSBuild]::IsTargetFrameworkCompatible('$(TargetFramework)', 'net7.0'))">true</AllowUnsafeBlocks>
<IsAotCompatible Condition="$([MSBuild]::IsTargetFrameworkCompatible('$(TargetFramework)', 'net7.0'))">true</IsAotCompatible>
</PropertyGroup>
<ItemGroup>
<Using Include="DiffEngine" />
Expand Down
4 changes: 1 addition & 3 deletions src/DiffEngine/OrderReader.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,7 @@
{
public record Result(bool UsedToolOrderEnvVar, IEnumerable<DiffTool> Order);

static Result defaultResult = new(false, Enum
.GetValues(typeof(DiffTool))
.Cast<DiffTool>());
static Result defaultResult = new(false, Enum.GetValues<DiffTool>());

public static Result ReadToolOrder()
{
Expand Down