Repository navigation
Conversation
Reflection mode named a repeated-type-parameter test after its last argument type but instantiated the method from its first non-assignable type. A test shown as Repeated<int> could then run with T = string and fail its where T : struct constraint. Directly declared generic parameters now take the last argument type, matching TestGenericTypeResolver and source-generated mode. Nested inference, such as the element type of a params T[], still preserves a more specific leading type so the _7099 fixtures keep passing.
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. |
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info
📝 Walkthrough
Merge Risk: ⚪ Minimal · up to
|
ReviewThe fix looks correct and is narrow. Minor, non-blocking suggestions:
I couldn't run the tests locally, so this review is based on reading the diff. LGTM. |
[Medium impact] The PR appears safe to merge; no actionable issues were found. SummaryReflection invocation now uses the last non-null argument type for repeated direct generic parameters.
Reviews (1) · Last reviewed commit: "fix(engine): use last inferred type for ..." · Reviewed by Greptile |
|
Thanks! |
|
Thanks @thomhurst for merging #7134. The reflection invoker now takes the last declared type for a repeated generic parameter, so a test named Repeated<int> runs as int rather than failing its struct constraint. That mismatch was easy to miss.
My work sits at https://github.com/theluckystrike, and a small one-time sponsorship via https://github.com/sponsors/theluckystrike would tell me the time was valued. Totally fine if not, and I'll keep sending fixes here when I can.
Thank you,
Michael Lip
Founder of https://zovo.one, 108 Chrome extensions with 150,000+ users
Also building https://makeroll.com and https://ml0x.com, open-source guardrails for Claude Code agents
Open source has to win, and small fixes like this one are my part of it
GitHub Sponsors keeps these fixes coming, https://github.com/sponsors/theluckystrike
|
Description
Reflection mode inferred a repeated generic type parameter from its first non-assignable argument while naming the test from its last. A test displayed as
Repeated<int>could therefore be invoked withT = stringand fail itswhere T : structconstraint. The reflection invoker now takes the last declared argument type for a directly declared generic parameter, matchingTestGenericTypeResolverand source-generated mode. Nested inference, such as the element type of aparams T[], keeps the previous guard so it cannot replace a more specific leading type.Related Issue
Fixes #7121
Type of Change
Checklist
Required
TUnit-Specific Requirements
TUnit.Core.SourceGenerator)TUnit.Engine)TUnit.Core.SourceGenerator.Testsand/orTUnit.PublicAPItests.received.txtfiles and accepted them as.verified.txt.verified.txtfiles[DynamicallyAccessedMembers]annotationsdotnet publish -p:PublishAot=trueTesting
Source-generated mode already infers the last occurrence, so only the reflection path needed changing; the fixture is compiled and run in both modes by the existing engine suite.
Additional Notes
The
where T : structrow("1", 2)is the issue repro. Before the fix the test was reported asRepeated<int>(1, 2)but invoked withT = string, throwingArgumentException ... violates the constraint of type 'T'; after the fix it passes. The_7099params T[]inference tests are the regression guard for the nested-inference guard.Summary by CodeRabbit