Fix Source Generator not emitting any files#1143
Conversation
📝 WalkthroughWalkthrough
ChangesSource Generator On-Disk Output Pivot
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~25 minutes Possibly related PRs
Suggested labels
🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
|
There was a problem hiding this comment.
Actionable comments posted: 1
Caution
Some comments are outside the diff and can’t be posted inline due to platform limitations.
⚠️ Outside diff range comments (2)
src/Refitter.SourceGenerator/README.md (2)
62-64:⚠️ Potential issue | 🟡 Minor | ⚡ Quick winFix the
.refitterexample punctuation.The
outputFolderline is missing a trailing comma beforeoutputFilename, which makes the example malformed for copy/paste use.🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the rest with a brief reason, keep changes minimal, and validate. In `@src/Refitter.SourceGenerator/README.md` around lines 62 - 64, The `.refitter` example in the README has invalid JSON syntax where the outputFolder property is missing a trailing comma after the value. Add a comma immediately after the outputFolder value (after the closing quote of "../CustomOutput") to make the JSON valid and ready for copy/paste use. The comment about the optional default can remain on the same line after the comma.
63-63:⚠️ Potential issue | 🟠 Major | ⚡ Quick win
outputFilenamedefault in docs does not match generator behavior.The README says
.refitterdefaults toPetstore.cs, but implementation currently defaults to<refitter-name>.g.cs(seesrc/Refitter.SourceGenerator/RefitterSourceGenerator.cs, Line 121). Please align both locations to the real default to avoid configuration mistakes.Suggested doc fix
- "outputFilename": "RefitInterface.cs", // Optional. Default=Output.cs for CLI tool + "outputFilename": "RefitInterface.g.cs", // Optional. Default=Output.cs for CLI tool, otherwise <.refitter filename>.g.cs for source generator-- `outputFilename` - Output filename. Default is `Output.cs` when used from the CLI tool, otherwise its the .refitter filename. So `Petstore.refitter` becomes `Petstore.cs`. +- `outputFilename` - Output filename. Default is `Output.cs` when used from the CLI tool, otherwise it's the `.refitter` filename with `.g.cs`. So `Petstore.refitter` becomes `Petstore.g.cs`.Also applies to: 191-191
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the rest with a brief reason, keep changes minimal, and validate. In `@src/Refitter.SourceGenerator/README.md` at line 63, The README.md documentation incorrectly states that the default outputFilename is "Output.cs" (at line 63) and likely has the same outdated information at line 191, but the actual implementation in RefitterSourceGenerator.cs defaults to "<refitter-name>.g.cs". Update both documentation locations in the README to correctly reflect the actual default value used by the generator, replacing references to "Output.cs" or incorrect defaults with the correct pattern "<refitter-name>.g.cs" to ensure users have accurate configuration information.
🧹 Nitpick comments (1)
src/Refitter.SourceGenerator.Tests/SourceGeneratorFileIOTests.cs (1)
40-40: ⚡ Quick winRename public test methods to PascalCase without underscores.
These public method names violate the project C# naming rule for public members.
As per coding guidelines, “Use PascalCase for public members, camelCase for parameters and local variables.”Suggested renames
-public async Task Test_CoreGenerator_DoesNotWriteToFileSystem() +public async Task TestCoreGeneratorDoesNotWriteToFileSystem() -public async Task Test_CoreGenerator_ConcurrentGeneration() +public async Task TestCoreGeneratorConcurrentGeneration() -public async Task Test_CoreGenerator_GeneratedCodeIsValid() +public async Task TestCoreGeneratorGeneratedCodeIsValid() -public async Task Test_CoreGenerator_OutputFilename_NotCreatedOnDisk() +public async Task TestCoreGeneratorOutputFilenameNotCreatedOnDisk()Also applies to: 67-67, 92-92, 114-114
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the rest with a brief reason, keep changes minimal, and validate. In `@src/Refitter.SourceGenerator.Tests/SourceGeneratorFileIOTests.cs` at line 40, Rename the public test methods in SourceGeneratorFileIOTests.cs from snake_case to PascalCase to comply with C# naming conventions. At line 40, rename Test_CoreGenerator_DoesNotWriteToFileSystem to TestCoreGeneratorDoesNotWriteToFileSystem. At line 67, rename the test method there to PascalCase (removing underscores). At line 92, rename the test method there to PascalCase (removing underscores). At line 114, rename the test method there to PascalCase (removing underscores). Ensure all public test method names follow PascalCase convention without underscores as separators.Source: Coding guidelines
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Inline comments:
In `@src/Refitter.SourceGenerator/README.md`:
- Around line 7-9: Remove the informal parenthetical note "(Translation: I
couldn't for the life of me figure how to get that to work, sorry)" from the
README.md file as it detracts from the professional tone of the documentation.
Simply delete this entire line to maintain a more polished and professional
appearance in the user-facing documentation.
---
Outside diff comments:
In `@src/Refitter.SourceGenerator/README.md`:
- Around line 62-64: The `.refitter` example in the README has invalid JSON
syntax where the outputFolder property is missing a trailing comma after the
value. Add a comma immediately after the outputFolder value (after the closing
quote of "../CustomOutput") to make the JSON valid and ready for copy/paste use.
The comment about the optional default can remain on the same line after the
comma.
- Line 63: The README.md documentation incorrectly states that the default
outputFilename is "Output.cs" (at line 63) and likely has the same outdated
information at line 191, but the actual implementation in
RefitterSourceGenerator.cs defaults to "<refitter-name>.g.cs". Update both
documentation locations in the README to correctly reflect the actual default
value used by the generator, replacing references to "Output.cs" or incorrect
defaults with the correct pattern "<refitter-name>.g.cs" to ensure users have
accurate configuration information.
---
Nitpick comments:
In `@src/Refitter.SourceGenerator.Tests/SourceGeneratorFileIOTests.cs`:
- Line 40: Rename the public test methods in SourceGeneratorFileIOTests.cs from
snake_case to PascalCase to comply with C# naming conventions. At line 40,
rename Test_CoreGenerator_DoesNotWriteToFileSystem to
TestCoreGeneratorDoesNotWriteToFileSystem. At line 67, rename the test method
there to PascalCase (removing underscores). At line 92, rename the test method
there to PascalCase (removing underscores). At line 114, rename the test method
there to PascalCase (removing underscores). Ensure all public test method names
follow PascalCase convention without underscores as separators.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: defaults
Review profile: CHILL
Plan: Pro
Run ID: 513e2f4d-06e1-4a54-8ac2-081834f199e3
⛔ Files ignored due to path filters (9)
src/Refitter.SourceGenerator.Tests/AdditionalFiles/Generated/.g.csis excluded by!**/generated/**src/Refitter.SourceGenerator.Tests/AdditionalFiles/Generated/PropertyNamingPolicy.g.csis excluded by!**/generated/**src/Refitter.SourceGenerator.Tests/AdditionalFiles/Generated/SwaggerPetstoreMultipleInterfaces.g.csis excluded by!**/generated/**src/Refitter.SourceGenerator.Tests/AdditionalFiles/Generated/SwaggerPetstoreMultipleInterfacesByTag.g.csis excluded by!**/generated/**src/Refitter.SourceGenerator.Tests/AdditionalFiles/Generated/SwaggerPetstoreOptionalParameters.g.csis excluded by!**/generated/**src/Refitter.SourceGenerator.Tests/AdditionalFiles/Generated/SwaggerPetstoreSingleInterfaceWithHttpResilience.g.csis excluded by!**/generated/**src/Refitter.SourceGenerator.Tests/AdditionalFiles/Generated/SwaggerPetstoreSingleInterfaceWithPolly.g.csis excluded by!**/generated/**src/Refitter.SourceGenerator.Tests/AdditionalFiles/Generated/UseJsonInheritanceConverter.g.csis excluded by!**/generated/**src/Refitter.SourceGenerator.Tests/AdditionalFiles/Generated/UsePolymorphicSerialization.g.csis excluded by!**/generated/**
📒 Files selected for processing (5)
src/Refitter.SourceGenerator.Tests/CustomGenerated/CustomGenerated.cssrc/Refitter.SourceGenerator.Tests/SourceGeneratorFileIOTests.cssrc/Refitter.SourceGenerator/README.mdsrc/Refitter.SourceGenerator/RefitterSourceGenerator.cstest/SourceGenerator/Directory.Build.props
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #1143 +/- ##
=======================================
Coverage 94.31% 94.31%
=======================================
Files 48 48
Lines 2796 2796
=======================================
Hits 2637 2637
Misses 53 53
Partials 106 106
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|



This pull request updates the Refitter source generator test suite and documentation to reflect the current behavior of file generation, and adds a new custom-generated API interface for testing. The most notable changes are the addition of a comprehensive generated interface for test purposes, updates to test naming and comments for clarity, and a significant change in the documentation to describe the actual file output behavior of the source generator.
Test suite improvements and refactoring:
SourceGeneratorFileIOTests.csfromTest_SourceGenerator_*toTest_CoreGenerator_*for consistency and clarity, and removed outdated comments referencing RoslynAddSource()and file I/O expectations. The tests now clearly assert that the core generator should not write files to disk, aligning with the current generator's responsibilities. [1] [2] [3] [4] [5]Documentation update:
README.mdto state that the Refitter source generator now writes generated files to aGeneratedfolder on disk, which should be committed to source control, instead of emitting code only in-memory via RoslynAddSource(). The documentation now matches the actual implementation and clarifies the rationale for this approach.Test asset addition:
IApiInCustomGeneratedFolderinCustomGenerated.csfor use in source generator tests. This interface includes a wide range of RESTful operations and serves as a comprehensive test asset.Summary by CodeRabbit
Documentation
Generatedfolder instead of in-memory generation.Tests
Chores