Skip to content

Infer generic test class types from inherited literal constructor arguments #7542

Closed

Description

@thomhurst

Summary

Source-generated discovery ignores inherited literal constructor Arguments when inferring generic test classes. Include these rows consistently, so the inherited-only example in #7490 runs as it does in reflection discovery.

Scope and acceptance

Own the base-inclusive literal attribute collection and reuse in src/TUnit.Core.SourceGenerator/Generators/TestMetadataGenerator.cs, the minimal inherited-literal cases in tests/TUnit.TestProject/Bugs/_7490/Tests.cs, tests/TUnit.TestProject/Bugs/_7426/Tests.cs, and an isolated generator snapshot fixture under tests/TUnit.Core.SourceGenerator.Tests.

Cover inherited-only rows, multiple inheritance levels, direct plus inherited literals, generic methods, and inherited GenerateGenericTest with null method rows. Validate generated and reflection discovery. Keep constructor source partitioning and new runtime/public API semantics out of this part; those belong to the sibling sub-issue.

Start from fresh origin/main. Reuse the literal discovery portions of branch issue-7490-inherited-inference (initial commit 3edf214 and subsequent inherited-attribute corrections), not its entire diff. PR #7518 at aee2f77 is retained as reference.

Validation

Run the affected generator snapshots, inspect intentional differences, and run targeted fixtures in both modes. On #7518, workflow 41756832532 failed the Test and GeneratesCachedAotCompatibleGetters output assertions on all three operating systems; investigate the generated differences rather than blindly accepting snapshots. Do not carry those failures into this part. Engine tests must run in CI, not locally.

Deliver the inherited literal inference fix as a small independently reviewable PR under parent #7490.

Metadata

Metadata

Assignees

No one assigned

    Labels

    P2Medium: edge case, mode divergence, flaky test, or workaround existsbugSomething isn't workingin-progressWork is in progress

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions