You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
TUnit0001 rejects an int method source for a nullable generic class parameter #7573
The TUnit0001 analyzer rejects a typed method data source returning IEnumerable<int> when its test parameter is T? on a generic class constrained with where T : struct. Reflection discovery infers T = int and executes the row successfully; source-generated discovery also supports this after PR #7571. The diagnostic prevents users from building the supported test.
Build with the TUnit analyzer. Actual: TUnit0001 reports that int does not match T?. Expected: infer the underlying int and accept the test.
Environment
.NET SDK 10.0.403, repository head 4fd4387. Reproduced while validating PR #7571 in tests/TUnit.TestProject/Bugs/_7224/MethodSourceClassInferenceTests.cs, NullableValue. The analyzer also remains unchanged on main at 98b0697. The runtime regression temporarily suppresses this diagnostic.
Please make nullable generic class method-parameter validation agree with discovery and add analyzer coverage.
Rechecked the parent against origin/main at 55f4100. Both native sub-issues are closed: #7610 shipped via #7613 (3dfd584), and #7611 shipped via #7614 (55f4100). The analyzer accepts int/int? rows for T? and retains constraint regressions; discovery retains generated/reflection parity and constructor precedence. The merged PRs contain full analyzer/generator and Native AOT validation and passing CI.
The remaining cleanup was a fixture-wide TUnit0001 suppression and comment saying the analyzer fix was pending. #7626 removes both and closes this parent when merged. With the suppression removed, a fresh net10.0 build succeeded and all 39 targeted _7573 cases passed in generated mode and all 39 passed in reflection mode (SDK 10.0.403, macOS arm64). No engine integration suite was run locally, per repository guidance. Existing build warning debt is tracked in #7410, #7412 and #7430.
Additional nullable analyzer reproduction found while validating #7630: C<TClass> closed with [GenerateGenericTest(typeof(int))] (or [Arguments<int>(1)]) has static IEnumerable<TClass> StaticRows() => [default!]; and [Test, GenerateGenericTest(typeof(int)), MethodDataSource(nameof(StaticRows))] void BothSources<T>(T? item) where T : struct { }. Building reports TUnit0001 that TClass does not match T?, despite the closed class/method pair being int/int and execution succeeding in both discovery modes. Expected: accept that compatible closed pairing. SDK 10.0.403; reproduction is in tests/TUnit.TestProject/Bugs/_7222/GenericInstanceSourceTests.cs on #7630, with an explanatory suppression so its discovery regressions compile. Please include this method-generic/closed-class variant in the remaining nullable analyzer work.
Activity
Honor explicit nullable generic class types for #7573
Honor constructor-inferred nullable class types (#7573)
Fix nullable row inference and source overload isolation (#7573)
Fix peer constraints for independently supplied nullable class types (#…
Fix nullable generic class method source validation (#7573)
Honor explicit nullable generic class types for #7573
Honor constructor-inferred nullable class types (#7573)
Fix nullable row inference and source overload isolation (#7573)
Fix peer constraints for independently supplied nullable class types (#…
Fix nullable class discovery and inherited data handling (#7573)
Scope inferred class method sources consistently for #7573
Exclude generic source overloads from class inference for #7573
5 remaining items
Keep inferred class method sources partitioned beside literal rows (#…
Preserve nullable constructor type precedence for #7573
Preserve partial constructor inference beside nullable method rows (#…
Preserve partial constructor row fallback for #7573
Fix nullable constructed struct inference parity for #7573
Validate partial constructor fallback constraints for #7573
thomhurst commentedon Nov 5, 2026
Rechecked the parent against origin/main at 55f4100. Both native sub-issues are closed: #7610 shipped via #7613 (3dfd584), and #7611 shipped via #7614 (55f4100). The analyzer accepts int/int? rows for T? and retains constraint regressions; discovery retains generated/reflection parity and constructor precedence. The merged PRs contain full analyzer/generator and Native AOT validation and passing CI.
The remaining cleanup was a fixture-wide TUnit0001 suppression and comment saying the analyzer fix was pending. #7626 removes both and closes this parent when merged. With the suppression removed, a fresh net10.0 build succeeded and all 39 targeted
_7573cases passed in generated mode and all 39 passed in reflection mode (SDK 10.0.403, macOS arm64). No engine integration suite was run locally, per repository guidance. Existing build warning debt is tracked in #7410, #7412 and #7430.Update nullable row snapshot source locations (#7573)
thomhurst commentedon Nov 5, 2026
Additional nullable analyzer reproduction found while validating #7630:
C<TClass>closed with[GenerateGenericTest(typeof(int))](or[Arguments<int>(1)]) hasstatic IEnumerable<TClass> StaticRows() => [default!];and[Test, GenerateGenericTest(typeof(int)), MethodDataSource(nameof(StaticRows))] void BothSources<T>(T? item) where T : struct { }. Building reports TUnit0001 thatTClassdoes not matchT?, despite the closed class/method pair being int/int and execution succeeding in both discovery modes. Expected: accept that compatible closed pairing. SDK 10.0.403; reproduction is intests/TUnit.TestProject/Bugs/_7222/GenericInstanceSourceTests.cson #7630, with an explanatory suppression so its discovery regressions compile. Please include this method-generic/closed-class variant in the remaining nullable analyzer work.Remove obsolete nullable method-row analyzer suppression (#7626)