Skip to content

Fix C# 14 extension members in [Expressive] generation#62

Merged
koenbeuk merged 1 commit intomainfrom
fix/extension-members
May 7, 2026
Merged

Fix C# 14 extension members in [Expressive] generation#62
koenbeuk merged 1 commit intomainfrom
fix/extension-members

Conversation

@koenbeuk
Copy link
Copy Markdown
Collaborator

@koenbeuk koenbeuk commented May 7, 2026

Fixes #60

Copilot AI review requested due to automatic review settings May 7, 2026 01:19
@codecov
Copy link
Copy Markdown

codecov Bot commented May 7, 2026

Codecov Report

❌ Patch coverage is 93.33333% with 1 line in your changes missing coverage. Please review.

Files with missing lines Patch % Lines
....Generator/Interpretation/ExpressiveInterpreter.cs 90.00% 0 Missing and 1 partial ⚠️

📢 Thoughts on this report? Let us know!

Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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 IParameterSymbol and bind it to the generated @this lambda parameter so parameter references in the body resolve correctly.
  • Adjust extension-member descriptor construction to treat static members inside extension(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.

@koenbeuk koenbeuk merged commit b30c757 into main May 7, 2026
21 checks passed
@koenbeuk koenbeuk deleted the fix/extension-members branch May 7, 2026 01:26
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

C# 14 extension members not working

2 participants