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
Mock generator nullable regression helpers can pass even when generated implementations contain nullable warnings. Generated source starts with #pragma warning disable, which compiler WarningsAsErrors cannot override. Restore relevant diagnostics in test compilations and prove enforcement with a deliberately invalid positive control.
Reproduction
Inspect src/TUnit.Mocks.SourceGenerator/MockGenerator.cs (implementation header) and tests/TUnit.Mocks.SourceGenerator.Tests/SnapshotTestBase.cs:221 on main d87516c. AssertGeneratedCodeHasNoNullableWarnings compiles generated trees without restoring the disabled warnings.
Proposal
Re-enable relevant nullable diagnostics in test-only generated trees before compiling and add a positive control proving that an injected nullable mismatch fails the guard. Preserve production generated output and existing reviewed snapshots unless a separate production defect requires change.
This is the nonblocking CodeRabbit follow-up on #7414; call-site CS8634 enforcement remains useful for that fix.
Acceptance criteria
In test-only generated syntax trees, restore nullable diagnostics after the generated warning suppression; leave production output unchanged.
Cover the nullable-event regression diagnostics CS8604 and CS8612–CS8615 as well as the existing nullable guards. Project-level WarningsAsErrors alone cannot override generated #pragma warning disable.
Add a deliberately invalid generated nullable-event signature (or equivalent targeted positive control) and prove the guard fails; verify the valid nullable-event regressions pass.
Run the affected mock source-generator tests and review any intentional snapshot changes.
The generated-code enforcement requirement from #7432 is consolidated here. PR #7414 removes the unsupported pragmas and adds project-level warning promotion, but does not restore diagnostics disabled inside generated files.
Audited against main d87516cb9c: MockGenerator.cs:415 still disables all generated warnings, and SnapshotTestBase.RunGeneratorWithCompilationDiagnostics compiles those trees unchanged. Added explicit acceptance criteria for the remaining nullable-event enforcement from #7432, including a failing positive control. This remains separate work from #7414.
Activity
thomhurst commentedon Nov 3, 2026
Audited against main
d87516cb9c:MockGenerator.cs:415still disables all generated warnings, andSnapshotTestBase.RunGeneratorWithCompilationDiagnosticscompiles those trees unchanged. Added explicit acceptance criteria for the remaining nullable-event enforcement from #7432, including a failing positive control. This remains separate work from #7414.Enforce generated nullable diagnostics in mock regression guards (#7436…