Repository navigation
fix(sourcegen): pick MethodDataSource overloads declared on base types like reflection - #7323
Conversation
|
Caution Review failedThe pull request is closed.
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. |
|
@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. |
ReviewSolid fix. Scoring candidates across the whole hierarchy matches reflection's Non-blocking observations:
The test matrix (static, instance, private base, overridden virtual) covers the main paths in both modes. LGTM, pending CI. |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: df983f2589
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
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".
[Medium impact] The change affects source-generated data-source selection and invocation. The override-default fix should preserve date defaults before merging. SummaryThe PR searches base types when choosing a
Reviews (2) · Last reviewed commit: "fix(sourcegen): keep an override's defau..." · Reviewed by Greptile |
…s like reflection (#7202) Score base-type overloads (excluding private, overridden and hidden-by-signature members) and call the winner through its declaring type when a derived type shadows the name. Also treat overrides as declared on their virtual's type. Also add an IsExternalInit polyfill to AotConverterScanTests' record struct source so it compiles on net472.
… when calling it through its base declaration (#7202)
df983f2 to
29819df
Compare
|
Disposition of the non-blocking notes in the Claude review:
The Codex (optional defaults) and Greptile (covariant return type) findings are fixed in 29819df and replied to in their threads. |
ReviewThe approach is sound. Notes:
No blocking issues. |
|
@codex review |
|
Codex Review: Didn't find any major issues. Already looking forward to the next diff. 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". |
Comments Outside DiffThese findings could not be posted inline.
|
Summary
Source-gen mode now picks the same
[MethodDataSource]overload as reflection mode when overloads are spread across a class hierarchy.ResolveMethodDataSourceMemberscores methods from the target type and every base type, the same set reflection'sGetMethods(FlattenHierarchy)sees. It skips private base members and base methods that a more derived type overrides or hides by signature. It also skips base methods the generated class cannot call (for example protected ones), so choosing one cannot break the build. On an exact tie the most derived declaration wins, as with the reflection binder. The property/field fallback still reads the first type that declares the name.BaseProvider.Split(...), or((BaseProvider)instance).Split(...)), but only when a type below the declaring type also declares that name without overriding it. Without the cast, C# overload resolution on the target type drops the base overload. The common case keeps its current output, so no snapshot changes.override Overridden(string, int)next to a derivedOverridden(string, long)was already a pre-existing divergence: C# does not count overrides as overload candidates on the derived type, so for1, source-gen called thelongoverload. The new rows exposed this case, and it is fixed here too.Task<...>override of a baseobjectmethod still binds toFromTask<T>.Tests
DataSourceOverloadParityTestsgets six new rows:Task<>overrideIssue7108Testsnow expects 31 rows.DataSourceOverloadParityTests: 31/31 pass in source-gen and reflection modes (net10.0). Before the fix, the default row failed in source-gen (int = 1instead of2), and the covariant row failed to compile (CS0411).TUnit.Core.SourceGenerator.Tests: all pass on net10.0 and net472. No snapshot changes.TUnit.Engine.TestsIssue7108Tests(net10.0): source-gen and reflection variants pass. The AOT variants run only in CI.The earlier net472
AotConverterScanTestspolyfill is dropped from this PR:mainfixed that in #7330.Closes #7202