Repository navigation
Fix reflection data source overloads with omitted optional arguments - #7421
Conversation
|
Warning Review limit reachedYou've used all free OSS reviews for now. Wait for the free limit to reset to keep reviewing this public repository. Next included review available in 4 minutes. View limit details
|
| Layer / File(s) | Summary |
|---|---|
Resolver fallback and parity coverage src/TUnit.Core/Attributes/TestData/MethodDataSourceAttribute.cs, tests/TUnit.TestProject/Bugs/_7108/DataSourceOverloadParityTests.cs, tests/TUnit.Engine.Tests/Issue7108Tests.cs |
Both platform paths store the binder-selected method and use the scoring resolver when no method is selected. Null-containing arguments also use that resolver. The tests add a non-null argument case and increase the expected total and passed counts to 32. |
Estimated code review effort: 2 (Simple) | ~10 minutes
Change: Bug fix · Severity of issue fixed: Low
Possibly related PRs
- thomhurst/TUnit#7336: Adds reflection helpers that use the same MethodDataSource overload resolver.
Merge Risk: 
Low · previous review 2ecfe
-
Reflection-mode discovery can fail for tied overloads with omitted tokens. The affected case is narrow, but it should be fixed or explicitly accepted before merging.
Pre-merge checks: 
4 · 
1
-
Failed checks: 1 warning Passed checks: 4 passed-
Full details: Linked Issues check
-
Explanation
The changes satisfy
#7331.ResolveDataSourceMethodkeeps the runtime binder result when it succeeds and callsResolveDataSourceMethodByScorewhen the binder returns no exact-arity match. The scorer covers omitted optional andCancellationTokenparameters, including null arguments. The parity suite adds a non-null inherited override case and updates the expected count from 31 to 32. ExistingOptionalandTokenrows also cover omitted trailing parameters.
Full details: Out of Scope Changes check
-
Explanation
All changed files support
#7331. The resolver change implements the fallback. The added parity row and the count update test the reported overload-selection behavior. No unrelated product behavior or unrelated test scope is changed.
-
Full details: Docstring Coverage
-
Explanation
Docstring coverage is 50.00% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff with cyclomatic complexity of at least 2. Documentation-only edits and deletions within surviving functions are included; unchanged diff context and fully deleted functions are excluded. Analyzed 2 functions across 3 files.
Resolution
Write docstrings for the functions missing them to satisfy the coverage threshold.
-
Finishing Touches
-
Generate docstrings
-
- Commit to this branch
- Create a new PR
Generate unit tests (beta)
-
- Commit to this branch
- Create a new PR
-
- Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts
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.
A rabbit checks each overload row,
Where null or missing arguments go.
The binder tries, then scores the rest,
A parity case joins the test.
Thirty-two pass; the carrots cheer.
CodeRabbit Verify
- Run CodeRabbit Verify to test the changes in this pull request.
|
@codex review |
Codex Review SummaryThis comment shows the latest Codex review activity on this pull request.
ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings. |
|
Codex Review: Didn't find any major issues. Keep them coming! Reviewed commit: ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
If Codex has suggestions, it will comment; otherwise it will react with 👍. Codex can also answer questions or update the PR. Try commenting "@codex address that feedback". |
[Medium impact] The PR appears safe to merge; the previous overload-selection issue is fixed and no new blocking issues were found. SummaryReflection discovery now falls back to overload scoring when the binder finds no match with the supplied argument count.
No new actionable issues found. Tests were not run during this review. Reviews (3) · Last reviewed commit: "Fix nullable numeric overload specificit..." · Reviewed by Greptile |
|
Review: LGTM, with one minor nit. The change is small and well-targeted. The runtime binder is tried first, so existing successful selections don't change. When it returns null (it needs exact arity), the code falls back to the existing scorer, which already mirrors the source generator's
Nothing blocking. |
|
Review disposition for 2ecfe92: Claude and Codex report no blocking findings; there are no review threads. The new inline comment immediately above the fallback documents the binder's exact-arity limitation and scorer fallback. The earlier block describes the null-argument path correctly, although it could also summarize the new fallback; accepting that documentation nit without another code push per the loop's nonblocking-finding policy. The existing non-null Optional row (line 275), Token row (line 276), and new non-null inherited override row (line 279) exercise omitted trailing arguments; the inherited override case supplies the overloaded lookup regression. No additional coverage is required for this review suggestion. Promoting the reviewed head to ready. Promotion triggers fresh CI and Claude review; auto-merge will remain unarmed until that Claude run passes and its review has been read. |
Review of #7421I found no blocking issues. The change is a good simplification. What I checked
Non-blocking suggestions
Engine integration tests and native AOT are left to CI, as noted in the PR description. |
|
The earlier wait on run 41547620666 no longer applies: that old-head run was cancelled and superseded by successful current-head Claude run 41549694535. Codex also reports a completed clean review of ddc3f41. Reviewed every review surface. Both correctness findings are fixed in 42492b8 and ddc3f41 and their threads are resolved. Claude’s current-head helper-extraction and pattern-readability suggestions are optional; retaining the tested inline implementation avoids a further review cycle for stylistic changes. CodeRabbit’s older docstring-coverage warning is advisory rather than a repository requirement; the resolver’s behavior and tie handling are documented in the updated comments. Every current CI check is successful, skipped, or neutral, including Engine integration and Native AOT on Linux, Windows, and macOS. This supersedes the local AOT limitation in the PR description. Proceeding through the repository merge gate with the reviewed head unchanged. |
When MethodDataSource Arguments omit an optional parameter and the method name is overloaded, reflection discovery can throw AmbiguousMatchException even though source-generated discovery selects a valid overload.
Fall back to the existing overload scorer when the runtime binder finds no exact-arity match. This handles omitted optional and CancellationToken parameters while preserving the binder's existing successful selections. Retain the first equally scored overload unless a later one is more specific, matching the generator. Add regressions for the inherited override default and for tied overloads with one or two omitted CancellationToken parameters in both declaration orders, and update the parity test count.
Closes #7331
Validation: all 34 DataSourceOverloadParityTests passed on net10.0 in source-generated mode and with --reflection. Engine integration tests are left to CI per repository instructions. The separate analyzer optional-parameter limitation is tracked in #7418.
Native AOT validation:
dotnet publish tests/TUnit.TestProject/TUnit.TestProject.csproj -c Release -f net10.0 -p:Aot=true --use-current-runtimereached native linking but failed because this machine lackslibssl(ld: library 'ssl' not found). AOT publishing remains for CI. No new reflection APIs or trimming annotations were introduced.Summary by CodeRabbit
Review follow-up: 42492b8 fixes tied omitted-token overloads and updates the resolver comments. All 34 parity cases passed in both discovery modes. No generator implementation or public API changed; Engine integration and native AOT remain for CI. Existing analyzer build warnings are tracked in #7410.
Review follow-up: ddc3f41 aligns nullable numeric specificity with source generation, including lifted decimal conversions. Added null-argument parity rows for int?/long? in both declaration orders and int?/decimal?. All 37 cases passed in source-generated and reflection modes on net10.0. No generator implementation or public API changed. Engine integration remains for CI; the native AOT linker limitation documented above still applies.