Repository navigation
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 |
Updated [TUnit.Core](https://github.com/thomhurst/TUnit) from 1.68.17 to 1.72.16. <details> <summary>Release notes</summary> _Sourced from [TUnit.Core's releases](https://github.com/thomhurst/TUnit/releases)._ ## 1.72.16 <!-- Release notes generated using configuration in .github/release.yml at v1.72.16 --> ## What's Changed ### Other Changes * docs: add Moq, NSubstitute, and FakeItEasy migration guides for TUnit.Mocks by @thomhurst in thomhurst/TUnit#6951 ### Dependencies * chore(deps): update dependency azure.storage.blobs to 12.30.0 by @thomhurst in thomhurst/TUnit#6945 * chore(deps): update tunit to 1.72.10 by @thomhurst in thomhurst/TUnit#6946 * chore(deps): update dependency mockolate to 3.5.2 by @thomhurst in thomhurst/TUnit#6949 **Full Changelog**: thomhurst/TUnit@v1.72.10...v1.72.16 ## 1.72.10 <!-- Release notes generated using configuration in .github/release.yml at v1.72.10 --> ## What's Changed ### Other Changes * fix(source-gen): adapt ValueTask<T> test results by @zion-sati in thomhurst/TUnit#6930 ### Dependencies * chore(deps): update tunit to 1.72.4 by @thomhurst in thomhurst/TUnit#6941 * chore(deps): update aspire to 13.6.0 by @thomhurst in thomhurst/TUnit#6940 * chore(deps): update verify to 33.2.0 by @thomhurst in thomhurst/TUnit#6943 * chore(deps): update dependency awssdk.sqs to 4.0.100.15 by @thomhurst in thomhurst/TUnit#6944 ## New Contributors * @zion-sati made their first contribution in thomhurst/TUnit#6930 **Full Changelog**: thomhurst/TUnit@v1.72.4...v1.72.10 ## 1.72.4 <!-- Release notes generated using configuration in .github/release.yml at v1.72.4 --> ## What's Changed ### Other Changes * fix(source-gen): stop parameter resolver keeping every non-public test-class method (IL2111) by @thomhurst in thomhurst/TUnit#6937 ### Dependencies * chore(deps): update tunit to 1.72.0 by @thomhurst in thomhurst/TUnit#6934 **Full Changelog**: thomhurst/TUnit@v1.72.0...v1.72.4 ## 1.72.0 <!-- Release notes generated using configuration in .github/release.yml at v1.72.0 --> ## What's Changed ### Other Changes * perf(source-gen): resolve parameter reflection info through a shared runtime helper by @thomhurst in thomhurst/TUnit#6923 * perf(analyzers): trim remaining analyzer hot-path symbol lookups and binds by @thomhurst in thomhurst/TUnit#6928 * perf(mocks): move shared MockCall wrapper plumbing into runtime base classes by @thomhurst in thomhurst/TUnit#6929 * perf(source-gen): close incremental caching gaps in static property and property injection generators by @thomhurst in thomhurst/TUnit#6925 * perf(source-gen): stop InfrastructureGenerator pinning an old Compilation by @thomhurst in thomhurst/TUnit#6926 * perf(assertions-analyzers): cache assertion symbols and cut per-call work by @thomhurst in thomhurst/TUnit#6927 * perf(source-gen): emit hooks per class with direct, non-async bodies by @thomhurst in thomhurst/TUnit#6924 * test: fix flaky ObjectInitializer continuation-thread test by @thomhurst in thomhurst/TUnit#6932 * fix: CI flakes from leaked hook contexts, ActivityCollector race and Repro5700 rendezvous by @thomhurst in thomhurst/TUnit#6933 * fix(aspnetcore): honor WebApplicationFactoryClientOptions in CreateClient by @thomhurst in thomhurst/TUnit#6931 ### Dependencies * chore(deps): update tunit to 1.71.0 by @thomhurst in thomhurst/TUnit#6920 **Full Changelog**: thomhurst/TUnit@v1.71.0...v1.72.0 ## 1.71.0 <!-- Release notes generated using configuration in .github/release.yml at v1.71.0 --> ## What's Changed ### Other Changes * perf: lighter per-test trace bookkeeping for the HTML report (-12% allocations at 10k tests) by @thomhurst in thomhurst/TUnit#6910 * perf(html-report): parallel report serialization + optimized hot writers (-26% end-of-session time) by @thomhurst in thomhurst/TUnit#6911 * perf: emit source-generated test types after user code (Defender scan 5s → 0.2s at 10k tests) by @thomhurst in thomhurst/TUnit#6908 * perf(source-gen): bound generated test-entry methods (data-driven startup JIT -45%) by @thomhurst in thomhurst/TUnit#6909 * fix: avoid blocking waiting callers during IAsyncInitializer initialization by @Sing303 in thomhurst/TUnit#6906 * perf(analyzers): cut binding and symbol lookups in analyzer hot paths (TUnit.Analyzers -89% on TestProject) by @thomhurst in thomhurst/TUnit#6917 * fix(source-gen): model equality covers every emitted field; infrastructure refreshes on reference changes by @thomhurst in thomhurst/TUnit#6912 * perf(mocks): memoize generator discovery per compilation and decouple emitted source from call-site locations by @thomhurst in thomhurst/TUnit#6913 * fix(packaging): skip the source generator when disabled and replace the broken Polyfill injection by @thomhurst in thomhurst/TUnit#6915 * refactor(analyzers): address review feedback from #6917 by @thomhurst in thomhurst/TUnit#6919 * perf(source-gen): remove whole-compilation scans from static property, property injection and AOT converter generators by @thomhurst in thomhurst/TUnit#6914 * perf(assertions-source-gen): make assertion generators properly incremental by @thomhurst in thomhurst/TUnit#6916 * perf(source-gen): make TestMetadataGenerator pipeline values equatable by @thomhurst in thomhurst/TUnit#6918 ### Dependencies * chore(deps): update dependency polyfill to 11.4.1 by @thomhurst in thomhurst/TUnit#6900 * chore(deps): update dependency polyfill to 11.4.1 by @thomhurst in thomhurst/TUnit#6899 * chore(deps): update dependency tunit.aspire to 1.7* by @thomhurst in thomhurst/TUnit#6901 * chore(deps): update tunit to 1.7* by @thomhurst in thomhurst/TUnit#6902 * chore(deps): update dependency coverlet.collector to 10.1.0 by @thomhurst in thomhurst/TUnit#6905 * chore(deps): update dependency nunit to v5 by @thomhurst in thomhurst/TUnit#6903 **Full Changelog**: thomhurst/TUnit@v1.70.1...v1.71.0 ## 1.70.1 <!-- Release notes generated using configuration in .github/release.yml at v1.70.1 --> ## What's Changed ### Other Changes * fix: don't run DedicatedThreadExecutor continuations inline on the dedicated thread by @thomhurst in thomhurst/TUnit#6898 **Full Changelog**: thomhurst/TUnit@v1.70.0...v1.70.1 ## 1.70.0 <!-- Release notes generated using configuration in .github/release.yml at v1.70.0 --> ## What's Changed ### Other Changes * feat: clear parallel constraints and limiter during test registration by @thomhurst in thomhurst/TUnit#6897 * fix(mocks): emit valid lambdas for Task/ValueTask-returning delegate mocks by @thomhurst in thomhurst/TUnit#6896 ### Dependencies * chore(deps): update tunit to 1.69.24 by @thomhurst in thomhurst/TUnit#6893 **Full Changelog**: thomhurst/TUnit@v1.69.24...v1.70.0 ## 1.69.24 <!-- Release notes generated using configuration in .github/release.yml at v1.69.24 --> ## What's Changed ### Other Changes * fix: skip Ctrl+C handling where Console.CancelKeyPress is unsupported by @glennawatson in thomhurst/TUnit#6889 ### Dependencies * chore(deps): update verify to 33.1.5 by @thomhurst in thomhurst/TUnit#6891 * chore(deps): update tunit to 1.69.21 by @thomhurst in thomhurst/TUnit#6890 **Full Changelog**: thomhurst/TUnit@v1.69.21...v1.69.24 ## 1.69.21 <!-- Release notes generated using configuration in .github/release.yml at v1.69.21 --> ## What's Changed ### Other Changes * fix: preserve JUnit results after session cancellation by @Sing303 in thomhurst/TUnit#6882 * feat: warn when setup hooks pass the test execution token by @Sing303 in thomhurst/TUnit#6883 * fix: complete DedicatedThreadExecutor tests only after CleanUp() returns by @glennawatson in thomhurst/TUnit#6886 ### Dependencies * chore(deps): update tunit to 1.69.16 by @thomhurst in thomhurst/TUnit#6881 ## New Contributors * @glennawatson made their first contribution in thomhurst/TUnit#6886 **Full Changelog**: thomhurst/TUnit@v1.69.16...v1.69.21 ## 1.69.16 <!-- Release notes generated using configuration in .github/release.yml at v1.69.16 --> ## What's Changed ### Other Changes * fix: preserve TRX results when session cleanup fails by @Sing303 in thomhurst/TUnit#6879 ### Dependencies * chore(deps): update tunit to 1.69.0 by @thomhurst in thomhurst/TUnit#6864 * chore(deps): update dependency messagepack to 3.1.10 by @thomhurst in thomhurst/TUnit#6866 * chore(deps): update dependency dompurify to v3.4.16 by @thomhurst in thomhurst/TUnit#6867 * chore(deps): update dependency serialize-javascript to v7.1.2 by @thomhurst in thomhurst/TUnit#6868 * chore(deps): update dependency azure.data.tables to 12.13.0 by @thomhurst in thomhurst/TUnit#6870 * chore(deps): update dependency microsoft.playwright to 1.63.0 by @thomhurst in thomhurst/TUnit#6871 * chore(deps): update verify to 33.1.2 by @thomhurst in thomhurst/TUnit#6872 * chore(deps): update dependency verify.tool to v0.9.2 by @thomhurst in thomhurst/TUnit#6873 * chore(deps): update verify to 33.1.3 by @thomhurst in thomhurst/TUnit#6874 * chore(deps): update verify to 33.1.4 by @thomhurst in thomhurst/TUnit#6876 * chore(deps): update dependency moq to 4.21.0 by @thomhurst in thomhurst/TUnit#6877 * chore(deps): bump image-size from 2.0.2 to 2.0.4 in /docs by @dependabot[bot] in thomhurst/TUnit#6878 ## New Contributors * @Sing303 made their first contribution in thomhurst/TUnit#6879 **Full Changelog**: thomhurst/TUnit@v1.69.0...v1.69.16 ## 1.69.0 <!-- Release notes generated using configuration in .github/release.yml at v1.69.0 --> ## What's Changed ### Other Changes * feat(templates): add enableDotCover flag (#6714) by @ForNeVeR in thomhurst/TUnit#6844 * fix: don't request semantic models for attribute syntax from other compilations (DevKit crash) by @thomhurst in thomhurst/TUnit#6855 * fix(ci): restore net472 PublicAPI tests on Windows by @thomhurst in thomhurst/TUnit#6857 * perf(html-report): stream report JSON through pooled chunks and overlap sidecar serialization by @thomhurst in thomhurst/TUnit#6860 * chore(renovate): cap Microsoft.Build packages below 18.10.0 by @thomhurst in thomhurst/TUnit#6863 * perf: shrink generated per-class test source static constructors (~40% less startup JIT) by @thomhurst in thomhurst/TUnit#6859 * refactor: remove unreachable decimal source-text path from GenerateAttributeInstantiation by @thomhurst in thomhurst/TUnit#6856 * perf: cut per-test allocations in discovery and execution (-61% at 10k tests) by @thomhurst in thomhurst/TUnit#6861 * perf: stop hashing per-test event receivers during registration (data-driven tests 2.9x faster at 10k) by @thomhurst in thomhurst/TUnit#6858 * perf(analyzers): cut TUnit analyzer build time ~60% on large test projects by @thomhurst in thomhurst/TUnit#6862 ### Dependencies * chore(deps): update opentelemetry to 1.19.0 by @thomhurst in thomhurst/TUnit#6838 * chore(deps): update dependency opentelemetry.instrumentation.runtime to 1.19.0 by @thomhurst in thomhurst/TUnit#6840 * chore(deps): update tunit to 1.68.17 by @thomhurst in thomhurst/TUnit#6839 * chore(deps): update verify to 33.1.0 by @thomhurst in thomhurst/TUnit#6843 * chore(deps): update verify to 33.1.1 by @thomhurst in thomhurst/TUnit#6847 * chore(deps): update opentelemetry to 1.19.1 by @thomhurst in thomhurst/TUnit#6850 * chore(deps): update dependency grpc.core.api to 2.84.0 by @thomhurst in thomhurst/TUnit#6851 * chore(deps): update dependency stackexchange.redis to 3.3.1 by @thomhurst in thomhurst/TUnit#6853 * chore(deps): update dependency polyfill to 11.4.0 by @thomhurst in thomhurst/TUnit#6841 * chore(deps): update dependency polyfill to 11.4.0 by @thomhurst in thomhurst/TUnit#6842 ## New Contributors * @ForNeVeR made their first contribution in thomhurst/TUnit#6844 **Full Changelog**: thomhurst/TUnit@v1.68.17...v1.69.0 Commits viewable in [compare view](thomhurst/TUnit@v1.68.17...v1.72.16). </details> [](https://docs.github.com/en/github/managing-security-vulnerabilities/about-dependabot-security-updates#about-compatibility-scores) Dependabot will resolve any conflicts with this PR as long as you don't alter it yourself. You can also trigger a rebase manually by commenting `@dependabot rebase`. [//]: # (dependabot-automerge-start) [//]: # (dependabot-automerge-end) --- <details> <summary>Dependabot commands and options</summary> <br /> You can trigger Dependabot actions by commenting on this PR: - `@dependabot rebase` will rebase this PR - `@dependabot recreate` will recreate this PR, overwriting any edits that have been made to it - `@dependabot show <dependency name> ignore conditions` will show all of the ignore conditions of the specified dependency - `@dependabot ignore this major version` will close this PR and stop Dependabot creating any more for this major version (unless you reopen the PR or upgrade to it yourself) - `@dependabot ignore this minor version` will close this PR and stop Dependabot creating any more for this minor version (unless you reopen the PR or upgrade to it yourself) - `@dependabot ignore this dependency` will close this PR and stop Dependabot creating any more for this dependency (unless you reopen the PR or upgrade to it yourself) </details> Signed-off-by: dependabot[bot] <support@github.com> Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
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.