Repository navigation
fix(analyzers): TUnit0001 unwraps only the Func/TestDataRow layers the runtime removes - #7347
Conversation
|
@codex review |
|
No actionable comments were generated in the recent review.
|
| Layer / File(s) | Summary |
|---|---|
Bound wrapper unwrapping and validate type matching src/TUnit.Analyzers/TestDataAnalyzer.cs, tests/TUnit.Analyzers.Tests/MethodDataSourceAnalyzerTests.cs |
UnwrapTypes now removes at most one outer Func<T>, one TestDataRow<T>, and one inner Func<T>. Tests verify matching and mismatching parameter types for nested wrappers. |
Estimated code review effort: 2 (Simple) | ~10 minutes
Change: Bug fix · Severity of issue fixed: Low
Merge Risk: 
Minimal · up to 3cda3
-
The bounded wrapper handling and its new tests present no identified issue that needs resolution before merge.
Pre-merge checks: 
4 · 
1
-
Failed checks: 1 warning Passed checks: 4 passed-
Check name Status Explanation Description Check Check skipped - CodeRabbit’s high-level summary is enabled. Title check The title names the analyzer (TUnit0001) and the specific change: it unwraps only the Func/TestDataRow layers that the runtime removes. The raw summary says UnwrapTypes now removes at most one outer F… Linked Issues check [ #7227] Requirement: TUnit0001 must unwrap only the layers the runtime removes: one optional outer Func, one optional TestDataRow, then one optional Func inside the row. Deeper nesting must b…Out of Scope Changes check Changed files at head 3cda39a, relative to merge base 7e579da: src/TUnit.Analyzers/TestDataAnalyzer.cs and tests/TUnit.Analyzers.Tests/MethodDataSourceAnalyzerTests.cs.
- UnwrapTypes: the loop is rep…Full details: Title check
-
Explanation
The title names the analyzer (TUnit0001) and the specific change: it unwraps only the Func/TestDataRow layers that the runtime removes. The raw summary says UnwrapTypes now removes at most one outer Func<T>, one TestDataRow<T>, and one inner Func<T>, and the objectives say this aligns with the runtime row reader. The title is specific and matches the main change. It uses the conventional fix(analyzers) prefix and is one sentence, though at 86 characters it is slightly long.
Full details: Linked Issues check
-
Explanation
[
#7227] Requirement: TUnit0001 must unwrap only the layers the runtime removes: one optional outer Func<T>, one optional TestDataRow<T>, then one optional Func<T> inside the row. Deeper nesting must be reported.Evidence at head 3cda39a:
- TestDataAnalyzer.cs UnwrapTypes replaces the former do/while loop with three single steps: TryUnwrapFunc (outer), a TestDataRow<T> check, then TryUnwrapFunc on the row value. Each layer is removed at most once.
- src/TUnit.Core/Helpers/DataSourceHelpers.cs ToObjectArray calls InvokeIfFunc once on the item. This matches the outer Func step. I did not read TestDataRowUnwrapper.UnwrapArray; its behavior comes from the issue text and PR description.
- Repro from the issue, IEnumerable<Func<Func<int>>> for an int parameter: the analyzer now stops at Func<int>, which differs from int, so it reports TUnit0001.
- Func<TestDataRow<Func<int>>> and TestDataRow<Func<int>> still reduce to int, as the runtime requires.
- New tests in MethodDataSourceAnalyzerTests.cs cover the mismatch cases (Func<Func<int>> and TestDataRow<TestDataRow<int>> for int), the matching Func<int> parameter case, and the valid Func<TestDataRow<Func<int>>> case.
Test results (2754 total, 0 failed) are author-reported. I did not run the test suite.
Full details: Out of Scope Changes check
-
Explanation
Changed files at head 3cda39a, relative to merge base 7e579da: src/TUnit.Analyzers/TestDataAnalyzer.cs and tests/TUnit.Analyzers.Tests/MethodDataSourceAnalyzerTests.cs.
- UnwrapTypes: the loop is replaced by bounded unwrapping steps. This directly implements [
#7227]. The new private static TryUnwrapFunc helper contains the same display-string check as the original code, moved into one place. It supports the same objective. - Tests: the four added tests cover the issue scenario and the valid boundary cases. They support the objective.
No unrelated behavior change is visible in the reviewed hunks. The PR is analyzer-only, and the diff does not touch runtime or source generator code.
The display-string match for System.Func is pre-existing behavior. The PR references follow-up issue
#7380for it. It is not an out-of-scope change in this PR. - UnwrapTypes: the loop is replaced by bounded unwrapping steps. This directly implements [
-
Full details: Docstring Coverage
-
Explanation
Docstring coverage is 0.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 2 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 wrapper in a row,
One Func<T> is all it lets go.
A row unwraps once, then one more,
Nested types stay at the door.
Tests confirm each type in view.
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. |
Review: TUnit0001 unwrap depthLGTM. Replacing the unbounded
Optional, non-blocking: I did not run the tests myself; the PR reports 2754 analyzer tests passing. |
|
Codex Review: Didn't find any major issues. What shall we delve into next? 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". |
[Low impact] The PR appears safe to merge. Summary
No actionable issues found. Tests were not run during this review. Reviews (2) · Last reviewed commit: "fix(analyzers): TUnit0001 unwraps only t..." · Reviewed by Greptile |
…e runtime removes (#7227)
b5d08a1 to
3cda39a
Compare
Review: TUnit0001 unwrap depthLGTM. Replacing the unbounded
Optional: No previous review findings are outstanding. |
|
Disposition of the optional finding from the Claude reviews (display-string Head |
|
@codex review |
|
Codex Review: Didn't find any major issues. Keep it up! 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". |
ReviewThe change is correct and well scoped. Replacing the unbounded unwrap loop with a fixed Func → TestDataRow → Func sequence matches the runtime row reader (
Two optional suggestions:
LGTM. |
|
Dispositions for the latest Claude review (comment 6570666000) on head
Both Claude and Codex (receipt for |
TestDataAnalyzerlooped overFunc<T>andTestDataRow<T>wrappers until none were left. That reducedFunc<Func<int>>andTestDataRow<TestDataRow<int>>toint, so TUnit0001 accepted them. At run time the test then received aFunc<int>or aTestDataRow<int>and the cast failed.Change
TUnit0001 now unwraps only the layers the runtime row reader removes. This matches
GetMethodDataSourceRowTypein the source generator (#7143):Func<T>(DataSourceHelpers.ToObjectArray)TestDataRow<T>(TestDataRowUnwrapper.UnwrapArray)Func<T>inside the rowFunc<T>,TestDataRow<T>,Func<TestDataRow<T>>,TestDataRow<Func<T>>andFunc<TestDataRow<Func<T>>>still reduce toT. Deeper nesting is now checked as the wrapper value the test actually receives.Tests
New tests in
MethodDataSourceAnalyzerTests:Func<Func<int>>for anintparameter reports TUnit0001.TestDataRow<TestDataRow<int>>for anintparameter reports TUnit0001.Func<Func<int>>for aFunc<int>parameter reports nothing.Func<TestDataRow<Func<int>>>for anintparameter reports nothing.dotnet testintests/TUnit.Analyzers.Tests: 2754 total, 0 failed, 2751 succeeded.This change is analyzer-only, so source-generated and reflection metadata collection are unaffected.
Closes #7227
Summary by CodeRabbit
Func<T>andTestDataRow<T>wrappers. The analyzer now unwraps only the supported outer layers, so remaining nested types are included when checking whether data source values match test parameters.