Repository navigation
test(sourcegen): parse fixtures as a real build in all generator test harnesses - #7319
Conversation
…version in all harnesses (#7190)
|
Caution Review failedThe pull request is closed. Walkthrough
Merge Risk:
|
|
@codex review |
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. |
ReviewThis is a well-scoped test-infrastructure change. A shared Checked:
Optional suggestions, not blockers:
I have not run the tests myself. The PR description reports that all TFMs pass with no snapshot changes. LGTM. |
|
Codex Review: Didn't find any major issues. Can't wait for the next one! 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 changes stay within source-generator test infrastructure. Fix the missing Findings
SummaryShares Preview parse options and input checks across the generator test harnesses.
Reviews (1) · Last reviewed commit: "test(sourcegen): parse generator test fi..." · Reviewed by Greptile |
|
Dispositions for head
|
ReviewThis is a sound test-infrastructure change. I read the diff but did not build the projects or run the tests. What I checked
Suggestions (non-blocking)
I don't see correctness problems. Approving in spirit. |
Summary
#7189 fixed the Core generator harness so it parses fixtures as a real build does. This PR applies the same fix to the other generator test harnesses (#7190):
Shared helper.
tests/SharedTestHelpers/GeneratorTestInput.csholds theLanguageVersion.Previewparse options and the input check from test(sourcegen): parse snapshot fixtures as a real build does #7189 (ThrowIfInputCannotBeParsed: syntax errors, plus CS0182/CS0225/CS8652, the errors a too-old compiler reports for valid newer syntax). The Core harness now uses it in place of its private copy.TUnit.Assertions.SourceGenerator.Tests.
TestsBaseparses all inputs, including additional sources, with Preview options (preprocessor symbols are kept), passes them toCSharpGeneratorDriver.Create, and fails on unparseable input.AssertionMethodGeneratorRunner, the compile-check helpers (CompileChecker,AssertionExtensionGeneratorTests,XmlDocsRegressionTests,GlobalNamespaceRegressionTests) andUnboundGenericAssertionFromTests.RunGeneratoruse the same options.TUnit.Assertions.Should.SourceGenerator.Tests.
RunGeneratorparses with Preview options, passes them to the driver, and fails on unparseable input.Roslyn host. Both Assertions test projects now host on Roslyn 4.14 (
VersionOverride), as the Core test project does, because Roslyn 4.7 rejects collection expressions in attribute arguments even in preview mode.TUnit.Mocks.SourceGenerator.Tests. It already parsed with Preview options and runs on Roslyn 4.12 through
Microsoft.CodeAnalysis.CSharp.Workspaces.MemberDiscoveryTestsnow uses the shared options too, and the snapshot paths ofSnapshotTestBase(RunGeneratorand the compile-diagnostics path) fail on unparseable input.RunGeneratorForDiagnosticsis left as it was, because diagnostic tests may feed in input that is invalid on purpose.Regression test.
GeneratorTestInputTestschecks that newer syntax (a collection expression in an attribute argument, aparams IEnumerable<T>parameter) passes the check on the hosted Roslyn, and that a syntax error fails it.Unrelated net472 fix.
AotConverterScanTests.SkipsConversionsBlockedByObsoleteError(added in fix(sourcegen): skip [Obsolete(error: true)] conversion operators in AotConverterGenerator #7317) failed on the Windows-only net472 leg with CS0518, because itsrecord structfixture needsIsExternalInit. It now addsReferencesHelper.NetFrameworkPolyfillson .NET Framework, as other Core tests already do. CI runs only on Linux and macOS, so it never ran this leg.No snapshot changed, so none of the existing fixtures was being bound incorrectly.
Left out of scope:
TUnit.SourceGenerator.IncrementalTestspins Roslyn 4.7 on purpose, to test the Roslyn47 generator variant, and its fixtures use only simple syntax.Validation
dotnet teston every TFM forTUnit.Core.SourceGenerator.Tests,TUnit.Assertions.SourceGenerator.Tests(net472 included),TUnit.Assertions.Should.SourceGenerator.TestsandTUnit.Mocks.SourceGenerator.Tests: all pass, and no snapshot files changed.Closes #7190
Summary by CodeRabbit