Fix C# 14 extension members in [Expressive] generation#62
Merged
Conversation
Codecov Report❌ Patch coverage is
📢 Thoughts on this report? Let us know! |
Contributor
There was a problem hiding this comment.
Pull request overview
Fixes C# 14 extension(T) { } member support in the source generator by ensuring the generated expression-tree lambdas reference the same ParameterExpression that the lambda declares for the extension receiver, restoring correct runtime compilation/translation behavior (Issue #60).
Changes:
- Track the C# 14 extension receiver
IParameterSymboland bind it to the generated@thislambda parameter so parameter references in the body resolve correctly. - Adjust extension-member descriptor construction to treat
staticmembers insideextension(T) { }as non-receiver members. - Add integration coverage for extension methods/properties across several shapes, and update generator verified outputs accordingly.
Reviewed changes
Copilot reviewed 14 out of 14 changed files in this pull request and generated no comments.
Show a summary per file
| File | Description |
|---|---|
| tests/ExpressiveSharp.IntegrationTests/Tests/ExtensionMemberTests.cs | New integration tests validating expanded expression trees compile/evaluate for C# 14 extension members. |
| tests/ExpressiveSharp.IntegrationTests/ExpressiveSharp.IntegrationTests.csproj | Excludes the new C# 14 extension-member test when not targeting net10.0. |
| tests/ExpressiveSharp.Generator.Tests/ExpressiveGenerator/ExtensionMemberTests.*.verified.txt | Updated verified snapshots to reflect correct receiver parameter binding (p__this) in generated trees. |
| src/ExpressiveSharp.Generator/Models/ExpressiveDescriptor.cs | Adds storage for the extension receiver parameter symbol on the descriptor. |
| src/ExpressiveSharp.Generator/Interpretation/ExpressiveInterpreter.cs | Captures the extension receiver symbol and refines instance-vs-static extension member handling. |
| src/ExpressiveSharp.Generator/Interpretation/ExpressiveInterpreter.BodyProcessors.cs | Passes the extension receiver symbol into EmitterParameter for @this so parameter references bind properly. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes #60