Repository navigation
test(sourcegen): snapshot property injection output for Core.* namespaces - #7293
Conversation
…aces Follow-up to #7291. The existing tests only check that the generated property injection code compiles. A snapshot of the output shows exactly which type names lose their global:: prefix if the generator regresses. The fixture lives in TUnit.TestProject under namespace Core.Api.Tests, so the real build and both engine modes also cover it.
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. |
|
No actionable comments were generated in the recent review.
|
| Layer / File(s) | Summary |
|---|---|
Regression fixture and assertions tests/TUnit.TestProject/Bugs/_7291/Tests.cs |
Adds initialized database properties on the test class and its generic base class. The test checks initialization and verifies that the enum-backed value is "B-B". |
Generator test and expected output tests/TUnit.Core.SourceGenerator.Tests/Bugs/7291/Tests7291.cs, tests/TUnit.Core.SourceGenerator.Tests/TestsBase.cs, tests/TUnit.Core.SourceGenerator.Tests/Tests7291.Test.verified.txt |
Adds a test that runs PropertyInjectionGenerator on the fixture and checks for generated files. Adds expected generated sources for the concrete and generic-base properties. |
Priority:
Estimated code review effort: 2 (Simple) | ~10 minutes
Change: Other
Merge Risk: 
Minimal · up to ca529
-
The change adds regression coverage without an identified merge-blocking issue.
Pre-merge checks: 
5
-
Full details: Docstring Coverage
-
Explanation
No eligible functions found in the changed files. Skipping docstring coverage check. 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 0 functions across 3 files. (1 skipped: 1 unsupported.)
-
Finishing Touches: 💡 1
-
📝 Generate docstrings
-
- Commit to this branch
- Create a new PR
🧪 Generate unit tests (beta)
-
- Commit to this branch
- Create a new PR
🛠️ Fix failing CI checks: 💡
-
- 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 property in place,
Then watches generated sources trace.
Two databases wake and glow,
Enum-made values say “B-B” so.
The test confirms the sources show.
Comment @coderabbitai help to get the list of available commands.
ReviewTest-only PR, and it looks good.
One non-blocking note: the verified snapshot has no I did not run the tests myself, and I'm relying on the PR's stated results. Nothing here needs changing. |
[Low impact] The PR appears safe to merge; no actionable issues were found. SummaryAdds a snapshot test for property injection in
No actionable issues were found. Tests were not run during this review. Reviews (1) · Last reviewed commit: "test(sourcegen): snapshot property injec..." · Reviewed by Greptile |
NamespaceStartingWithCore_GeneratedCodeCompiles (#7293) failed on the Windows net472 leg: .NET Framework lacks IsExternalInit and RequiredMemberAttribute for the source's init/required members, and has no UnsafeAccessor for the NET8_0_OR_GREATER branches. Share the existing polyfill source through ReferencesHelper and compile only the reflection fallback branch on net472.
…7296) * feat(engine): report unobserved task exceptions in session results TaskScheduler.UnobservedTaskException was only written to stderr, so the run stayed green and the exceptions never reached any report. Record them on TestSessionContext.UnobservedTaskExceptions and report them at session end: a console warning, an HTML Overview panel, and the JUnit suite-level system-err. --fail-on-unobserved-task-exceptions (or Settings.Execution.FailOnUnobservedTaskExceptions) forces a final GC so late faults are not lost, and reports each exception as a failed result, which reaches TRX and the exit code. The event fires on the finalizer thread, which has no AsyncLocal contexts, so a static tracker routes it to the running sessions. Closes #7288 * test(sourcegen): compile raw property-injection tests on net472 NamespaceStartingWithCore_GeneratedCodeCompiles (#7293) failed on the Windows net472 leg: .NET Framework lacks IsExternalInit and RequiredMemberAttribute for the source's init/required members, and has no UnsafeAccessor for the NET8_0_OR_GREATER branches. Share the existing polyfill source through ReferencesHelper and compile only the reflection fallback branch on net472. * fix(engine): scope unobserved task exception reports per session - Clear the HTML reporter's exception queue at session start, so a later IDE session does not report an earlier session's exceptions. - Record each cause of an AggregateException separately, so reports keep every cause's type and stack trace. - When several sessions run at once, report the exception in each but do not fail any of them, since the event names no session. * fix(engine): keep empty AggregateException causes of unobserved tasks AggregateException.Flatten() drops an empty AggregateException, so a task that threw one recorded nothing and could not fail the run. Unwrap only aggregates that wrap causes.
Description
Follow-up to #7291. The tests added there check that the property injection output compiles. This PR adds a snapshot test of the generated source, so a regression shows the exact lines that lose the
global::prefix.tests/TUnit.TestProject/Bugs/_7291/Tests.csin namespaceCore.Api.Tests. It covers each site that fix(sourcegen): globally qualify type names in property injection output #7291 fixed: the containing type, the data source attribute type, a generic base with a constraint, an enum cast in an attribute argument, and a keyword-named enum (@event).Tests7291runsPropertyInjectionSourceGeneratoron the fixture.TestsBasegets aPropertyInjectionGeneratorrunner for this.TUnit.TestProject. It checks that each property is injected and initialized, so the real build and both engine modes cover it too.Type of Change
Testing
Tests7291passes on net10.0, net9.0, net8.0 and net472.typeof(Core.Api.Tests.Tests)andwhere TProgram : class, Core.Api.Tests.IMarker.TUnit.Core.SourceGenerator.Testson net10.0: 213 passed, 1 skipped.TUnit.TestProjectwith--treenode-filter "/*/Core.Api.Tests/*/*": passes in source-generated and--reflectionmodes.Summary by CodeRabbit