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
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
<PackageReference Include="Microsoft.Extensions.Http.Resilience" Version="10.1.0" />
<PackageReference Include="FluentAssertions" Version="7.2.0" />
<PackageReference Include="System.Text.Json" Version="10.0.1" />
<PackageReference Include="TUnit" Version="1.9.2" />
<PackageReference Include="TUnit" Version="1.11.28" />
<PackageReference Include="coverlet.collector" Version="6.0.4">
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
<PrivateAssets>all</PrivateAssets>
Expand Down
13 changes: 12 additions & 1 deletion src/Refitter.Tests/Build/BuildHelper.cs
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,8 @@ public static class BuildHelper
{
public static bool BuildCSharp(params string[] generatedCode)
{
var path = Path.Combine(Directory.GetCurrentDirectory(), Guid.NewGuid().ToString("N"));
var folder = Path.GetDirectoryName(typeof(BuildHelper).Assembly.Location) ?? Path.GetTempPath();
var path = Path.Combine(folder, Guid.NewGuid().ToString("N"));
Directory.CreateDirectory(path);
var projectFile = Path.Combine(path, "Project.csproj");
File.WriteAllText(projectFile, ProjectFileContents.Net80App);
Expand Down Expand Up @@ -38,9 +39,19 @@ public static bool BuildCSharp(params string[] generatedCode)
process.WaitForExit();

var result = startResult && process.ExitCode == 0;

if (!result)
throw new BuildFailedException(errors.ToString(), output.ToString());

try
{
Directory.Delete(path, true);
}
catch
{
// Ignore cleanup errors
}

return result;
}

Expand Down
1 change: 1 addition & 0 deletions src/Refitter.Tests/Build/ProjectFileContents.cs
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ public static class ProjectFileContents
<GenerateDocumentationFile>true</GenerateDocumentationFile>
</PropertyGroup>
<ItemGroup>
<PackageReference Include=""Refit.HttpClientFactory"" Version=""8.0.0"" />

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue | 🟠 Major

🧩 Analysis chain

🏁 Script executed:

#!/bin/bash
# Find all Refit.HttpClientFactory references with version info
rg "Refit\.HttpClientFactory.*Version" --type=xml -B2 -A2

Repository: christianhelle/refitter

Length of output: 49


🏁 Script executed:

#!/bin/bash
# Broader search for all Refit.HttpClientFactory references
rg "Refit\.HttpClientFactory" -A1 -B1

# Also check the specific files mentioned
echo "=== ProjectFileContents.cs ==="
cat -n src/Refitter.Tests/Build/ProjectFileContents.cs

echo "=== Refitter.SourceGenerator.Tests.csproj ==="
rg "Refit\.HttpClientFactory" src/Refitter.SourceGenerator.Tests.csproj -A1 -B1

Repository: christianhelle/refitter

Length of output: 6271


🏁 Script executed:

#!/bin/bash
# Check the pattern of package versions in ProjectFileContents.cs to see if they're intentionally pinned to net8.0
echo "=== All packages in embedded project (net8.0) ==="
cat -n src/Refitter.Tests/Build/ProjectFileContents.cs | grep -A 30 "Net80App"

# Check if there are comments explaining version choice
echo "=== Check for version-related comments in file ==="
rg -i "version|8\.0\.|9\.0\." src/Refitter.Tests/Build/ProjectFileContents.cs -B2 -A2

# Verify Refit.HttpClientFactory compatibility - check if 9.0.2 supports net8.0
echo "=== Check git history for this change ==="
git log --oneline -n 20 -- src/Refitter.Tests/Build/ProjectFileContents.cs

Repository: christianhelle/refitter

Length of output: 3717


Update Refit.HttpClientFactory to version 9.0.2 for consistency.

Adding Refit.HttpClientFactory to the embedded project template is good for verifying generated code compiles. However, version 8.0.0 creates an inconsistency: all test projects and examples (MinimalApi, MSBuild, MauiExample, MultipleFiles, ConsoleApp, and SourceGenerator.Tests) use version 9.0.2. The embedded template should match to ensure generated code is tested against the same version used across the test suite. Change to Version="9.0.2".

🤖 Prompt for AI Agents
In `@src/Refitter.Tests/Build/ProjectFileContents.cs` at line 12, Update the
embedded project template in ProjectFileContents (the string containing the
PackageReference) so the Refit.HttpClientFactory PackageReference line uses
Version="9.0.2" instead of "8.0.0"; locate the PackageReference entry for
"Refit.HttpClientFactory" in the ProjectFileContents constant and change the
Version attribute to 9.0.2 to match the rest of the test projects.

<PackageReference Include=""System.Text.Json"" Version=""8.0.5"" />
<PackageReference Include=""System.ComponentModel.Annotations"" Version=""4.5.0"" />
<PackageReference Include=""System.Runtime.Serialization.Primitives"" Version=""4.3.0"" />
Expand Down
2 changes: 1 addition & 1 deletion src/Refitter.Tests/Refitter.Tests.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
<ItemGroup>
<PackageReference Include="FluentAssertions" Version="7.2.0" />
<PackageReference Include="System.Text.Json" Version="10.0.1" />
<PackageReference Include="TUnit" Version="1.9.2" />
<PackageReference Include="TUnit" Version="1.11.28" />
<PackageReference Include="coverlet.collector" Version="6.0.4">
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
<PrivateAssets>all</PrivateAssets>
Expand Down
5 changes: 5 additions & 0 deletions src/Refitter.Tests/SwaggerPetstoreTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -584,6 +584,11 @@ public async Task Can_Build_Generated_Code_With_IApiResponse(SampleOpenSpecifica

[Test]
[Arguments(SampleOpenSpecifications.SwaggerPetstoreJsonV3, "SwaggerPetstore.json")]
#if !DEBUG
[Arguments(SampleOpenSpecifications.SwaggerPetstoreYamlV3, "SwaggerPetstore.yaml")]
[Arguments(SampleOpenSpecifications.SwaggerPetstoreJsonV2, "SwaggerPetstore.json")]
[Arguments(SampleOpenSpecifications.SwaggerPetstoreYamlV2, "SwaggerPetstore.yaml")]
#endif
public async Task Can_Build_Generated_Code_With_IObservableResponse(SampleOpenSpecifications version, string filename)
{
var settings = new RefitGeneratorSettings();
Expand Down
5 changes: 3 additions & 2 deletions src/Refitter.Tests/WriteRefitterSettingsFileTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,8 @@ public void DetermineSettingsFilePath_Returns_Default_When_Output_Path_Is_Null()
public async Task WriteRefitterSettingsFile_Creates_File_With_Default_Path()
{
// Arrange
var tempDir = Path.Combine(Path.GetTempPath(), Guid.NewGuid().ToString());
var folder = Path.GetDirectoryName(GetType().Assembly.Location) ?? Path.GetTempPath();
var tempDir = Path.Combine(folder, Guid.NewGuid().ToString());
Comment on lines +116 to +117

Copilot AI Jan 15, 2026

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Only one test method in this file has been updated to use the assembly location pattern, but there are five other test methods (starting at lines 160, 199, 241, 288, and 337) that still use Path.GetTempPath() directly. For consistency and to fully address parallel execution issues, all tests that create temporary directories in this file should use the same pattern: Path.GetDirectoryName(GetType().Assembly.Location) ?? Path.GetTempPath().

Copilot uses AI. Check for mistakes.
Directory.CreateDirectory(tempDir);
var originalDir = Directory.GetCurrentDirectory();

Expand Down Expand Up @@ -268,7 +269,7 @@ public async Task WriteRefitterSettingsFile_Creates_File_When_ContractsOutputPat

var content = await File.ReadAllTextAsync(settingsFile);
content.Should().Contain("ContractsNamespace");

// Verify the deserialized settings contain the correct contracts path
var deserializedSettings = Serializer.Deserialize<RefitGeneratorSettings>(content);
deserializedSettings.ContractsOutputFolder.Should().Be(contractsDir);
Expand Down
Loading