Fix hint-name collisions in SourceGenerator when two .refitter files share a filename#1058
Closed
christianhelle with Copilot wants to merge 2 commits into
Closed
Fix hint-name collisions in SourceGenerator when two .refitter files share a filename#1058christianhelle with Copilot wants to merge 2 commits into
christianhelle with Copilot wants to merge 2 commits into
Conversation
…share a filename - Replace filename-only hint name with full path-based disambiguation - Honor settings.OutputFilename when present - Remove dead `filename` variable - Add regression tests for hint-name uniqueness Agent-Logs-Url: https://github.com/christianhelle/refitter/sessions/cc94e817-e939-47bb-8be7-8bcc4353697f Co-authored-by: christianhelle <710400+christianhelle@users.noreply.github.com>
|
Copilot
AI
changed the title
[WIP] Fix hint-name collisions for .refitter files with same filename
Fix hint-name collisions in SourceGenerator when two .refitter files share a filename
Apr 18, 2026
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #1058 +/- ##
=======================================
Coverage 93.18% 93.18%
=======================================
Files 27 27
Lines 1804 1804
=======================================
Hits 1681 1681
Misses 49 49
Partials 74 74
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
christianhelle
added a commit
that referenced
this pull request
Apr 20, 2026
Closes #1058 Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.



Description:
Two
.refitterfiles with the same filename in different directories (e.g.src/ApiA/petstore.refitterandsrc/ApiB/petstore.refitter) both producedpetstore.g.csas the Roslyn hint name, causing the secondcontext.AddSource()call to throwArgumentException: hintName 'petstore.g.cs' was already addedand crash the analyzer for the entire build/IDE session. Thefilenamevariable computed fromsettings.OutputFilenamewas also dead code — never used in the hint name.src/Refitter.SourceGenerator/RefitterSourceGenerator.cssettings.OutputFilenameis set, use it directly as the hint name (previously ignored)src_ApiA_petstore.g.csvssrc_ApiB_petstore.g.csfilenamevariablesrc/Refitter.Tests/SourceGeneratorFileIOTests.csTest_HintName_IsUnique_For_SameFilename_InDifferentDirectories— regression test for the collision scenarioTest_HintName_UsesOutputFilename_WhenSpecified— verifiesOutputFilenameis honored as the hint nameExample hint name disambiguation
With
OutputFilenameset in the.refitterfile:{ "outputFilename": "PetstoreClient.g.cs" }→ hint name is
PetstoreClient.g.cs(previously this value was computed but discarded)Warning
Firewall rules blocked me from connecting to one or more addresses (expand for details)
I tried to connect to the following addresses, but was blocked by firewall rules:
collector.exceptionless.io/home/REDACTED/work/refitter/refitter/src/Refitter.Tests/bin/Release/net10.0/Refitter.Tests /home/REDACTED/work/refitter/refitter/src/Refitter.Tests/bin/Release/net10.0/Refitter.Tests(dns block)config.exceptionless.io/home/REDACTED/work/refitter/refitter/src/Refitter.Tests/bin/Release/net10.0/Refitter.Tests /home/REDACTED/work/refitter/refitter/src/Refitter.Tests/bin/Release/net10.0/Refitter.Tests(dns block)developers.intellihr.io/home/REDACTED/work/refitter/refitter/src/Refitter.Tests/bin/Release/net10.0/Refitter.Tests /home/REDACTED/work/refitter/refitter/src/Refitter.Tests/bin/Release/net10.0/Refitter.Tests(dns block)heartbeat.exceptionless.io/home/REDACTED/work/refitter/refitter/src/Refitter.Tests/bin/Release/net10.0/Refitter.Tests /home/REDACTED/work/refitter/refitter/src/Refitter.Tests/bin/Release/net10.0/Refitter.Tests(dns block)http://dc.services.visualstudio.com:443/christianhelle/refitter/main/test/OpenAPI/v3.0/petstore.json/usr/bin/dotnet dotnet build /home/REDACTED/work/refitter/refitter/src/Refitter.Tests/bin/Release/net10.0/f72145c88b6e4f4abfee9a141a882bf3/Project.csproj .Tests/bin/Releaowner(http block)/usr/bin/dotnet dotnet build /home/REDACTED/work/refitter/refitter/src/Refitter.Tests/bin/Release/net10.0/c0d2055ae257419d9a85e36805452f8a/Project.csproj git conf�� 8e7e3244358bc65fd8b4a55fe27/Project.csproj committer.email /snap/bin/sh ect.csproj(http block)http://dc.services.visualstudio.com:443/christianhelle/refitter/main/test/OpenAPI/v3.0/petstore.yaml/usr/bin/dotnet dotnet build /home/REDACTED/work/refitter/refitter/src/Refitter.Tests/bin/Release/net10.0/f72145c88b6e4f4abfee9a141a882bf3/Project.csproj .Tests/bin/Releaowner(http block)/usr/bin/dotnet dotnet build /home/REDACTED/work/refitter/refitter/src/Refitter.Tests/bin/Release/net10.0/c0d2055ae257419d9a85e36805452f8a/Project.csproj git conf�� 8e7e3244358bc65fd8b4a55fe27/Project.csproj committer.email /snap/bin/sh ect.csproj(http block)petstore.swagger.io/home/REDACTED/work/refitter/refitter/src/Refitter.Tests/bin/Release/net10.0/Refitter.Tests /home/REDACTED/work/refitter/refitter/src/Refitter.Tests/bin/Release/net10.0/Refitter.Tests(dns block)petstore3.swagger.io/home/REDACTED/work/refitter/refitter/src/Refitter.Tests/bin/Release/net10.0/Refitter.Tests /home/REDACTED/work/refitter/refitter/src/Refitter.Tests/bin/Release/net10.0/Refitter.Tests(dns block)If you need me to access, download, or install something from one of these locations, you can either: