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](https://github.com/thomhurst/TUnit) from 1.70.1 to 1.74.0. <details> <summary>Release notes</summary> _Sourced from [TUnit's releases](https://github.com/thomhurst/TUnit/releases)._ ## 1.74.0 <!-- Release notes generated using configuration in .github/release.yml at v1.74.0 --> ## What's Changed ### Other Changes * fix(mocks): eliminate trim/AOT warnings on Native AOT publish by @thomhurst in thomhurst/TUnit#7029 * feat(engine): raise thread pool minimum when blocking tests starve the pool by @thomhurst in thomhurst/TUnit#7030 * feat(mocks): add ClearCalls, PassThrough toggle and string/type/reference matchers by @Quattordici in thomhurst/TUnit#7018 ### Dependencies * chore(deps): update tunit to 1.73.19 by @thomhurst in thomhurst/TUnit#7008 * chore(deps): update dependency imposter to 0.2.5 by @thomhurst in thomhurst/TUnit#7010 * chore(deps): update dependency mockolate to 3.6.0 by @thomhurst in thomhurst/TUnit#7011 * chore(deps): update dependency imposter to 0.2.6 by @thomhurst in thomhurst/TUnit#7012 * chore(deps): update dependency stackexchange.redis to 3.4.0 by @thomhurst in thomhurst/TUnit#7013 * chore(deps): update xunit by @thomhurst in thomhurst/TUnit#7014 * chore(deps): update dependency imposter to 0.2.7 by @thomhurst in thomhurst/TUnit#7016 * chore(deps): update dependency nunit3testadapter to 6.3.1 by @thomhurst in thomhurst/TUnit#7015 * chore(deps): update verify to 33.3.3 by @thomhurst in thomhurst/TUnit#7019 * chore(deps): update dependency imposter to 0.2.8 by @thomhurst in thomhurst/TUnit#7020 * chore(deps): update dependency imposter to 0.2.10 by @thomhurst in thomhurst/TUnit#7021 * chore(deps): update dependency fluentvalidation.dependencyinjectionextensions to 12.2.0 by @thomhurst in thomhurst/TUnit#7022 * chore(deps): update dependency imposter to 0.2.11 by @thomhurst in thomhurst/TUnit#7023 * chore(deps): update dependency imposter to 0.2.12 by @thomhurst in thomhurst/TUnit#7024 * chore(deps): update dependency imposter to 0.2.14 by @thomhurst in thomhurst/TUnit#7025 * chore(deps): update dependency imposter to 0.2.17 by @thomhurst in thomhurst/TUnit#7031 **Full Changelog**: thomhurst/TUnit@v1.73.19...v1.74.0 ## 1.73.19 <!-- Release notes generated using configuration in .github/release.yml at v1.73.19 --> ## What's Changed ### Other Changes * fix(fscheck): apply Verbose, QuietOnSuccess and Parallelism; validate Replay by @JesseKlaasse in thomhurst/TUnit#7001 ### Dependencies * chore(deps): update microsoft.testing to 2.5.1 by @thomhurst in thomhurst/TUnit#6990 * chore(deps): update dependency dotnet-trace to v10.0.750501 by @thomhurst in thomhurst/TUnit#6995 * chore(deps): update tunit to 1.73.5 by @thomhurst in thomhurst/TUnit#6996 * chore(deps): update verify to 33.3.2 by @thomhurst in thomhurst/TUnit#6997 * chore(deps): update actions/setup-node action to v7.1.0 by @thomhurst in thomhurst/TUnit#6999 * chore(deps): update dependency imposter to 0.2.3 by @thomhurst in thomhurst/TUnit#7000 * chore(deps): update dependency testcontainers.kafka to 4.16.0 by @thomhurst in thomhurst/TUnit#7002 * chore(deps): update dependency imposter to 0.2.4 by @thomhurst in thomhurst/TUnit#7004 * chore(deps): update dependency testcontainers.postgresql to 4.16.0 by @thomhurst in thomhurst/TUnit#7003 * chore(deps): update dependency awssdk.sqs to 4.0.100.16 by @thomhurst in thomhurst/TUnit#7007 * chore(deps): update dependency testcontainers.redis to 4.16.0 by @thomhurst in thomhurst/TUnit#7005 ## New Contributors * @JesseKlaasse made their first contribution in thomhurst/TUnit#7001 **Full Changelog**: thomhurst/TUnit@v1.73.5...v1.73.19 ## 1.73.5 <!-- Release notes generated using configuration in .github/release.yml at v1.73.5 --> ## What's Changed ### Other Changes * fix: Ignore default start timestamps in HTML report by @SnakyBeaky in thomhurst/TUnit#6942 * fix(playwright): send trace context headers only to origins under test by @thomhurst in thomhurst/TUnit#6993 ### Dependencies * chore(deps): update dependency imposter to 0.2.2 by @thomhurst in thomhurst/TUnit#6988 * chore(deps): update tunit to 1.73.0 by @thomhurst in thomhurst/TUnit#6989 * chore(deps): update mstest to 4.5.1 by @thomhurst in thomhurst/TUnit#6991 **Full Changelog**: thomhurst/TUnit@v1.73.0...v1.73.5 ## 1.73.0 <!-- Release notes generated using configuration in .github/release.yml at v1.73.0 --> ## What's Changed ### Other Changes * fix(aspnetcore): initialize web application factories through services by @thomhurst in thomhurst/TUnit#6956 * docs: give the site a green-bar identity by @thomhurst in thomhurst/TUnit#6959 * docs: make examples work on Linux and macOS by @Quattordici in thomhurst/TUnit#6964 * fix(runtime): correct Windows-shaped assumptions on Linux and macOS by @Quattordici in thomhurst/TUnit#6962 * build: make the repo build, test and script cleanly on macOS and Linux by @Quattordici in thomhurst/TUnit#6963 * fix(globalization): culture-invariant generators, analyzers and code fixers; enforce it by @Quattordici in thomhurst/TUnit#6969 * chore: update NuGet dependencies and split versions per target framework by @Quattordici in thomhurst/TUnit#6972 * feat: add [PairwiseDataSource] for all-pairs test case generation by @AArnott in thomhurst/TUnit#6971 ### Dependencies * chore(deps): update tunit to 1.72.16 by @thomhurst in thomhurst/TUnit#6953 * chore(deps): update dependency masstransit to 9.2.3 by @thomhurst in thomhurst/TUnit#6954 * chore(deps): update dependency messagepack to 3.1.11 by @thomhurst in thomhurst/TUnit#6958 * chore(deps): update dependency polyfill to 11.4.2 by @thomhurst in thomhurst/TUnit#6965 * chore(deps): update verify to 33.3.0 by @thomhurst in thomhurst/TUnit#6966 * chore(deps): update dependency polyfill to 11.4.3 by @thomhurst in thomhurst/TUnit#6968 * chore(deps): update microsoft.testing to 2.5.0 by @thomhurst in thomhurst/TUnit#6978 * chore(deps): bump compression from 1.8.1 to 1.8.2 in /docs by @dependabot[bot] in thomhurst/TUnit#6977 * chore(deps): bump proxy-addr from 2.0.7 to 2.0.8 in /docs by @dependabot[bot] in thomhurst/TUnit#6976 * chore(deps): bump joi from 17.13.7 to 17.13.8 in /docs by @dependabot[bot] in thomhurst/TUnit#6975 * chore(deps): bump source-map-js from 1.2.1 to 1.2.2 in /docs by @dependabot[bot] in thomhurst/TUnit#6974 * chore(deps): bump shell-quote from 1.10.0 to 1.12.0 in /docs by @dependabot[bot] in thomhurst/TUnit#6980 * chore(deps): update dependency microsoft.testing.extensions.codecoverage to 18.12.0 by @thomhurst in thomhurst/TUnit#6979 * chore(deps): update dependency azure.storage.blobs to 12.30.1 by @thomhurst in thomhurst/TUnit#6981 * chore(deps): update dependency imposter to 0.2.0 by @thomhurst in thomhurst/TUnit#6982 * chore(deps): update verify to 33.3.1 by @thomhurst in thomhurst/TUnit#6983 * chore(deps): update aspire to 13.6.1 by @thomhurst in thomhurst/TUnit#6985 * chore(deps): update actions/upload-artifact action to v7.0.2 by @thomhurst in thomhurst/TUnit#6986 * chore(deps): update dependency imposter to 0.2.1 by @thomhurst in thomhurst/TUnit#6987 ## New Contributors * @Quattordici made their first contribution in thomhurst/TUnit#6964 **Full Changelog**: thomhurst/TUnit@v1.72.16...v1.73.0 ## 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 Commits viewable in [compare view](thomhurst/TUnit@v1.70.1...v1.74.0). </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.