fix(source-gen): adapt ValueTask<T> test results - #6930
Conversation
|
Navigate logical layers of code changes, visualize relationships, and explore their blast radius. Important Review skippedReview was skipped as selected files did not have any reviewable changes. ⚙️ Run configurationConfiguration used: Organization UI Review profile: CHILL Plan: Advanced Run ID: You can disable this status message by setting the Use the checkbox below for a quick retry:
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Organization UI Review profile: CHILL Plan: Advanced Run ID: 📒 Files selected for processing (6)
Included review availability: This review used your included allowance. Your plan provides up to 8 included reviews per hour; 7 remain after this review. 📝 WalkthroughWalkthroughThe source generator now distinguishes ChangesValueTask return handling
Priority: ⬇️ Low Estimated code review effort: 2 (Simple) | ~10 minutes Change: Bug fix Merge Risk: ⚪ Minimal · up to The change fixes generated invokers for ValueTask tests without changing bare ValueTask handling. No actionable merge-blocking risk remains; merge after normal checks pass. 🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
Full details: Docstring CoverageExplanation Docstring coverage is 11.11% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 9 functions across 4 files. (4 skipped: 4 unsupported.) ✨ Finishing Touches🧪 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. I’m a rabbit with a task to run, Comment |
ReviewThe fix is correct and minimal. I did not build or run the tests, and the Suggestions, none of them blocking:
Overall this looks good to merge once (3) is confirmed. |
|
|
@zion-sati Can we just add more validation in the analyzer to prevent users from defining test methods like this? |
|
Actually I'm fine with this since we support a similar pattern for Task |
7014edf to
c73655f
Compare
|
Review: LGTM. The fix is correct and minimal. I could not run the Minor, non-blocking points:
Thanks for the fix and the regression coverage. |
c73655f to
410b69b
Compare
|
Review: LGTM, with one optional suggestion. The fix is correct. The regression tests cover an ordinary method and a generic method, with snapshots for all four TFMs. The TestProject tests actually execute both paths, which is what you want. Optional suggestion: allocation on the hot path. Nothing else to flag. |
|
Thanks @zion-sati |
Generated test invokers return a non-generic
ValueTask, but the source generator currently classifiesValueTask<T>as the same return shape and emits it directly. The generated project then fails to compile becauseValueTask<T>cannot be returned asValueTask.Split the two return patterns and adapt
ValueTask<T>through its underlying task. The regression covers ordinary and generic generated test methods, updates snapshots for every supported target framework, and executes both paths.This was found while porting TUnit to NetWasm, a C# to WebAssembly compiler.
Validation:
dotnet test tests/TUnit.Core.SourceGenerator.Tests/TUnit.Core.SourceGenerator.Tests.csproj -f net10.0 --treenode-filter '/*/*/BasicTests/Test'dotnet test tests/TUnit.TestProject/TUnit.TestProject.csproj -f net10.0 --treenode-filter '/*/*/BasicTests/*'dotnet test tests/TUnit.TestProject/TUnit.TestProject.csproj -f net10.0 --treenode-filter '/*/*/BasicTests/*' -- --reflectionThe only other
ValueTaskprefix classification in the core generator selects generic data-source factories and is intentionally generic.Summary by CodeRabbit
ValueTask<T>are now invoked correctly, including generic test methods.