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
Generic type inference rules are implemented twice (source-gen and reflection) and keep drifting #7371
Two hand-written copies decide how a generic test class or method gets its type arguments:
source-gen: TestMetadataGenerator (TryAddInstantiation, InferTypesFromDataSourceAttribute, InferTypesFromTypedDataSourceForClass, and others)
reflection: ReflectionTestDataCollector (InferClassTypeArgumentsOfMethodRows, BuildTestsForMethodRowsWithoutClassRow, ScopeMethodRowsToClassTypeArguments, and others)
Each copy answers three questions for every data source kind ([Arguments] row, typed data source, [MethodDataSource], parameter attribute such as [Matrix<T>], [GenerateGenericTest]):
Which sources infer an instantiation?
In which order, and which source keeps a type that two sources infer?
Is a source scoped to the instantiation it infers, or does it run on every instantiation?
The answers drift apart, and most generic-inference bugs filed recently are cases of that drift: #7214, #7333, #7335, #7353, #7362, #7369. In #7337, every round of Codex and Greptile findings was another parity gap of this kind. The latest was a typed source scoped to its instantiation in source-gen but not in reflection (fixed in da8c1aa). The Claude review of #7337 raised the same concern.
Expected
Put the rules (which sources infer, their precedence, and their scope) in one documented table. Have both modes follow it, and run one parity test matrix against it. A new source kind should then need one change in the table, not two hand-written changes.
Reproduce
Compare how each mode handles the same fixture. For example, before da8c1aa, TypeFreeClassRowWithTypedSourceAndInferringParameterAttribute in tests/TUnit.TestProject/Bugs/_7209 ran 4 tests in source-gen and 3 with --reflection.
Split into native sub-issues #7450 (generic-method source precedence, duplicate selection, and fallback) and #7451 (generic-class scoping and class/method pairing). These are independently reviewable policy changes; #7451 depends on #7450. Implementing #7450 in this unit. Existing type-free class-row behavior fixes remain in #7390.
The generic-method policy portion is implemented in draft PR #7455, closing child #7450. The shared policy, documented rule table, and 13-case matrix are included. All 13 cases passed in both source-generated and reflection modes; the generator suite passed (219 passed, 1 skipped). Parent scope remains open in #7451 for class inference and class/method pairing.
Re-checked the parent acceptance criteria against freshly fetched origin/main at 10a0af7272. Both native children (#7450 and #7451) are closed, and their implementations are ancestors of this main commit:
One parity matrix covers 33 successful-fixture cases and 3 diagnostic cases, including every source kind, duplicate inference, explicit types, fallback, constructor row scoping, and class/method pairing. Its inherited harness runs the same cases in reflection and source-generated Native AOT modes.
Share generic class row selection and pairing policy #7498 records 72 targeted runs across both discovery modes, 249 passing generator snapshots (1 skipped), 13 shared-class-policy tests, and a successful native publish. Its merged-head Engine/AOT CI passed on Ubuntu, Windows, and macOS; its .NET CI also passed on all three platforms.
Type extraction, extraction switches, and class-source traversal remain adapter-specific, as explicitly documented and reviewed in #7498; adding a source still requires implementing its type extraction in both adapters. The shared policies centralize the common decisions rather than unifying Roslyn and reflection representations. The existing mixed-source type-free-row behavior remains tracked separately in #7390 and was explicitly outside both children's changes.
No additional parent-only implementation remains. Closing as completed by #7455 and #7498. This unit audited source, ancestry, matrix wiring, and merged CI evidence; it did not rerun the Engine suite locally, in accordance with repository instructions.
Activity
thomhurst commentedon Nov 3, 2026
Split into native sub-issues #7450 (generic-method source precedence, duplicate selection, and fallback) and #7451 (generic-class scoping and class/method pairing). These are independently reviewable policy changes; #7451 depends on #7450. Implementing #7450 in this unit. Existing type-free class-row behavior fixes remain in #7390.
thomhurst commentedon Nov 3, 2026
The generic-method policy portion is implemented in draft PR #7455, closing child #7450. The shared policy, documented rule table, and 13-case matrix are included. All 13 cases passed in both source-generated and reflection modes; the generator suite passed (219 passed, 1 skipped). Parent scope remains open in #7451 for class inference and class/method pairing.
thomhurst commentedon Nov 4, 2026
Re-checked the parent acceptance criteria against freshly fetched
origin/mainat10a0af7272. Both native children (#7450 and #7451) are closed, and their implementations are ancestors of this main commit:aa24319a0615902e20fa924a253eb2c0eac19113: shared generic-method source precedence, row scope, duplicate joining, and declared-source constraint fallback.5d9086ba573206c58fdd57a15ebd4cba3cee6e22: shared generic-class row membership, type-free classification, fallback decisions, and class/method type pairing; combined generic methods consume the shared method-source ordering.Evidence on main:
Type extraction, extraction switches, and class-source traversal remain adapter-specific, as explicitly documented and reviewed in #7498; adding a source still requires implementing its type extraction in both adapters. The shared policies centralize the common decisions rather than unifying Roslyn and reflection representations. The existing mixed-source type-free-row behavior remains tracked separately in #7390 and was explicitly outside both children's changes.
No additional parent-only implementation remains. Closing as completed by #7455 and #7498. This unit audited source, ancestry, matrix wiring, and merged CI evidence; it did not rerun the Engine suite locally, in accordance with repository instructions.