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
Source generator crashes with TUNIT0999 (NullReferenceException) for [Arguments(null)] on a generic test method #7120
[Arguments(null)] on a generic test method makes the source generator crash with TUNIT0999 (NullReferenceException). C# binds a bare null to the params object?[] parameter as a null array rather than as one null element, and the generator's type-argument inference does not handle a null argument array.
The build reports TUNIT0999 from the TUnit source generator with a NullReferenceException.
Expected
No generator crash. Either treat the row as a single null value (inferring object, which is what source-gen does for [Arguments((string?)null)]) or report a clear diagnostic explaining that T cannot be inferred.
Notes
Found while addressing review on #7094. Reflection-mode behaviour for the same row has not been checked.
PR #7111 (commit 5034196) makes the generator's three type-inference helpers treat [Arguments(null)] as inferring no type instead of crashing. It was found for [Arguments(null)] on a generic class. Check whether the generic method repro here is also fixed once #7111 merges.
Another shape that hits the same crash: an untyped [Arguments(null)]method row on a generic class. Found while addressing review on #7112. The new test there uses [Arguments((string?)null)] to avoid it.
#7112 is built on #7102, not #7111, so it doesn't have #7111's null-array handling yet. Once #7111 merges, check this shape as well as the generic-method repro above.
Activity
thomhurst commentedon Oct 18, 2026
PR #7111 (commit 5034196) makes the generator's three type-inference helpers treat
[Arguments(null)]as inferring no type instead of crashing. It was found for[Arguments(null)]on a generic class. Check whether the generic method repro here is also fixed once #7111 merges.thomhurst commentedon Oct 18, 2026
Another shape that hits the same crash: an untyped
[Arguments(null)]method row on a generic class. Found while addressing review on #7112. The new test there uses[Arguments((string?)null)]to avoid it.#7112 is built on #7102, not #7111, so it doesn't have #7111's null-array handling yet. Once #7111 merges, check this shape as well as the generic-method repro above.
fix(engine): run untyped [Arguments(null)] rows on generic classes in…
fix(generic): infer object when a type parameter gets null and a valu…
fix(engine): infer object for null rows on generic test methods in re…